Skip to content

Commit

Permalink
[WIP] depends: upstream patches to fix CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
fanquake committed Mar 25, 2024
1 parent b511971 commit 328da34
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
5 changes: 3 additions & 2 deletions depends/packages/zeromq.mk
Expand Up @@ -3,7 +3,7 @@ $(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
$(package)_build_subdir=build

define $(package)_set_vars
Expand All @@ -16,7 +16,8 @@ define $(package)_set_vars
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
endef

define $(package)_config_cmds
Expand Down
45 changes: 45 additions & 0 deletions depends/patches/zeromq/fix_cmake_build.patch
@@ -0,0 +1,45 @@
Two upstream 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.

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")

0 comments on commit 328da34

Please sign in to comment.