|
7 | 7 | cmake_minimum_required(VERSION 2.8) |
8 | 8 | project(CPP-NETLIB) |
9 | 9 |
|
| 10 | +option(BUILD_SHARED_LIBS"Build cpp-netlib as shared libraries."OFF) |
| 11 | +option(BUILD_TESTS"Build the unit tests."ON) |
| 12 | +option(BUILD_EXAMPLES"Build the examples using cpp-netlib."ON) |
| 13 | + |
10 | 14 | set(CMAKE_MODULE_PATH${CMAKE_CURRENT_SOURCE_DIR}) |
11 | 15 | find_package( ICU ) |
12 | 16 |
|
13 | | -set(Boost_USE_STATIC_LIBSON) |
| 17 | +if(BUILD_SHARED_LIBS) |
| 18 | + set(Boost_USE_STATIC_LIBSOFF) |
| 19 | +else() |
| 20 | + set(Boost_USE_STATIC_LIBSON) |
| 21 | +endif() |
14 | 22 | set(Boost_USE_MULTITHREADEDON) |
15 | | -find_package( Boost 1.45.0 REQUIRED unit_test_frameworksystemregex date_time thread chrono filesystem program_options ) |
| 23 | +if(BUILD_TESTS) |
| 24 | + set(Boost_COMPONENTS unit_test_frameworksystemregex date_time thread chrono filesystem program_options ) |
| 25 | +else() |
| 26 | + set(Boost_COMPONENTSsystemregex date_time thread chrono filesystem program_options ) |
| 27 | +endif() |
| 28 | +find_package( Boost 1.51 REQUIRED${Boost_COMPONENTS} ) |
16 | 29 | find_package( OpenSSL ) |
17 | 30 | find_package( Threads ) |
18 | 31 | set(CMAKE_VERBOSE_MAKEFILEtrue) |
@@ -51,13 +64,27 @@ if (Boost_FOUND) |
51 | 64 | add_definitions(-D_WIN32_WINNT=0x0501) |
52 | 65 | endif(WIN32) |
53 | 66 | include_directories(${Boost_INCLUDE_DIRS}) |
54 | | - enable_testing() |
| 67 | + if(BUILD_TESTS) |
| 68 | + enable_testing() |
| 69 | + endif() |
55 | 70 | add_subdirectory(libs/network/src) |
56 | | - add_subdirectory(libs/network/test) |
57 | | - if (NOTMSVC) |
58 | | - add_subdirectory(libs/mime/test) |
59 | | - endif(NOTMSVC) |
60 | | - add_subdirectory(libs/network/example) |
| 71 | + if(BUILD_TESTS) |
| 72 | + enable_testing() |
| 73 | + add_subdirectory(libs/network/test) |
| 74 | + if (NOTMSVC) |
| 75 | + add_subdirectory(libs/mime/test) |
| 76 | + endif(NOTMSVC) |
| 77 | + endif() |
| 78 | + if(BUILD_EXAMPLES) |
| 79 | + add_subdirectory(libs/network/example) |
| 80 | + endif() |
61 | 81 | endif(Boost_FOUND) |
62 | 82 |
|
63 | | -enable_testing() |
| 83 | +if(BUILD_TESTS) |
| 84 | + enable_testing() |
| 85 | +endif() |
| 86 | + |
| 87 | +message(STATUS"Options selected:") |
| 88 | +message(STATUS" BUILD_SHARED_LIBS:${BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)") |
| 89 | +message(STATUS" BUILD_TESTS:${BUILD_TESTS}\t(Build the unit tests: ON, OFF)") |
| 90 | +message(STATUS" BUILD_EXAMPLES:${BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)") |