Skip to content

Commit c69ba20

Browse files
committed
Merge bitcoin/bitcoin#29723: depends: build zeromq with CMake
0388ad0 depends: switch zmq to CMake (Cory Fields) fefb3bb depends: add zeromq no librt patch (fanquake) a522ef1 depends: add zeromq cmake minimum patch (fanquake) cbbc229 depends: add zeromq windows usage patch (fanquake) 2de68d6 depends: add zeromq builtin sha1 patch (fanquake) 0c86052 depends: add zeromq mktemp macos patch (fanquake) Pull request description: This picks up a change, which is a switch to building zeromq with CMake. It includes a number of patches, some which have already been upstreamed (see each patch for details). ACKs for top commit: hebasto: ACK 0388ad0. Tree-SHA512: 5567e432b4e4e0446c41d502bd61810a80b329dea2399b5d9d9f6e79acc450d1c6ba861c8238ba895de98338cfc5dc44ad2bf86ee8c222ecb3fbf47d6eb60da4
2 parents 98537a0 + 0388ad0 commit c69ba20

File tree

6 files changed

+181
-12
lines changed

6 files changed

+181
-12
lines changed

depends/packages/zeromq.mk

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,42 @@ $(package)_version=4.3.5
33
$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/
44
$(package)_file_name=$(package)-$($(package)_version).tar.gz
55
$(package)_sha256_hash=6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43
6-
$(package)_patches=remove_libstd_link.patch
6+
$(package)_build_subdir=build
7+
$(package)_patches = remove_libstd_link.patch
8+
$(package)_patches += macos_mktemp_check.patch
9+
$(package)_patches += builtin_sha1.patch
10+
$(package)_patches += fix_have_windows.patch
11+
$(package)_patches += cmake_minimum.patch
12+
$(package)_patches += no_librt.patch
713

