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
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF
option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." 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 @@ -36,8 +38,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 @@ -64,6 +68,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 @@ -32,6 +32,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 ()
install(TARGETS cppnetlib-client-connections
EXPORT cppnetlibTargets
Expand Down