From 9e54fd5f1a308ab3818034372c3fc882bad0c40a Mon Sep 17 00:00:00 2001 From: ebenali <54529923+ebenali@users.noreply.github.com> Date: Sat, 2 May 2020 22:08:58 -0700 Subject: [PATCH] Fix CMake/zlibstatic-related regression (#192) * cmake: add export() and install(EXPORT) for easier packageability Enable the package to be more readily packageable as a system-wide install or as a third-party dependency to another CMake-base project This does not change CMake version requirements AFAICT * CMake: link-in OpenSSL::Crypto * CMake: explicitly manage dependencies. Fixes building with zlibstatic --- CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e410db70..62334aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,16 +175,16 @@ if (USE_TLS) endif() message(STATUS "OpenSSL: " ${OPENSSL_VERSION}) - target_link_libraries(ixwebsocket OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(ixwebsocket PUBLIC OpenSSL::SSL OpenSSL::Crypto) elseif (USE_MBED_TLS) message(STATUS "TLS configured to use mbedtls") find_package(MbedTLS REQUIRED) target_include_directories(ixwebsocket PUBLIC ${MBEDTLS_INCLUDE_DIRS}) - target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES}) + target_link_libraries(ixwebsocket PUBLIC ${MBEDTLS_LIBRARIES}) elseif (USE_SECURE_TRANSPORT) message(STATUS "TLS configured to use secure transport") - target_link_libraries(ixwebsocket "-framework foundation" "-framework security") + target_link_libraries(ixwebsocket PUBLIC "-framework foundation" "-framework security") endif() endif() @@ -194,25 +194,25 @@ if (NOT ZLIB_FOUND) endif() if (ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIRS}) - target_link_libraries(ixwebsocket ${ZLIB_LIBRARIES}) + target_link_libraries(ixwebsocket PUBLIC ${ZLIB_LIBRARIES}) else() include_directories(third_party/zlib ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib) - add_subdirectory(third_party/zlib) - target_link_libraries(ixwebsocket zlibstatic) + add_subdirectory(third_party/zlib EXCLUDE_FROM_ALL) + target_link_libraries(ixwebsocket PRIVATE $) endif() if (WIN32) - target_link_libraries(ixwebsocket wsock32 ws2_32 shlwapi) + target_link_libraries(ixwebsocket PUBLIC wsock32 ws2_32 shlwapi) add_definitions(-D_CRT_SECURE_NO_WARNINGS) if (USE_TLS) - target_link_libraries(ixwebsocket Crypt32) + target_link_libraries(ixwebsocket PUBLIC Crypt32) endif() endif() if (UNIX) find_package(Threads) - target_link_libraries(ixwebsocket ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(ixwebsocket PUBLIC ${CMAKE_THREAD_LIBS_INIT}) endif()