|
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_LIBS ON) |
| 17 | +if(BUILD_SHARED_LIBS) |
| 18 | + set(Boost_USE_STATIC_LIBS OFF) |
| 19 | + # TODO/NOTE: |
| 20 | + # the unit tests and examples won't compile with the current setup and |
| 21 | + # shared libraries yet |
| 22 | + set(BUILD_TESTS OFF) |
| 23 | + set(BUILD_EXAMPLES OFF) |
| 24 | +else() |
| 25 | + set(Boost_USE_STATIC_LIBS ON) |
| 26 | +endif() |
14 | 27 | set(Boost_USE_MULTITHREADED ON)
|
15 |
| -find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options ) |
| 28 | +if(BUILD_TESTS) |
| 29 | + set(Boost_COMPONENTS unit_test_framework system regex date_time thread chrono filesystem program_options ) |
| 30 | +else() |
| 31 | + set(Boost_COMPONENTS system regex date_time thread chrono filesystem program_options ) |
| 32 | +endif() |
| 33 | +find_package( Boost 1.45.0 REQUIRED ${Boost_COMPONENTS} ) |
16 | 34 | find_package( OpenSSL )
|
17 | 35 | find_package( Threads )
|
18 | 36 | set(CMAKE_VERBOSE_MAKEFILE true)
|
@@ -51,13 +69,27 @@ if (Boost_FOUND)
|
51 | 69 | add_definitions(-D_WIN32_WINNT=0x0501)
|
52 | 70 | endif(WIN32)
|
53 | 71 | include_directories(${Boost_INCLUDE_DIRS})
|
54 |
| - enable_testing() |
| 72 | + if(BUILD_TESTS) |
| 73 | + enable_testing() |
| 74 | + endif() |
55 | 75 | add_subdirectory(libs/network/src)
|
56 |
| - add_subdirectory(libs/network/test) |
57 |
| - if (NOT MSVC) |
58 |
| - add_subdirectory(libs/mime/test) |
59 |
| - endif(NOT MSVC) |
60 |
| - add_subdirectory(libs/network/example) |
| 76 | + if(BUILD_TESTS) |
| 77 | + enable_testing() |
| 78 | + add_subdirectory(libs/network/test) |
| 79 | + if (NOT MSVC) |
| 80 | + add_subdirectory(libs/mime/test) |
| 81 | + endif(NOT MSVC) |
| 82 | + endif() |
| 83 | + if(BUILD_EXAMPLES) |
| 84 | + add_subdirectory(libs/network/example) |
| 85 | + endif() |
61 | 86 | endif(Boost_FOUND)
|
62 | 87 |
|
63 |
| -enable_testing() |
| 88 | +if(BUILD_TESTS) |
| 89 | + enable_testing() |
| 90 | +endif() |
| 91 | + |
| 92 | +message(STATUS "Options selected:") |
| 93 | +message(STATUS " BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)") |
| 94 | +message(STATUS " BUILD_TESTS: ${BUILD_TESTS}\t(Build the unit tests: ON, OFF)") |
| 95 | +message(STATUS " BUILD_EXAMPLES: ${BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)") |
0 commit comments