From c12b88d571df0469a88967375cbe6b2360fbf3a9 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 16 May 2025 10:49:00 -0700 Subject: [PATCH 1/2] build: support static libclosure builds While we are still undecided on the state of libclosure (whether it should be supported as a dynamic-only linked dependency or whether we should support statically linking against the library), tweak the build to support the static builds on Windows. --- src/BlocksRuntime/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/BlocksRuntime/CMakeLists.txt b/src/BlocksRuntime/CMakeLists.txt index fc3d60252..3732b0aec 100644 --- a/src/BlocksRuntime/CMakeLists.txt +++ b/src/BlocksRuntime/CMakeLists.txt @@ -7,8 +7,11 @@ if(WIN32) BlocksRuntime.def) if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(BlocksRuntime PRIVATE + target_compile_definitions(BlocksRuntime PUBLIC BlocksRuntime_STATIC) + target_compile_options(BlocksRuntime PUBLIC + "$<$:SHELL:$<$:-Xclang >-static-libclosure>" + $<$:SHELL:-Xcc -static-libclosure>) endif() endif() From 053f8ad0b81e8d6d3f5613dc2528d5f7517cfee7 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 16 May 2025 10:49:00 -0700 Subject: [PATCH 2/2] build: support static dispatch builds In order to support the MUSL Linux SDK, we need to ensure that we are able to build libdispatch statically. Add support to correctly build the static library on all platforms. --- dispatch/base.h | 2 +- src/CMakeLists.txt | 4 ++++ tests/CMakeLists.txt | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dispatch/base.h b/dispatch/base.h index 8e7728525..00c723b36 100644 --- a/dispatch/base.h +++ b/dispatch/base.h @@ -194,7 +194,7 @@ # endif #else # if defined(_WIN32) -# if defined(dispatch_EXPORT) || defined(__DISPATCH_BUILDING_DISPATCH__) +# if defined(dispatch_EXPORTS) # define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllexport) # else # define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllimport) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index feeaa25e8..b436454e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,6 +92,10 @@ target_include_directories(dispatch PUBLIC target_include_directories(dispatch PRIVATE ${PROJECT_SOURCE_DIR}/private) +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(dispatch PUBLIC + dispatch_STATIC) +endif() if(WIN32) target_compile_definitions(dispatch PRIVATE _CRT_NONSTDC_NO_WARNINGS diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f06162874..0ec603842 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,6 +23,8 @@ add_library(bsdtests STATIC bsdtests.c dispatch_test.c) +target_link_libraries(bsdtests PUBLIC + dispatch) target_include_directories(bsdtests PRIVATE ${CMAKE_CURRENT_BINARY_DIR}