Skip to content

Commit

Permalink
More CMakeLists fudging around.
Browse files Browse the repository at this point in the history
  • Loading branch information
deanberris committed Dec 5, 2011
1 parent 9dacc03 commit 2d39520
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 32 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 2.6)
project(CPP-NETLIB)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTI_THREADED ON)
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options)
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options )
find_package( OpenSSL )
find_package( Threads )
set(CMAKE_VERBOSE_MAKEFILE true)
Expand All @@ -16,16 +16,17 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DBOOST_NETWORK_DEBUG)
endif()

if (OpenSSL_FOUND)
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
endif()

if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
enable_testing()
add_subdirectory(libs/network/src)
add_subdirectory(libs/network/test)
add_subdirectory(libs/mime/test)
add_subdirectory(libs/network/example)
endif()

if (OpenSSL_FOUND)
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
endif()

enable_testing()
add_subdirectory(libs/network/src)
add_subdirectory(libs/network/test)
add_subdirectory(libs/mime/test)
add_subdirectory(libs/network/example)
69 changes: 50 additions & 19 deletions libs/network/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,54 @@
include_directories(${CPP-NETLIB_SOURCE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})

if (Boost_FOUND)
add_executable(http_client http_client.cpp)
add_executable(simple_wget simple_wget.cpp)
add_executable(hello_world_server http/hello_world_server.cpp)
add_executable(fileserver http/fileserver.cpp)
add_executable(uri uri.cpp)
add_dependencies(http_client cppnetlib-uri-parsers)
add_dependencies(simple_wget cppnetlib-uri-parsers)
add_dependencies(uri cppnetlib-uri-parsers)
target_link_libraries(http_client ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} cppnetlib-uri-parsers)
target_link_libraries(simple_wget ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} cppnetlib-uri-parsers)
target_link_libraries(hello_world_server ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} )
target_link_libraries(fileserver ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
target_link_libraries(uri cppnetlib-uri-parsers)
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(uri PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
if (OPENSSL_FOUND)
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
endif()

add_executable(http_client http_client.cpp)
add_executable(simple_wget simple_wget.cpp)
add_executable(hello_world_server http/hello_world_server.cpp)
add_executable(fileserver http/fileserver.cpp)
add_executable(uri uri.cpp)
add_dependencies(http_client cppnetlib-uri-parsers)
add_dependencies(simple_wget cppnetlib-uri-parsers)
add_dependencies(uri cppnetlib-uri-parsers)
set(BOOST_CLIENT_LIBS
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY})

set(BOOST_SERVER_LIBS
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY})

target_link_libraries(http_client
${BOOST_CLIENT_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_LIBRARIES}
cppnetlib-uri-parsers)

target_link_libraries(simple_wget
${BOOST_CLIENT_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_LIBRARIES}
cppnetlib-uri-parsers)

target_link_libraries(hello_world_server
${BOOST_SERVER_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_LIBRARIES})

target_link_libraries(fileserver
${BOOST_SERVER_LIBS}
${Boost_FILESYSTEM_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-server-parsers)

target_link_libraries(uri cppnetlib-uri-parsers)
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(uri PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
4 changes: 4 additions & 0 deletions libs/network/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# boost_network_uri
include_directories(${CPP-NETLIB_SOURCE_DIR})

if (OPENSSL_FOUND)
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
endif()

set(CPP-NETLIB_URI_SRCS uri/parse.cpp)
add_library(cppnetlib-uri-parsers ${CPP-NETLIB_URI_SRCS})

Expand Down
12 changes: 8 additions & 4 deletions libs/network/test/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if (OPENSSL_FOUND)
endif()

if (Boost_FOUND)
set ( BOOST_LIBS
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY})
set ( TESTS
client_constructor_test
client_get_test
Expand All @@ -32,7 +36,7 @@ if (Boost_FOUND)
endif()
add_executable(cpp-netlib-http-${test} ${test}.cpp)
add_dependencies(cpp-netlib-http-${test} cppnetlib-uri-parsers)
target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
target_link_libraries(cpp-netlib-http-${test} ${BOOST_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-http-${test} ${OPENSSL_LIBRARIES})
endif()
Expand All @@ -53,7 +57,7 @@ if (Boost_FOUND)
endif()
add_executable(cpp-netlib-http-${test} ${test}.cpp)
add_dependencies(cpp-netlib-http-${test} cppnetlib-server-parsers)
target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
target_link_libraries(cpp-netlib-http-${test} ${BOOST_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
set_target_properties(cpp-netlib-http-${test}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-http-${test}
Expand All @@ -73,7 +77,7 @@ if (Boost_FOUND)
endif()
add_executable(cpp-netlib-http-${test} ${test}.cpp)
add_dependencies(cpp-netlib-http-${test} cppnetlib-server-parsers)
target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
target_link_libraries(cpp-netlib-http-${test} ${BOOST_LIBS} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
set_target_properties(cpp-netlib-http-${test}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CPP-NETLIB_BINARY_DIR}/tests)
Expand All @@ -96,7 +100,7 @@ if (Boost_FOUND)
PROPERTIES COMPILE_FLAGS "-Wall")
endif()
add_executable(cpp-netlib-http-inlined-${test} ${test}.cpp)
target_link_libraries(cpp-netlib-http-inlined-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(cpp-netlib-http-inlined-${test} ${BOOST_LIBS} ${CMAKE_THREAD_LIBS_INIT})
if (OPENSSL_FOUND)
target_link_libraries(cpp-netlib-http-inlined-${test} ${OPENSSL_LIBRARIES})
endif()
Expand Down

0 comments on commit 2d39520

Please sign in to comment.