Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #227 from torbjoernk/make-one-lib

Enable cpp-netlib to be build into a single library
  • Loading branch information...
commit 7af8275a65d65abe681943752227a976b99201d7 2 parents 7a953e7 + 04c2039
Dean Michael Berris deanberris authored
29 CMakeLists.txt
View
@@ -8,6 +8,7 @@ cmake_minimum_required(VERSION 2.8)
project(CPP-NETLIB)
option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF )
+option( CPP-NETLIB_BUILD_SINGLE_LIB "Build cpp-netlib into a single library" OFF )
option( CPP-NETLIB_BUILD_TESTS "Build the unit tests." ON )
option( CPP-NETLIB_BUILD_EXAMPLES "Build the examples using cpp-netlib." ON )
option( CPP-NETLIB_ALWAYS_LOGGING "Allow cpp-netlib to log debug messages even in non-debug mode." OFF )
@@ -87,6 +88,7 @@ endif(Boost_FOUND)
message(STATUS "CPP-NETLIB options selected:")
message(STATUS " CPP-NETLIB_BUILD_SHARED_LIBS: ${CPP-NETLIB_BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
+message(STATUS " CPP-NETLIB_BUILD_SINGLE_LIB: ${CPP-NETLIB_BUILD_SINGLE_LIB}\t(Build cpp-netlib into a single library: OFF, ON)")
message(STATUS " CPP-NETLIB_BUILD_TESTS: ${CPP-NETLIB_BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
message(STATUS " CPP-NETLIB_BUILD_EXAMPLES: ${CPP-NETLIB_BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)")
message(STATUS " CPP-NETLIB_ALWAYS_LOGGING: ${CPP-NETLIB_ALWAYS_LOGGING}\t(Allow cpp-netlib to log debug messages even in non-debug mode: ON, OFF)")
@@ -127,6 +129,16 @@ if(CPP-NETLIB_BUILD_TESTS)
set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES})
endif()
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/concurrency/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/logging/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/message/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/uri/src
+ )
+endif()
+
add_subdirectory(uri)
add_subdirectory(message)
add_subdirectory(logging)
@@ -136,3 +148,20 @@ add_subdirectory(http)
if(CPP-NETLIB_BUILD_EXAMPLES)
add_subdirectory(contrib/http_examples)
endif()
+
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib
+ ${Uri_SRCS}
+ ${CPP-NETLIB_MESSAGE_SRCS}
+ ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}
+ ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}
+ ${CPP-NETLIB_LOGGING_SRCS}
+ ${CPP-NETLIB_HTTP_CLIENT_SRCS}
+ ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}
+ ${CPP-NETLIB_HTTP_MESSAGE_SRCS}
+ ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS}
+ ${CPP-NETLIB_CONSTANTS_SRCS}
+ ${CPP-NETLIB_CONCURRENCY_SRCS}
+ )
+ target_link_libraries(cppnetlib ${Boost_LIBRARIES})
+endif()
3  concurrency/CMakeLists.txt
View
@@ -9,3 +9,6 @@ if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(CPP-NETLIB_BUILD_TESTS)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_CONCURRENCY_SRCS ${CPP-NETLIB_CONCURRENCY_SRCS} PARENT_SCOPE)
9 concurrency/src/CMakeLists.txt
View
@@ -16,8 +16,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endif()
-set(CPP-NETLIB_CONCURRENCY_SRCS thread_pool.cpp)
-add_library(cppnetlib-concurrency ${CPP-NETLIB_CONCURRENCY_SRCS})
+set(CPP-NETLIB_CONCURRENCY_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/thread_pool.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-concurrency ${CPP-NETLIB_CONCURRENCY_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_CONCURRENCY_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -27,3 +29,6 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_CONCURRENCY_SRCS ${CPP-NETLIB_CONCURRENCY_SRCS} PARENT_SCOPE)
7 concurrency/test/CMakeLists.txt
View
@@ -7,11 +7,16 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src
${GTEST_INCLUDE_DIRS}
)
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(link_cppnetlib_lib cppnetlib)
+else()
+ set(link_cppnetlib_lib cppnetlib-concurrency)
+endif()
set_source_files_properties(thread_pool_test.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
add_executable(cpp-netlib-thread_pool_test thread_pool_test.cpp)
target_link_libraries(cpp-netlib-thread_pool_test
- cppnetlib-concurrency
+ ${link_cppnetlib_lib}
${Boost_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
44 contrib/http_examples/CMakeLists.txt
View
@@ -40,9 +40,10 @@ set(BOOST_SERVER_LIBS
${Boost_PROGRAM_OPTIONS_LIBRARY}
)
-target_link_libraries(simple_wget
- ${BOOST_CLIENT_LIBS}
- ${CMAKE_THREAD_LIBS_INIT}
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(simple_wget_linklibs cppnetlib)
+else()
+ set(simple_wget_linklibs
cppnetlib-uri
cppnetlib-message
cppnetlib-message-directives
@@ -53,10 +54,16 @@ target_link_libraries(simple_wget
cppnetlib-http-client
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})
-
-target_link_libraries(atom_reader
+endif()
+target_link_libraries(simple_wget
${BOOST_CLIENT_LIBS}
${CMAKE_THREAD_LIBS_INIT}
+ ${simple_wget_linklibs})
+
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(atom_reader_linklibs cppnetlib)
+else()
+ set(atom_reader_linklibs
cppnetlib-uri
cppnetlib-message
cppnetlib-message-directives
@@ -67,10 +74,16 @@ target_link_libraries(atom_reader
cppnetlib-http-client
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})
-
-target_link_libraries(rss_reader
+endif()
+target_link_libraries(atom_reader
${BOOST_CLIENT_LIBS}
${CMAKE_THREAD_LIBS_INIT}
+ ${atom_reader_linklibs})
+
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(rss_reader_linklibs cppnetlib)
+else()
+ set(rss_reader_linklibs
cppnetlib-uri
cppnetlib-message
cppnetlib-message-directives
@@ -80,6 +93,11 @@ target_link_libraries(rss_reader
cppnetlib-http-client
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})
+endif()
+target_link_libraries(rss_reader
+ ${BOOST_CLIENT_LIBS}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${rss_reader_linklibs})
#target_link_libraries(twitter_search
# ${BOOST_CLIENT_LIBS}
@@ -102,9 +120,10 @@ target_link_libraries(rss_reader
# cppnetlib-http-server
# ${CPP-NETLIB_LOGGING_LIB})
-target_link_libraries(hello_world_client
- ${BOOST_CLIENT_LIBS}
- ${CMAKE_THREAD_LIBS_INIT}
+if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(hello_world_client_linklibs cppnetlib)
+else()
+ set(hello_world_client_linklibs
cppnetlib-uri
cppnetlib-message
cppnetlib-message-directives
@@ -115,6 +134,11 @@ target_link_libraries(hello_world_client
cppnetlib-http-client
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})
+endif()
+target_link_libraries(hello_world_client
+ ${BOOST_CLIENT_LIBS}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${hello_world_client_linklibs})
if (OPENSSL_FOUND)
target_link_libraries(simple_wget ${OPENSSL_LIBRARIES})
7 http/CMakeLists.txt
View
@@ -9,3 +9,10 @@ if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(CPP-NETLIB_BUILD_TESTS)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
116 http/src/CMakeLists.txt
View
@@ -33,14 +33,18 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endif()
-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}
- cppnetlib-message)
-target_link_libraries(cppnetlib-http-message
- ${Boost_LIBRARIES}
- cppnetlib-message)
+set(CPP-NETLIB_HTTP_MESSAGE_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/request.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/response.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
+ add_dependencies(cppnetlib-http-message
+# ${Boost_LIBRARIES}
+ cppnetlib-message)
+ target_link_libraries(cppnetlib-http-message
+ ${Boost_LIBRARIES}
+ cppnetlib-message)
+endif()
foreach (src_file ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -51,8 +55,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endforeach(src_file)
-set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS http/message/wrappers.cpp)
-add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
+set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/http/message/wrappers.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -118,17 +124,19 @@ endforeach(src_file)
#endforeach(src_file)
set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
- http/client_connections.cpp
- http/simple_connection_manager.cpp
- http/simple_connection_factory.cpp
- http/connection_delegate_factory.cpp
- http/client_resolver_delegate.cpp
- http/client_resolver_delegate_factory.cpp
- http/client_connection_delegates.cpp
- http/client_connection_factory.cpp
- http/client_async_resolver.cpp
- http/client_connection_normal.cpp)
-add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_connections.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/simple_connection_manager.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/simple_connection_factory.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/connection_delegate_factory.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_resolver_delegate.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_resolver_delegate_factory.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_connection_delegates.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_connection_factory.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_async_resolver.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client_connection_normal.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -140,31 +148,33 @@ endif()
endforeach(src_file)
set(CPP-NETLIB_HTTP_CLIENT_SRCS
- http/client.cpp)
-add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
-add_dependencies(cppnetlib-http-client
- ${CPP-NETLIB_LOGGING_LIB}
- cppnetlib-constants
- cppnetlib-uri
- cppnetlib-message
- cppnetlib-message-wrappers
- cppnetlib-message-directives
- cppnetlib-http-message
- cppnetlib-http-message-wrappers
- cppnetlib-http-client-connections
- )
-target_link_libraries(cppnetlib-http-client
- ${Boost_LIBRARIES}
- ${CPP-NETLIB_LOGGING_LIB}
- cppnetlib-constants
- cppnetlib-uri
- cppnetlib-message
- cppnetlib-message-wrappers
- cppnetlib-message-directives
- cppnetlib-http-message
- cppnetlib-http-message-wrappers
- cppnetlib-http-client-connections
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/http/client.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
+ add_dependencies(cppnetlib-http-client
+ ${CPP-NETLIB_LOGGING_LIB}
+ cppnetlib-constants
+ cppnetlib-uri
+ cppnetlib-message
+ cppnetlib-message-wrappers
+ cppnetlib-message-directives
+ cppnetlib-http-message
+ cppnetlib-http-message-wrappers
+ cppnetlib-http-client-connections
+ )
+ target_link_libraries(cppnetlib-http-client
+ ${Boost_LIBRARIES}
+ ${CPP-NETLIB_LOGGING_LIB}
+ cppnetlib-constants
+ cppnetlib-uri
+ cppnetlib-message
+ cppnetlib-message-wrappers
+ cppnetlib-message-directives
+ cppnetlib-http-message
+ cppnetlib-http-message-wrappers
+ cppnetlib-http-client-connections
+ )
+endif()
foreach (src_file ${CPP-NETLIB_HTTP_CLIENT_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -175,8 +185,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endforeach(src_file)
-set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp)
-add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
+set(CPP-NETLIB_CONSTANTS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/constants.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_CONSTANTS_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -186,3 +198,11 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)
+
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
56 http/test/CMakeLists.txt
View
@@ -30,34 +30,37 @@ if (CPP-NETLIB_BUILD_TESTS)
request_base_test
request_test
response_test
- response_incremental_parser_test
- )
+ response_incremental_parser_test)
+ if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(link_cppnetlib_lib cppnetlib)
+ set(dependencies cppnetlib)
+ else()
+ set(link_cppnetlib_lib cppnetlib-message
+ cppnetlib-message-wrappers
+ cppnetlib-http-message
+ cppnetlib-http-message-wrappers
+ cppnetlib-uri
+ cppnetlib-constants)
+ set(dependencies cppnetlib-message
+ cppnetlib-message-wrappers
+ cppnetlib-http-message
+ cppnetlib-http-message-wrappers
+ cppnetlib-uri
+ cppnetlib-constants)
+ endif()
foreach ( test ${MESSAGE_TESTS} )
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${test}.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-http-${test} ${test}.cpp)
- add_dependencies(cpp-netlib-http-${test}
- cppnetlib-message
- cppnetlib-message-wrappers
- cppnetlib-http-message
- cppnetlib-http-message-wrappers
- cppnetlib-uri
- cppnetlib-constants
- )
+ add_dependencies(cpp-netlib-http-${test} ${dependencies})
target_link_libraries(cpp-netlib-http-${test}
${Boost_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
- cppnetlib-message
- cppnetlib-message-wrappers
- cppnetlib-http-message
- cppnetlib-http-message-wrappers
- cppnetlib-uri
- cppnetlib-constants
- )
+ ${link_cppnetlib_lib})
set_target_properties(cpp-netlib-http-${test}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-http-${test}
@@ -68,13 +71,10 @@ if (CPP-NETLIB_BUILD_TESTS)
set_source_files_properties(client_test.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
endif()
- add_executable(cpp-netlib-http-client_test client_test.cpp)
- target_link_libraries(cpp-netlib-http-client_test
- ${Boost_LIBRARIES}
- ${GTEST_BOTH_LIBRARIES}
- ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- cppnetlib-constants
+ if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(link_cppnetlib_lib cppnetlib)
+ else()
+ set(link_cppnetlib_lib cppnetlib-constants
cppnetlib-uri
cppnetlib-message
cppnetlib-message-wrappers
@@ -85,6 +85,14 @@ if (CPP-NETLIB_BUILD_TESTS)
cppnetlib-http-client
cppnetlib-http-client-connections
cppnetlib-logging)
+ endif()
+ add_executable(cpp-netlib-http-client_test client_test.cpp)
+ target_link_libraries(cpp-netlib-http-client_test
+ ${Boost_LIBRARIES}
+ ${GTEST_BOTH_LIBRARIES}
+ ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${link_cppnetlib_lib})
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-http-client_test ${OPENSSL_LIBRARIES})
endif()
5 logging/CMakeLists.txt
View
@@ -5,7 +5,7 @@
if( CPP-NETLIB_ALWAYS_LOGGING )
- add_definitions( /D NETWORK_ENABLE_LOGGING )
+ add_definitions( -DNETWORK_ENABLE_LOGGING )
endif()
if( NOT CPP-NETLIB_DISABLE_LOGGING )
@@ -21,3 +21,6 @@ if( NOT CPP-NETLIB_DISABLE_LOGGING )
endif(CPP-NETLIB_BUILD_TESTS)
endif()
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_LOGGING_SRCS ${CPP-NETLIB_LOGGING_SRCS} PARENT_SCOPE)
9 logging/src/CMakeLists.txt
View
@@ -15,8 +15,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
include_directories(${CPP-NETLIB_SOURCE_DIR}/logging/src)
-set(CPP-NETLIB_LOGGING_SRCS logging.cpp)
-add_library(cppnetlib-logging ${CPP-NETLIB_LOGGING_SRCS})
+set(CPP-NETLIB_LOGGING_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/logging.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-logging ${CPP-NETLIB_LOGGING_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_LOGGING_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -26,3 +28,6 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_LOGGING_SRCS ${CPP-NETLIB_LOGGING_SRCS} PARENT_SCOPE)
13 logging/test/CMakeLists.txt
View
@@ -15,15 +15,22 @@ if (CPP-NETLIB_BUILD_TESTS)
logging_log_record
logging_custom_handler
)
+ if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(link_cppnetlib_lib cppnetlib)
+ set(dependency cppnetlib)
+ else()
+ set(link_cppnetlib_lib cppnetlib-logging)
+ set(dependency cppnetlib-logging)
+ endif()
foreach (test ${TESTS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${test}.cpp
- PROPERTIES COMPILE_FLAGS "-Wall")
+ PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-${test} ${test}.cpp)
- add_dependencies(cpp-netlib-${test} cppnetlib-logging)
+ add_dependencies(cpp-netlib-${test} ${dependency})
target_link_libraries(cpp-netlib-${test}
- ${Boost_LIBRARIES} ${GTEST_BOTH_LIBRARIES} cppnetlib-logging)
+ ${Boost_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${link_cppnetlib_lib})
set_target_properties(cpp-netlib-${test}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-${test}
5 message/CMakeLists.txt
View
@@ -9,3 +9,8 @@ if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(CPP-NETLIB_BUILD_TESTS)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_MESSAGE_SRCS ${CPP-NETLIB_MESSAGE_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
27 message/src/CMakeLists.txt
View
@@ -16,10 +16,12 @@ endif()
include_directories(${CPP-NETLIB_SOURCE_DIR}/uri/src ${CPP-NETLIB_SOURCE_DIR}/message/src)
-set(CPP-NETLIB_MESSAGE_SRCS message.cpp)
-add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS})
-add_dependencies(cppnetlib-message cppnetlib-uri)
-target_link_libraries(cppnetlib-message cppnetlib-uri)
+set(CPP-NETLIB_MESSAGE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/message.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-message ${CPP-NETLIB_MESSAGE_SRCS})
+ add_dependencies(cppnetlib-message cppnetlib-uri)
+ target_link_libraries(cppnetlib-message cppnetlib-uri)
+endif()
foreach (src_file ${CPP-NETLIB_MESSAGE_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -30,8 +32,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endforeach(src_file)
-set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS directives.cpp)
-add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS})
+set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/directives.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-message-directives ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -42,8 +46,10 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endforeach(src_file)
-set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS wrappers.cpp)
-add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS})
+set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/wrappers.cpp)
+if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
+ add_library(cppnetlib-message-wrappers ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS})
+endif()
foreach (src_file ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
@@ -53,3 +59,8 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)
+
+# propagate sources to parent directory for one-lib-build
+set(CPP-NETLIB_MESSAGE_SRCS ${CPP-NETLIB_MESSAGE_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS ${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS} PARENT_SCOPE)
+set(CPP-NETLIB_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
21 message/test/CMakeLists.txt
View
@@ -9,16 +9,29 @@ include_directories(${CPP-NETLIB_SOURCE_DIR}/message/src)
if (CPP-NETLIB_BUILD_TESTS)
set(TESTS message_test message_transform_test)
+ if(CPP-NETLIB_BUILD_SINGLE_LIB)
+ set(link_cppnetlib_lib cppnetlib)
+ set(dependencies cppnetlib)
+ else()
+ set(link_cppnetlib_lib cppnetlib-message
+ cppnetlib-message-directives
+ cppnetlib-message-wrappers)
+ set(dependencies cppnetlib-message
+ cppnetlib-message-directives
+ cppnetlib-message-wrappers)
+ endif()
foreach (test ${TESTS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${test}.cpp
- PROPERTIES COMPILE_FLAGS "-Wall")
+ PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-${test} ${test}.cpp)
- add_dependencies(cpp-netlib-${test} cppnetlib-message cppnetlib-message-directives cppnetlib-message-wrappers)
+ add_dependencies(cpp-netlib-${test} ${dependencies})
target_link_libraries(cpp-netlib-${test}
- ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${GTEST_BOTH_LIBRARIES}
- cppnetlib-message cppnetlib-message-directives cppnetlib-message-wrappers)
+ ${Boost_SYSTEM_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${GTEST_BOTH_LIBRARIES}
+ ${link_cppnetlib_lib})
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES})
endif()
2  uri
@@ -1 +1 @@
-Subproject commit e3ed456dbec947765018b1dde9ede787bad91814
+Subproject commit 79565659303a8f16244d6cbd2d695e28cad55cbf
Please sign in to comment.
Something went wrong with that request. Please try again.