Skip to content

Commit 2abe24f

Browse files
author
Mark Ellzey
committed
Examples will only built if "make examples" is run.
1 parent 32bd829 commit 2abe24f

File tree

7 files changed

+27
-35
lines changed

7 files changed

+27
-35
lines changed

CMakeLists.txt

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -195,49 +195,35 @@ if (NOT APPLE)
195195
set (SYS_LIBS ${SYS_LIBS} ${LIB_RT})
196196
endif()
197197

198-
if (EVHTP_BUILD_SHARED)
199-
add_library(libevhtpShared SHARED ${LIBEVHTP_SOURCES} ${ONIG_SOURCES})
200-
set_target_properties(libevhtpShared PROPERTIES OUTPUT_NAME "evhtp")
201-
target_link_libraries(libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS})
202-
install (TARGETS libevhtpShared DESTINATION lib)
203-
204-
add_executable(test test.c)
205-
target_link_libraries(test libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
206-
207-
add_executable(test_basic test_basic.c)
208-
target_link_libraries(test_basic libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
209-
210-
add_executable(test_vhost test_vhost.c)
211-
target_link_libraries(test_vhost libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
212-
213-
add_executable(test_client test_client.c)
214-
target_link_libraries(test_client libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
215-
216-
add_executable(test_proxy test_proxy.c)
217-
target_link_libraries(test_proxy libevhtpShared ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
198+
add_custom_target(examples)
218199

200+
if (EVHTP_BUILD_SHARED)
201+
set (EVHTP_LIBTYPE SHARED)
219202
else()
220-
add_library(libevhtpStatic STATIC ${LIBEVHTP_SOURCES} ${ONIG_SOURCES})
221-
set_target_properties(libevhtpStatic PROPERTIES OUTPUT_NAME "evhtp")
222-
install (TARGETS libevhtpStatic DESTINATION lib)
203+
set (EVHTP_LIBTYPE STATIC)
204+
endif()
223205

224-
add_executable(test test.c)
225-
target_link_libraries(test libevhtpStatic ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
206+
add_library(libevhtp ${EVHTP_LIBTYPE} ${LIBEVHTP_SOURCES} ${ONIG_SOURCES})
226207

227-
add_executable(test_basic test_basic.c)
228-
target_link_libraries(test_basic libevhtpStatic ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
208+
set_target_properties(libevhtp PROPERTIES OUTPUT_NAME "evhtp")
209+
target_link_libraries(libevhtp ${LIBEVHTP_EXTERNAL_LIBS})
229210

230-
add_executable(test_vhost test_vhost.c)
231-
target_link_libraries(test_vhost libevhtpStatic ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
232211

233-
add_executable(test_client test_client.c)
234-
target_link_libraries(test_client libevhtpStatic ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
212+
add_executable(test EXCLUDE_FROM_ALL examples/test.c)
213+
add_executable(test_basic EXCLUDE_FROM_ALL examples/test_basic.c)
214+
add_executable(test_vhost EXCLUDE_FROM_ALL examples/test_vhost.c)
215+
add_executable(test_client EXCLUDE_FROM_ALL examples/test_client.c)
216+
add_executable(test_proxy EXCLUDE_FROM_ALL examples/test_proxy.c)
235217

236-
add_executable(test_proxy test_proxy.c)
237-
target_link_libraries(test_proxy libevhtpStatic ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
218+
target_link_libraries(test libevhtp ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
219+
target_link_libraries(test_basic libevhtp ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
220+
target_link_libraries(test_vhost libevhtp ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
221+
target_link_libraries(test_client libevhtp ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
222+
target_link_libraries(test_proxy libevhtp ${LIBEVHTP_EXTERNAL_LIBS} ${SYS_LIBS})
238223

239-
endif()
224+
add_dependencies(examples test test_basic test_vhost test_client test_proxy)
240225

226+
install (TARGETS libevhtp DESTINATION lib)
241227
install (FILES evhtp.h DESTINATION include)
242228
install (FILES htparse/htparse.h DESTINATION include)
243229
install (FILES evthr/evthr.h DESTINATION include)

README.markdown

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ probably not very awesome, it's best to look at test.c to see advanced usage.
1212
* [OpenSSL](http://openssl.org)
1313
* pthreads
1414

15+
## Building
16+
* cd build
17+
* cmake ..
18+
* make
19+
* make examples
20+
1521
## Overview
1622
***
1723

@@ -34,7 +40,7 @@ Libevhtp attempts to address these problems along with a wide variety of cool me
3440
### A bit about the architecture of libevhtp
3541
***
3642

37-
#### Bootstrapping
43+
#### Bootstrapping
3844

3945
1. Create a parent evhtp_t structure.
4046
2. Assign callbacks to the parent for specific URIs or posix-regex based URI's

test.c renamed to examples/test.c

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)