Skip to content

Commit 053f8ad

Browse files
committed
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.
1 parent c12b88d commit 053f8ad

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

dispatch/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
# endif
195195
#else
196196
# if defined(_WIN32)
197-
# if defined(dispatch_EXPORT) || defined(__DISPATCH_BUILDING_DISPATCH__)
197+
# if defined(dispatch_EXPORTS)
198198
# define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllexport)
199199
# else
200200
# define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllimport)

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ target_include_directories(dispatch PUBLIC
9292
target_include_directories(dispatch PRIVATE
9393
${PROJECT_SOURCE_DIR}/private)
9494

95+
if(NOT BUILD_SHARED_LIBS)
96+
target_compile_definitions(dispatch PUBLIC
97+
dispatch_STATIC)
98+
endif()
9599
if(WIN32)
96100
target_compile_definitions(dispatch PRIVATE
97101
_CRT_NONSTDC_NO_WARNINGS

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ add_library(bsdtests
2323
STATIC
2424
bsdtests.c
2525
dispatch_test.c)
26+
target_link_libraries(bsdtests PUBLIC
27+
dispatch)
2628
target_include_directories(bsdtests
2729
PRIVATE
2830
${CMAKE_CURRENT_BINARY_DIR}

0 commit comments

Comments
 (0)