814
define $(package)_set_vars
9-
$(package)_config_opts = --without-docs --disable-shared --disable-valgrind
10-
$(package)_config_opts += --disable-perf --disable-curve-keygen --disable-curve --disable-libbsd
11-
$(package)_config_opts += --without-libsodium --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci
12-
$(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov --disable-dependency-tracking
13-
$(package)_config_opts += --disable-Werror --disable-drafts --enable-option-checking
15+
$(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DWITH_DOCS=OFF -DWITH_LIBSODIUM=OFF
16+
$(package)_config_opts += -DWITH_LIBBSD=OFF -DENABLE_CURVE=OFF -DENABLE_CPACK=OFF
17+
$(package)_config_opts += -DBUILD_SHARED=OFF -DBUILD_TESTS=OFF -DZMQ_BUILD_TESTS=OFF
18+
$(package)_config_opts += -DENABLE_DRAFTS=OFF -DZMQ_BUILD_TESTS=OFF
19+
$(package)_cxxflags += -ffile-prefix-map=$($(package)_extract_dir)=/usr
20+
$(package)_config_opts_mingw32 += -DZMQ_WIN32_WINNT=0x0601 -DZMQ_HAVE_IPC=OFF
1421
endef
1522

1623
define $(package)_preprocess_cmds
17-
patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch
24+
patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch && \
25+
patch -p1 < $($(package)_patch_dir)/macos_mktemp_check.patch && \
26+
patch -p1 < $($(package)_patch_dir)/builtin_sha1.patch && \
27+
patch -p1 < $($(package)_patch_dir)/fix_have_windows.patch && \
28+
patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch && \
29+
patch -p1 < $($(package)_patch_dir)/no_librt.patch
1830
endef
1931

2032
define $(package)_config_cmds
21-
./autogen.sh && \
22-
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub config && \
23-
$($(package)_autoconf)
33+
$($(package)_cmake) -S .. -B .
2434
endef
2535

2636
define $(package)_build_cmds
27-
$(MAKE) src/libzmq.la
37+
$(MAKE)
2838
endef
2939

3040
define $(package)_stage_cmds
31-
$(MAKE) DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-includeHEADERS install-pkgconfigDATA
41+
$(MAKE) DESTDIR=$($(package)_staging_dir) install
3242
endef
3343

3444
define $(package)_postprocess_cmds
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Don't use builtin sha1 if not using ws
2+
3+
The builtin SHA1 (ZMQ_USE_BUILTIN_SHA1) is only used in the websocket
4+
engine (ws_engine.cpp).
5+
Upstreamed in https://github.com/zeromq/libzmq/pull/4670.
6+
7+
--- a/CMakeLists.txt
8+
+++ b/CMakeLists.txt
9+
@@ -234,7 +234,7 @@ if(NOT ZMQ_USE_GNUTLS)
10+
endif()
11+
endif()
12+
endif()
13+
- if(NOT ZMQ_USE_NSS)
14+
+ if(ENABLE_WS AND NOT ZMQ_USE_NSS)
15+
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.c
16+
${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.h)
17+
message(STATUS "Using builtin sha1")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Set a more sane cmake_minimum_required.
2+
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -1,12 +1,7 @@
6+
# CMake build script for ZeroMQ
7+
+cmake_minimum_required(VERSION 3.16)
8+
project(ZeroMQ)
9+
10+
-if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
11+
- cmake_minimum_required(VERSION 3.0.2)
12+
-else()
13+
- cmake_minimum_required(VERSION 2.8.12)
14+
-endif()
15+
-
16+
include(CheckIncludeFiles)
17+
include(CheckCCompilerFlag)
18+
include(CheckCXXCompilerFlag)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
This fixes several instances where _MSC_VER was
2+
used to determine whether to use afunix.h or not.
3+
4+
See https://github.com/zeromq/libzmq/pull/4678.
5+
--- a/src/ipc_address.hpp
6+
+++ b/src/ipc_address.hpp
7+
@@ -7,7 +7,7 @@
8+
9+
#include <string>
10+
11+
-#if defined _MSC_VER
12+
+#if defined ZMQ_HAVE_WINDOWS
13+
#include <afunix.h>
14+
#else
15+
#include <sys/socket.h>
16+
diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp
17+
index 3f988745..ed2a0645 100644
18+
--- a/src/ipc_connecter.cpp
19+
+++ b/src/ipc_connecter.cpp
20+
@@ -16,7 +16,7 @@
21+
#include "ipc_address.hpp"
22+
#include "session_base.hpp"
23+
24+
-#ifdef _MSC_VER
25+
+#if defined ZMQ_HAVE_WINDOWS
26+
#include <afunix.h>
27+
#else
28+
#include <unistd.h>
29+
diff --git a/src/ipc_listener.cpp b/src/ipc_listener.cpp
30+
index 50126040..5428579b 100644
31+
--- a/src/ipc_listener.cpp
32+
+++ b/src/ipc_listener.cpp
33+
@@ -17,7 +17,7 @@
34+
#include "socket_base.hpp"
35+
#include "address.hpp"
36+
37+
-#ifdef _MSC_VER
38+
+#ifdef ZMQ_HAVE_WINDOWS
39+
#ifdef ZMQ_IOTHREAD_POLLER_USE_SELECT
40+
#error On Windows, IPC does not work with POLLER=select, use POLLER=epoll instead, or disable IPC transport
41+
#endif
42+
diff --git a/tests/testutil.cpp b/tests/testutil.cpp
43+
index bdc80283..6f21e8f6 100644
44+
--- a/tests/testutil.cpp
45+
+++ b/tests/testutil.cpp
46+
@@ -7,7 +7,7 @@
47+
48+
#if defined _WIN32
49+
#include "../src/windows.hpp"
50+
-#if defined _MSC_VER
51+
+#if defined ZMQ_HAVE_WINDOWS
52+
#if defined ZMQ_HAVE_IPC
53+
#include <direct.h>
54+
#include <afunix.h>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
build: fix mkdtemp check on macOS
2+
3+
On macOS, mkdtemp is in unistd.h. Fix the CMake check so that is works.
4+
Upstreamed in https://github.com/zeromq/libzmq/pull/4668.
5+
6+
--- a/CMakeLists.txt
7+
+++ b/CMakeLists.txt
8+
@@ -599,7 +599,7 @@ if(NOT MSVC)
9+
10+
check_cxx_symbol_exists(fork unistd.h HAVE_FORK)
11+
check_cxx_symbol_exists(gethrtime sys/time.h HAVE_GETHRTIME)
12+
- check_cxx_symbol_exists(mkdtemp stdlib.h HAVE_MKDTEMP)
13+
+ check_cxx_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP)
14+
check_cxx_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
15+
check_cxx_symbol_exists(strnlen string.h HAVE_STRNLEN)
16+
else()

depends/patches/zeromq/no_librt.patch

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
We don't use librt, so don't try and link against it.
2+
3+
Related to: https://github.com/zeromq/libzmq/pull/4702.
4+
5+
diff --git a/CMakeLists.txt b/CMakeLists.txt
6+
index 03462271..87ceab3c 100644
7+
--- a/CMakeLists.txt
8+
+++ b/CMakeLists.txt
9+
@@ -564,13 +564,6 @@ else()
10+
check_cxx_symbol_exists(SO_BUSY_POLL sys/socket.h ZMQ_HAVE_BUSY_POLL)
11+
endif()
12+
13+
-if(NOT MINGW)
14+
- find_library(RT_LIBRARY rt)
15+
- if(RT_LIBRARY)
16+
- set(pkg_config_libs_private "${pkg_config_libs_private} -lrt")
17+
- endif()
18+
-endif()
19+
-
20+
find_package(Threads)
21+
22+
if(WIN32 AND NOT CYGWIN)
23+
@@ -588,9 +581,7 @@ if(WIN32 AND NOT CYGWIN)
24+
endif()
25+
26+
if(NOT MSVC)
27+
- set(CMAKE_REQUIRED_LIBRARIES rt)
28+
check_cxx_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
29+
- set(CMAKE_REQUIRED_LIBRARIES)
30+
31+
check_cxx_symbol_exists(fork unistd.h HAVE_FORK)
32+
check_cxx_symbol_exists(gethrtime sys/time.h HAVE_GETHRTIME)
33+
@@ -1503,10 +1494,6 @@ if(BUILD_SHARED)
34+
target_link_libraries(libzmq iphlpapi)
35+
endif()
36+
37+
- if(RT_LIBRARY)
38+
- target_link_libraries(libzmq -lrt)
39+
- endif()
40+
-
41+
if(norm_FOUND)
42+
target_link_libraries(libzmq norm::norm)
43+
endif()
44+
@@ -1553,10 +1540,6 @@ if(BUILD_STATIC)
45+
target_link_libraries(libzmq-static iphlpapi)
46+
endif()
47+
48+
- if(RT_LIBRARY)
49+
- target_link_libraries(libzmq-static -lrt)
50+
- endif()
51+
-
52+
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
53+
add_definitions(-DUNITY_EXCLUDE_MATH_H)
54+
endif()

0 commit comments

Comments
 (0)