From 46bd2aa4a1b1878581d73acce02584753c67977b Mon Sep 17 00:00:00 2001 From: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> Date: Sun, 24 Apr 2022 09:16:13 +0800 Subject: [PATCH] vcpkg zlib dep fix (#385) * vcpkg zlib dep fix * Use cmake.in file instead of write file directly Co-authored-by: Cheney-Wang --- CMakeLists.txt | 14 +++++++------- ixwebsocket-config.cmake.in | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 ixwebsocket-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e7341bc0..e87173e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,11 +234,7 @@ endif() option(USE_ZLIB "Enable zlib support" TRUE) if (USE_ZLIB) - # This ZLIB_FOUND check is to help find a cmake manually configured zlib - if (NOT ZLIB_FOUND) - find_package(ZLIB REQUIRED) - endif() - target_include_directories(ixwebsocket PUBLIC $) + find_package(ZLIB REQUIRED) target_link_libraries(ixwebsocket PRIVATE ZLIB::ZLIB) target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_ZLIB) @@ -289,10 +285,14 @@ if (IXWEBSOCKET_INSTALL) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ixwebsocket/ ) + configure_file("${CMAKE_CURRENT_LIST_DIR}/ixwebsocket-config.cmake.in" "${CMAKE_BINARY_DIR}/ixwebsocket-config.cmake" @ONLY) + install(FILES "${CMAKE_BINARY_DIR}/ixwebsocket-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ixwebsocket") + install(EXPORT ixwebsocket - FILE ixwebsocket-config.cmake + FILE ixwebsocket-targets.cmake NAMESPACE ixwebsocket:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ixwebsocket) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ixwebsocket + ) endif() if (USE_WS OR USE_TEST) diff --git a/ixwebsocket-config.cmake.in b/ixwebsocket-config.cmake.in new file mode 100644 index 00000000..440edb4a --- /dev/null +++ b/ixwebsocket-config.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +if(@USE_ZLIB@) + find_dependency(ZLIB) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/ixwebsocket-targets.cmake") \ No newline at end of file