Skip to content

Build: allow options to use Boost + OpenSSL static libs #722

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 1 commit into from
Jan 9, 2017
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
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." ON)
# option( CPP-NETLIB_BUILD_EXPERIMENTS "Build the cpp-netlib project experiments." ON)
option( CPP-NETLIB_BUILD_EXAMPLES "Build the cpp-netlib project examples." ON)
option( CPP-NETLIB_ENABLE_HTTPS "Build cpp-netlib with support for https if OpenSSL is found." ON)
option( CPP-NETLIB_STATIC_OPENSSL "Build cpp-netlib using static OpenSSL" OFF)
option( CPP-NETLIB_STATIC_BOOST "Build cpp-netlib using static Boost" OFF)

include(GNUInstallDirs)

Expand All @@ -37,8 +39,10 @@ else()
set(BUILD_SHARED_LIBS OFF)
endif()

# Always use Boost's shared libraries.
set(Boost_USE_STATIC_LIBS OFF)
# Use Boost's static libraries
if (CPP-NETLIB_STATIC_BOOST)
set(Boost_USE_STATIC_LIBS ON)
endif()

# We need this for all tests to use the dynamic version.
add_definitions(-DBOOST_TEST_DYN_LINK)
Expand All @@ -65,6 +69,9 @@ if (CPP-NETLIB_ENABLE_HTTPS)
endif()
endif()
endif()
if (CPP-NETLIB_STATIC_OPENSSL)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
find_package(OpenSSL)
endif()

Expand Down
5 changes: 5 additions & 0 deletions libs/network/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ set_target_properties(cppnetlib-client-connections
target_link_libraries(cppnetlib-client-connections ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if (OPENSSL_FOUND)
target_link_libraries(cppnetlib-client-connections ${OPENSSL_LIBRARIES})
if (CPP-NETLIB_STATIC_OPENSSL)
if (NOT MSVC AND NOT MINGW AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") # dynlinker functions are built into libc on FreeBSD
target_link_libraries(cppnetlib-client-connections "-ldl")
endif()
endif()
endif ()
if (MINGW)
target_link_libraries(cppnetlib-client-connections ws2_32)
Expand Down