Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@
cmake_minimum_required(VERSION 2.8)
project(CPP-NETLIB)

option(BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF)
option(BUILD_TESTS "Build the unit tests." ON)
option(BUILD_EXAMPLES "Build the examples using cpp-netlib." ON)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package( ICU )

set(Boost_USE_STATIC_LIBS ON)
if(BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS OFF)
else()
set(Boost_USE_STATIC_LIBS ON)
endif()
set(Boost_USE_MULTITHREADED ON)
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options )
if(BUILD_TESTS)
set(Boost_COMPONENTS unit_test_framework system regex date_time thread chrono filesystem program_options )
else()
set(Boost_COMPONENTS system regex date_time thread chrono filesystem program_options )
endif()
find_package( Boost 1.51 REQUIRED ${Boost_COMPONENTS} )
find_package( OpenSSL )
find_package( Threads )
set(CMAKE_VERBOSE_MAKEFILE true)
Expand Down Expand Up @@ -51,13 +64,27 @@ if (Boost_FOUND)
add_definitions(-D_WIN32_WINNT=0x0501)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})
enable_testing()
if(BUILD_TESTS)
enable_testing()
endif()
add_subdirectory(libs/network/src)
add_subdirectory(libs/network/test)
if (NOT MSVC)
add_subdirectory(libs/mime/test)
endif(NOT MSVC)
add_subdirectory(libs/network/example)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(libs/network/test)
if (NOT MSVC)
add_subdirectory(libs/mime/test)
endif(NOT MSVC)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(libs/network/example)
endif()
endif(Boost_FOUND)

enable_testing()
if(BUILD_TESTS)
enable_testing()
endif()

message(STATUS "Options selected:")
message(STATUS " BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
message(STATUS " BUILD_TESTS: ${BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
message(STATUS " BUILD_EXAMPLES: ${BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)")
3 changes: 0 additions & 3 deletions libs/mime/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
include_directories(${CPP-NETLIB_SOURCE_DIR})
find_package ( Boost 1.41.0 COMPONENTS unit_test_framework )
set ( Boost_USE_STATIC_LIBS ON )
set ( Boost_USE_MULTITHREADED ON )

if ( Boost_FOUND )
add_executable ( mime-roundtrip mime-roundtrip.cpp )
Expand Down
6 changes: 3 additions & 3 deletions libs/network/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ endforeach(src_file)
set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp)
add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
add_dependencies(cppnetlib-http-message
${Boost_LIBRARIES}
# ${Boost_LIBRARIES}
cppnetlib-message)
target_link_libraries(cppnetlib-http-message
${Boost_LIBRARIES}
Expand Down Expand Up @@ -99,7 +99,6 @@ set(CPP-NETLIB_HTTP_SERVER_SRCS
)
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
add_dependencies(cppnetlib-http-server
${Boost_LIBRARIES}
cppnetlib-constants
cppnetlib-uri
cppnetlib-message
Expand All @@ -108,6 +107,7 @@ add_dependencies(cppnetlib-http-server
cppnetlib-http-message
cppnetlib-http-message-wrappers
cppnetlib-http-server-parsers
cppnetlib-utils-thread_pool
)
target_link_libraries(cppnetlib-http-server
${Boost_LIBRARIES}
Expand All @@ -119,6 +119,7 @@ target_link_libraries(cppnetlib-http-server
cppnetlib-http-message
cppnetlib-http-message-wrappers
cppnetlib-http-server-parsers
cppnetlib-utils-thread_pool
)
foreach (src_file ${CPP-NETLIB_HTTP_SERVER_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
Expand Down Expand Up @@ -150,7 +151,6 @@ set(CPP-NETLIB_HTTP_CLIENT_SRCS
http/client.cpp)
add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
add_dependencies(cppnetlib-http-client
${Boost_LIBRARIES}
cppnetlib-constants
cppnetlib-uri
cppnetlib-message
Expand Down
4 changes: 4 additions & 0 deletions libs/network/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

include_directories(${CPP-NETLIB_SOURCE_DIR}/include)

if(BUILD_SHARED_LIBS)
add_definitions(-DBUILD_SHARED_LIBS)
endif()

add_subdirectory(uri)
add_subdirectory(http)

Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/client_constructor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP 1.0 Client Constructor Test
#include <network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/client_get_different_port_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Client Get Different Port Test
#include <network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/client_get_streaming_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP 1.1 Get Streaming Test
#include <network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/client_get_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP 1.0 Get Test
#include <network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/client_get_timeout_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Client Get Timeout Test
#include <network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/request_base_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Request Storage Base Test
#include <network/protocol/http/request/request_base.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/request_linearize_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Request Linearize Test
#include <network/protocol/http/request.hpp>
#include <network/protocol/http/algorithms/linearize.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/request_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Request Test
#include <network/protocol/http/request.hpp>
#include <network/protocol/http/message/wrappers.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/response_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Client Response Test
#include <network/protocol/http/response.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
4 changes: 4 additions & 0 deletions libs/network/test/http/server_async_run_stop_concurrency.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
# define BOOST_TEST_NO_MAIN
#endif
#define BOOST_TEST_MODULE HTTP Asynchronous Server Tests

#include <network/include/http/server.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/http/server_constructor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE HTTP Server Construtor Tests

#include <network/include/http/server.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/message_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE message test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/message_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE message test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/relative_uri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE Relative URL Test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/scheme_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE URI Scheme Test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/uri_builder_stream_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE URI builder stream test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/uri_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE URI builder test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/uri_encoding_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE URI encoding test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/uri/uri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// (See accompanying file LICENSE_1_0.txt of copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE URI Test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down
3 changes: 3 additions & 0 deletions libs/network/test/utils_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULE utils thread pool test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
Expand Down