Skip to content

Commit 645cc74

Browse files
committed
Merge pull request #10 from cpp-netlib/master
Sync from cpp-netlib/cpp-netlib.
2 parents b7617ff + b9c3a01 commit 645cc74

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_LIBS ON)
17+
if(BUILD_SHARED_LIBS)
18+
set(Boost_USE_STATIC_LIBS OFF)
19+
else()
20+
set(Boost_USE_STATIC_LIBS ON)
21+
endif()
1422
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 )
23+
if(BUILD_TESTS)
24+
set(Boost_COMPONENTS unit_test_framework system regex date_time thread chrono filesystem program_options )
25+
else()
26+
set(Boost_COMPONENTS system regex 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_MAKEFILE true)
@@ -57,13 +70,27 @@ if (Boost_FOUND)
5770
add_definitions(-D_WIN32_WINNT=0x0501)
5871
endif(WIN32)
5972
include_directories(${Boost_INCLUDE_DIRS})
60-
enable_testing()
73+
if(BUILD_TESTS)
74+
enable_testing()
75+
endif()
6176
add_subdirectory(libs/network/src)
62-
add_subdirectory(libs/network/test)
63-
if (NOT MSVC)
64-
add_subdirectory(libs/mime/test)
65-
endif(NOT MSVC)
66-
add_subdirectory(libs/network/example)
77+
if(BUILD_TESTS)
78+
enable_testing()
79+
add_subdirectory(libs/network/test)
80+
if (NOT MSVC)
81+
add_subdirectory(libs/mime/test)
82+
endif(NOT MSVC)
83+
endif()
84+
if(BUILD_EXAMPLES)
85+
add_subdirectory(libs/network/example)
86+
endif()
6787
endif(Boost_FOUND)
6888

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

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_LIBS ON )
4-
set ( Boost_USE_MULTITHREADED ON )
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
@@ -77,7 +77,7 @@ endforeach(src_file)
7777
set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp)
7878
add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
7979
add_dependencies(cppnetlib-http-message
80-
${Boost_LIBRARIES}
80+
# ${Boost_LIBRARIES}
8181
cppnetlib-message)
8282
target_link_libraries(cppnetlib-http-message
8383
${Boost_LIBRARIES}
@@ -124,7 +124,6 @@ set(CPP-NETLIB_HTTP_SERVER_SRCS
124124
)
125125
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
126126
add_dependencies(cppnetlib-http-server
127-
${Boost_LIBRARIES}
128127
cppnetlib-constants
129128
cppnetlib-uri
130129
cppnetlib-message
@@ -133,6 +132,7 @@ add_dependencies(cppnetlib-http-server
133132
cppnetlib-http-message
134133
cppnetlib-http-message-wrappers
135134
cppnetlib-http-server-parsers
135+
cppnetlib-utils-thread_pool
136136
)
137137
target_link_libraries(cppnetlib-http-server
138138
${Boost_LIBRARIES}
@@ -144,6 +144,7 @@ target_link_libraries(cppnetlib-http-server
144144
cppnetlib-http-message
145145
cppnetlib-http-message-wrappers
146146
cppnetlib-http-server-parsers
147+
cppnetlib-utils-thread_pool
147148
)
148149
foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS})
149150
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
@@ -181,7 +182,6 @@ set(CPP-NETLIB_HTTP_CLIENT_SRCS
181182
http/client.cpp)
182183
add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
183184
add_dependencies(cppnetlib-http-client
184-
${Boost_LIBRARIES}
185185
cppnetlib-constants
186186
cppnetlib-uri
187187
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+
# define BOOST_TEST_DYN_LINK
10+
#endif
811
#define BOOST_TEST_MODULE HTTP 1.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+
# define BOOST_TEST_DYN_LINK
10+
#endif
811
#define BOOST_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+
# define BOOST_TEST_DYN_LINK
9+
#endif
710
#define BOOST_TEST_MODULE HTTP 1.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+
# define BOOST_TEST_DYN_LINK
9+
#endif
710
#define BOOST_TEST_MODULE HTTP 1.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+
# define BOOST_TEST_DYN_LINK
10+
#endif
811
#define BOOST_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+
# define BOOST_TEST_DYN_LINK
9+
#endif
710
#define BOOST_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)