From 5f408ba371ae4789549fb4696dcccd2ac946b7eb Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:15:09 +0100 Subject: [PATCH] Fix CMake-generated `libzmq.pc` file This change mirrors the Autotools-based build system behavior for cross-compiling for Windows with static linking. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36f48769..5ad2cc10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,12 +567,18 @@ if(ZMQ_HAVE_WINDOWS) # Cannot use check_library_exists because the symbol is always declared as char(*)(void) set(CMAKE_REQUIRED_LIBRARIES "ws2_32.lib") check_cxx_symbol_exists(WSAStartup "winsock2.h" HAVE_WS2_32) + if(HAVE_WS2_32) + set(pkg_config_libs_private "${pkg_config_libs_private} -lws2_32") + endif() set(CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib") check_cxx_symbol_exists(UuidCreateSequential "rpc.h" HAVE_RPCRT4) set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib") check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI) + if(HAVE_IPHLAPI) + set(pkg_config_libs_private "${pkg_config_libs_private} -liphlpapi") + endif() check_cxx_symbol_exists(if_nametoindex "iphlpapi.h" HAVE_IF_NAMETOINDEX) set(CMAKE_REQUIRED_LIBRARIES "")