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

Commitb9c3a01

Browse files
committed
Merge pull request#165 from torbjoernk/cmake-shared-libs
Enable build of cpp-netlib as shared libraries
2 parents49d3b20 +8131f49 commitb9c3a01

24 files changed

+104
-15
lines changed

‎CMakeLists.txt‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
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+
else()
20+
set(Boost_USE_STATIC_LIBSON)
21+
endif()
1422
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} )
1629
find_package( OpenSSL )
1730
find_package( Threads )
1831
set(CMAKE_VERBOSE_MAKEFILEtrue)
@@ -51,13 +64,27 @@ if (Boost_FOUND)
5164
add_definitions(-D_WIN32_WINNT=0x0501)
5265
endif(WIN32)
5366
include_directories(${Boost_INCLUDE_DIRS})
54-
enable_testing()
67+
if(BUILD_TESTS)
68+
enable_testing()
69+
endif()
5570
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()
6181
endif(Boost_FOUND)
6282

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)")

‎libs/mime/test/CMakeLists.txt‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
include_directories(${CPP-NETLIB_SOURCE_DIR})
2-
find_package ( Boost 1.41.0 COMPONENTS unit_test_framework )
3-
set ( Boost_USE_STATIC_LIBSON )
4-
set ( Boost_USE_MULTITHREADEDON )
52

63
if ( Boost_FOUND )
74
add_executable ( mime-roundtrip mime-roundtrip.cpp )

‎libs/network/src/CMakeLists.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endforeach(src_file)
6161
set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp)
6262
add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
6363
add_dependencies(cppnetlib-http-message
64-
${Boost_LIBRARIES}
64+
# ${Boost_LIBRARIES}
6565
cppnetlib-message)
6666
target_link_libraries(cppnetlib-http-message
6767
${Boost_LIBRARIES}
@@ -99,7 +99,6 @@ set(CPP-NETLIB_HTTP_SERVER_SRCS
9999
)
100100
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
101101
add_dependencies(cppnetlib-http-server
102-
${Boost_LIBRARIES}
103102
cppnetlib-constants
104103
cppnetlib-uri
105104
cppnetlib-message
@@ -108,6 +107,7 @@ add_dependencies(cppnetlib-http-server
108107
cppnetlib-http-message
109108
cppnetlib-http-message-wrappers
110109
cppnetlib-http-server-parsers
110+
cppnetlib-utils-thread_pool
111111
)
112112
target_link_libraries(cppnetlib-http-server
113113
${Boost_LIBRARIES}
@@ -119,6 +119,7 @@ target_link_libraries(cppnetlib-http-server
119119
cppnetlib-http-message
120120
cppnetlib-http-message-wrappers
121121
cppnetlib-http-server-parsers
122+
cppnetlib-utils-thread_pool
122123
)
123124
foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS})
124125
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
@@ -150,7 +151,6 @@ set(CPP-NETLIB_HTTP_CLIENT_SRCS
150151
http/client.cpp)
151152
add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
152153
add_dependencies(cppnetlib-http-client
153-
${Boost_LIBRARIES}
154154
cppnetlib-constants
155155
cppnetlib-uri
156156
cppnetlib-message

‎libs/network/test/CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
include_directories(${CPP-NETLIB_SOURCE_DIR}/include)
77

8+
if(BUILD_SHARED_LIBS)
9+
add_definitions(-DBUILD_SHARED_LIBS)
10+
endif()
11+
812
add_subdirectory(uri)
913
add_subdirectory(http)
1014

‎libs/network/test/http/client_constructor_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// (See accompanying file LICENSE_1_0.txt or copy at
66
// http://www.boost.org/LICENSE_1_0.txt)
77

8+
#ifdef BUILD_SHARED_LIBS
9+
#defineBOOST_TEST_DYN_LINK
10+
#endif
811
#defineBOOST_TEST_MODULE HTTP1.0 Client Constructor Test
912
#include<network/include/http/client.hpp>
1013
#include<boost/test/unit_test.hpp>

‎libs/network/test/http/client_get_different_port_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// (See accompanying file LICENSE_1_0.txt or copy at
66
// http://www.boost.org/LICENSE_1_0.txt)
77

8+
#ifdef BUILD_SHARED_LIBS
9+
#defineBOOST_TEST_DYN_LINK
10+
#endif
811
#defineBOOST_TEST_MODULE HTTP Client Get Different Port Test
912
#include<network/include/http/client.hpp>
1013
#include<boost/test/unit_test.hpp>

‎libs/network/test/http/client_get_streaming_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// (See accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7+
#ifdef BUILD_SHARED_LIBS
8+
#defineBOOST_TEST_DYN_LINK
9+
#endif
710
#defineBOOST_TEST_MODULE HTTP1.1 Get Streaming Test
811
#include<network/include/http/client.hpp>
912
#include<boost/test/unit_test.hpp>

‎libs/network/test/http/client_get_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// (See accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7+
#ifdef BUILD_SHARED_LIBS
8+
#defineBOOST_TEST_DYN_LINK
9+
#endif
710
#defineBOOST_TEST_MODULE HTTP1.0 Get Test
811
#include<network/include/http/client.hpp>
912
#include<boost/test/unit_test.hpp>

‎libs/network/test/http/client_get_timeout_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// (See accompanying file LICENSE_1_0.txt or copy at
66
// http://www.boost.org/LICENSE_1_0.txt)
77

8+
#ifdef BUILD_SHARED_LIBS
9+
#defineBOOST_TEST_DYN_LINK
10+
#endif
811
#defineBOOST_TEST_MODULE HTTP Client Get Timeout Test
912
#include<network/include/http/client.hpp>
1013
#include<boost/test/unit_test.hpp>

‎libs/network/test/http/request_base_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// (See accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7+
#ifdef BUILD_SHARED_LIBS
8+
#defineBOOST_TEST_DYN_LINK
9+
#endif
710
#defineBOOST_TEST_MODULE HTTP Request Storage Base Test
811
#include<network/protocol/http/request/request_base.hpp>
912
#include<boost/test/unit_test.hpp>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp