Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depends: build zeromq with CMake #29723

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 14 additions & 12 deletions depends/packages/zeromq.mk
Expand Up @@ -3,32 +3,34 @@ $(package)_version=4.3.5
$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43
$(package)_patches=remove_libstd_link.patch
$(package)_patches=remove_libstd_link.patch fix_cmake_build.patch fix_have_windows_usage.patch
$(package)_build_subdir=build

define $(package)_set_vars
$(package)_config_opts = --without-docs --disable-shared --disable-valgrind
$(package)_config_opts += --disable-perf --disable-curve-keygen --disable-curve --disable-libbsd
$(package)_config_opts += --without-libsodium --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci
$(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov --disable-dependency-tracking
$(package)_config_opts += --disable-Werror --disable-drafts --enable-option-checking
$(package)_config_opts := -DZMQ_BUILD_TESTS=OFF -DWITH_DOCS=OFF -DWITH_LIBSODIUM=OFF
$(package)_config_opts += -DWITH_LIBBSD=OFF -DENABLE_CURVE=OFF -DENABLE_CPACK=OFF
$(package)_config_opts += -DBUILD_SHARED=OFF -DBUILD_TESTS=OFF -DZMQ_BUILD_TESTS=OFF
$(package)_config_opts += -DENABLE_DRAFTS=OFF
$(package)_config_opts_mingw32 += -DZMQ_WIN32_WINNT=0x0601 -DZMQ_HAVE_IPC=OFF
$(package)_config_opts_debug := -DWITH_PERF_TOOL=OFF
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch
patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch && \
patch -p1 < $($(package)_patch_dir)/fix_cmake_build.patch && \
patch -p1 < $($(package)_patch_dir)/fix_have_windows_usage.patch
endef

define $(package)_config_cmds
./autogen.sh && \
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub config && \
$($(package)_autoconf)
$($(package)_cmake) -S .. -B .
endef

define $(package)_build_cmds
$(MAKE) src/libzmq.la
$(MAKE)
endef

define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-includeHEADERS install-pkgconfigDATA
$(MAKE) DESTDIR=$($(package)_staging_dir) install
endef

define $(package)_postprocess_cmds
Expand Down
66 changes: 66 additions & 0 deletions depends/patches/zeromq/fix_cmake_build.patch
@@ -0,0 +1,66 @@
Changes to the CMake build system:

build: fix mkdtemp check on macOS

On macOS, mkdtemp is in unistd.h. Fix the CMake check so that is works.
This was discovered when comparing the output of the Autotools an CMake
build systems.

Upstreamed in https://github.com/zeromq/libzmq/pull/4668.

cmake: don't use builtin sha1 if not using ws

The builtin SHA1 (ZMQ_USE_BUILTIN_SHA1) is only used in the websocket
engine (ws_engine.cpp), so if websockets are disabled, i.e
-DENABLE_DRAFTS=OFF, don't add sha1.c to the sources list.

Upstream in https://github.com/zeromq/libzmq/pull/4670.

Set a sane minimum (3.5), and fix the ordering of the cmake_minimum_required
call.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b62cc1e..e0c5c772 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,7 @@
# CMake build script for ZeroMQ
+cmake_minimum_required(VERSION 3.5)
project(ZeroMQ)

-if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
- cmake_minimum_required(VERSION 3.0.2)
-else()
- cmake_minimum_required(VERSION 2.8.12)
-endif()

include(CheckIncludeFiles)
include(CheckCCompilerFlag)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c124a6a4..200a82e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -605,7 +605,7 @@ if(NOT MSVC)

check_cxx_symbol_exists(fork unistd.h HAVE_FORK)
check_cxx_symbol_exists(gethrtime sys/time.h HAVE_GETHRTIME)
- check_cxx_symbol_exists(mkdtemp stdlib.h HAVE_MKDTEMP)
+ check_cxx_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP)
check_cxx_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
check_cxx_symbol_exists(strnlen string.h HAVE_STRNLEN)
else()

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 200a82e5..6b62cc1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,7 +234,7 @@ if(NOT ZMQ_USE_GNUTLS)
endif()
endif()
endif()
- if(NOT ZMQ_USE_NSS)
+ if(ENABLE_WS AND NOT ZMQ_USE_NSS)
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.c
${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.h)
message(STATUS "Using builtin sha1")
62 changes: 62 additions & 0 deletions depends/patches/zeromq/fix_have_windows_usage.patch
@@ -0,0 +1,62 @@
commit b163fc36a48ecdc87a3ecb4c6bba5f6b8965acaf
Author: Stephan Lachnit <stephanlachnit@debian.org>
Date: Tue Apr 23 16:02:59 2024 +0200

Do not use _MSC_VER if windows

This fixes several instances where _MSC_VER was used to determine whether to use afunix.h or not. For example, MinGW requires the use of afunix.h but does not define _MSC_VER. The correct behavior is checking ZMQ_HAVE_WINDOWS.

Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>

diff --git a/src/ipc_address.hpp b/src/ipc_address.hpp
index 422c2711..87f1245b 100644
--- a/src/ipc_address.hpp
+++ b/src/ipc_address.hpp
@@ -7,7 +7,7 @@

#include <string>

-#if defined _MSC_VER
+#if defined ZMQ_HAVE_WINDOWS
#include <afunix.h>
#else
#include <sys/socket.h>
diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp
index 3f988745..ed2a0645 100644
--- a/src/ipc_connecter.cpp
+++ b/src/ipc_connecter.cpp
@@ -16,7 +16,7 @@
#include "ipc_address.hpp"
#include "session_base.hpp"

-#ifdef _MSC_VER
+#if defined ZMQ_HAVE_WINDOWS
#include <afunix.h>
#else
#include <unistd.h>
diff --git a/src/ipc_listener.cpp b/src/ipc_listener.cpp
index 50126040..5428579b 100644
--- a/src/ipc_listener.cpp
+++ b/src/ipc_listener.cpp
@@ -17,7 +17,7 @@
#include "socket_base.hpp"
#include "address.hpp"

-#ifdef _MSC_VER
+#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_IOTHREAD_POLLER_USE_SELECT
#error On Windows, IPC does not work with POLLER=select, use POLLER=epoll instead, or disable IPC transport
#endif
diff --git a/tests/testutil.cpp b/tests/testutil.cpp
index bdc80283..6f21e8f6 100644
--- a/tests/testutil.cpp
+++ b/tests/testutil.cpp
@@ -7,7 +7,7 @@

#if defined _WIN32
#include "../src/windows.hpp"
-#if defined _MSC_VER
+#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_IPC
#include <direct.h>
#include <afunix.h>