From a4ef843ad9d61a6fcf0057a56fae50f133f25e35 Mon Sep 17 00:00:00 2001 From: merge-script Date: Wed, 28 Aug 2024 12:18:14 +0100 Subject: [PATCH] Merge bitcoin/bitcoin#30508: depends: Fix CMake-generated `libzmq.pc` file 371910a7682ecdaf86b3e65753667746add1ecd2 depends: Fix CMake-generated `libzmq.pc` file (Hennadii Stepanov) Pull request description: This is a backport of: https://github.com/zeromq/libzmq/pull/4706. Similar to https://github.com/bitcoin/bitcoin/pull/30488. Addresses https://github.com/bitcoin/bitcoin/pull/29723#issuecomment-2239864170: > Looking at the mingw .pc generated by this PR: > > ``` > Libs: -L${libdir} -lzmq > Libs.private: > Requires.private: > ``` > > It looks like we'll need to take [zeromq/libzmq#4706](https://github.com/zeromq/libzmq/pull/4706) as well for CMake. That can be done as a follow-up though, as it's not yet merged upstream. ACKs for top commit: fanquake: ACK 371910a7682ecdaf86b3e65753667746add1ecd2 Tree-SHA512: 6f9c2e32f83c0e629e32fd3e4c86712af00ffeaf0906bf85e5c2df889302707b9df102e8031249d1bae036eb4fc019c2a5124655682fbc5652d9337cb21c5f2c --- depends/packages/zeromq.mk | 4 ++- depends/patches/zeromq/fix_mingw_link.patch | 31 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 depends/patches/zeromq/fix_mingw_link.patch diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 7f44f1980ea21..1f05cd051b0a1 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -10,6 +10,7 @@ $(package)_patches += builtin_sha1.patch $(package)_patches += fix_have_windows.patch $(package)_patches += cmake_minimum.patch $(package)_patches += no_librt.patch +$(package)_patches += fix_mingw_link.patch define $(package)_set_vars $(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DWITH_DOCS=OFF -DWITH_LIBSODIUM=OFF @@ -27,7 +28,8 @@ define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/builtin_sha1.patch && \ patch -p1 < $($(package)_patch_dir)/fix_have_windows.patch && \ patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch && \ - patch -p1 < $($(package)_patch_dir)/no_librt.patch + patch -p1 < $($(package)_patch_dir)/no_librt.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_mingw_link.patch endef define $(package)_config_cmds diff --git a/depends/patches/zeromq/fix_mingw_link.patch b/depends/patches/zeromq/fix_mingw_link.patch new file mode 100644 index 0000000000000..1434557dc72cd --- /dev/null +++ b/depends/patches/zeromq/fix_mingw_link.patch @@ -0,0 +1,31 @@ +Fix CMake-generated `libzmq.pc` file + +This change mirrors the Autotools-based build system behavior for +cross-compiling for Windows with static linking. + +See https://github.com/zeromq/libzmq/pull/4706. + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 03462271..0315e606 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -546,12 +546,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 "")