Skip to content

enabling cpp-netlib (and uri) to be compiled into a single library #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2013
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ if (CMAKE_PROJECT_NAME STREQUAL "Uri" OR CPP-NETLIB_BUILD_TESTS)
endif()
add_subdirectory(test)
endif()

#propagate sources to parent scope for one-lib-build
set(Uri_SRCS ${Uri_SRCS} PARENT_SCOPE)
28 changes: 18 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(Uri_SRCS uri.cpp uri_io.cpp uri_builder.cpp detail/uri_parse.cpp)
add_library(cppnetlib-uri ${Uri_SRCS})
set(Uri_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/uri.cpp
${CMAKE_CURRENT_SOURCE_DIR}/uri_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/uri_builder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/detail/uri_parse.cpp)
if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
add_library(cppnetlib-uri ${Uri_SRCS})
install(
TARGETS
cppnetlib-uri
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)

install(
TARGETS
cppnetlib-uri
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
install(DIRECTORY network
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
endif()

install(DIRECTORY network
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
#propagate sources to parent scope for one-lib-build
set(Uri_SRCS ${Uri_SRCS} PARENT_SCOPE)
11 changes: 9 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ set(
uri_resolve_test
uri_builder_test
)
if(CPP-NETLIB_BUILD_SINGLE_LIB)
set(link_cppnetlib_lib cppnetlib)
set(dependencies cppnetlib)
else()
set(link_cppnetlib_lib cppnetlib-uri)
set(dependencies cppnetlib-uri)
endif()
foreach (test ${TESTS})
add_executable(${test} ${test}.cpp)
add_dependencies(${test} cppnetlib-uri)
target_link_libraries(${test} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri)
add_dependencies(${test} ${dependencies})
target_link_libraries(${test} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${link_cppnetlib_lib})
if (OPENSSL_FOUND)
target_link_libraries(${test} ${OPENSSL_LIBRARIES})
endif()
Expand Down