Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteaa0cac

Browse files
committed
add CMake options for shared libs, tests, examples
Add options to CMake to enable build of cpp-netlib as shared libraries.New options are: BUILD_SHARED_LIBS (default OFF) BUILD_TESTS (default ON) BUILD_EXAMPLES (default ON)As the current (CMakeLists-)setup of the tests and examples does notwork with a shared cpp-netlib build, those get not build then.Specify with `cmake -D<OPTION>=<ON|OFF>`
1 parent49d3b20 commiteaa0cac

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

‎CMakeLists.txt‎

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,30 @@
77
cmake_minimum_required(VERSION 2.8)
88
project(CPP-NETLIB)
99

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+
1014
set(CMAKE_MODULE_PATH${CMAKE_CURRENT_SOURCE_DIR})
1115
find_package( ICU )
1216

13-
set(Boost_USE_STATIC_LIBSON)
17+
if(BUILD_SHARED_LIBS)
18+
set(Boost_USE_STATIC_LIBSOFF)
19+
# TODO/NOTE:
20+
# the unit tests and examples won't compile with the current setup and
21+
# shared libraries yet
22+
set(BUILD_TESTSOFF)
23+
set(BUILD_EXAMPLESOFF)
24+
else()
25+
set(Boost_USE_STATIC_LIBSON)
26+
endif()
1427
set(Boost_USE_MULTITHREADEDON)
15-
find_package( Boost 1.45.0 REQUIRED unit_test_frameworksystemregex date_time thread chrono filesystem program_options )
28+
if(BUILD_TESTS)
29+
set(Boost_COMPONENTS unit_test_frameworksystemregex date_time thread chrono filesystem program_options )
30+
else()
31+
set(Boost_COMPONENTSsystemregex date_time thread chrono filesystem program_options )
32+
endif()
33+
find_package( Boost 1.45.0 REQUIRED${Boost_COMPONENTS} )
1634
find_package( OpenSSL )
1735
find_package( Threads )
1836
set(CMAKE_VERBOSE_MAKEFILEtrue)
@@ -51,13 +69,27 @@ if (Boost_FOUND)
5169
add_definitions(-D_WIN32_WINNT=0x0501)
5270
endif(WIN32)
5371
include_directories(${Boost_INCLUDE_DIRS})
54-
enable_testing()
72+
if(BUILD_TESTS)
73+
enable_testing()
74+
endif()
5575
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)
76+
if(BUILD_TESTS)
77+
enable_testing()
78+
add_subdirectory(libs/network/test)
79+
if (NOTMSVC)
80+
add_subdirectory(libs/mime/test)
81+
endif(NOTMSVC)
82+
endif()
83+
if(BUILD_EXAMPLES)
84+
add_subdirectory(libs/network/example)
85+
endif()
6186
endif(Boost_FOUND)
6287

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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp