|
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) |
@@ -57,13 +70,27 @@ if (Boost_FOUND) |
57 | 70 | add_definitions(-D_WIN32_WINNT=0x0501) |
58 | 71 | endif(WIN32) |
59 | 72 | include_directories(${Boost_INCLUDE_DIRS}) |
60 | | - enable_testing() |
| 73 | + if(BUILD_TESTS) |
| 74 | + enable_testing() |
| 75 | + endif() |
61 | 76 | add_subdirectory(libs/network/src) |
62 | | - add_subdirectory(libs/network/test) |
63 | | - if (NOTMSVC) |
64 | | - add_subdirectory(libs/mime/test) |
65 | | - endif(NOTMSVC) |
66 | | - add_subdirectory(libs/network/example) |
| 77 | + if(BUILD_TESTS) |
| 78 | + enable_testing() |
| 79 | + add_subdirectory(libs/network/test) |
| 80 | + if (NOTMSVC) |
| 81 | + add_subdirectory(libs/mime/test) |
| 82 | + endif(NOTMSVC) |
| 83 | + endif() |
| 84 | + if(BUILD_EXAMPLES) |
| 85 | + add_subdirectory(libs/network/example) |
| 86 | + endif() |
67 | 87 | endif(Boost_FOUND) |
68 | 88 |
|
69 | | -enable_testing() |
| 89 | +if(BUILD_TESTS) |
| 90 | + enable_testing() |
| 91 | +endif() |
| 92 | + |
| 93 | +message(STATUS"Options selected:") |
| 94 | +message(STATUS" BUILD_SHARED_LIBS:${BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)") |
| 95 | +message(STATUS" BUILD_TESTS:${BUILD_TESTS}\t(Build the unit tests: ON, OFF)") |
| 96 | +message(STATUS" BUILD_EXAMPLES:${BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)") |