Skip to content

Commit 98f8021

Browse files
committed
build: honour BUILD_SHARED_LIBS
This is needed for proper shared linkage to the BlocksRuntime (e.g. when building SourceKit). We now build BlocksRuntime shared or static as requested.
1 parent 6162a1d commit 98f8021

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,19 @@ endif()
132132

133133
option(INSTALL_PRIVATE_HEADERS "installs private headers in the same location as the public ones" OFF)
134134

135-
find_package(BlocksRuntime QUIET)
136-
if(NOT BlocksRuntime_FOUND)
135+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
137136
set(BlocksRuntime_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/BlocksRuntime)
138137

139138
add_library(BlocksRuntime
140-
STATIC
141-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/data.c
142-
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/runtime.c)
139+
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/data.c
140+
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/runtime.c)
143141
set_target_properties(BlocksRuntime
144142
PROPERTIES
145143
POSITION_INDEPENDENT_CODE TRUE)
146144
if(HAVE_OBJC AND CMAKE_DL_LIBS)
147-
set_target_properties(BlocksRuntime
148-
PROPERTIES
149-
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
145+
target_link_libraries(BlocksRuntime
146+
PUBLIC
147+
${CMAKE_DL_LIBS})
150148
endif()
151149

152150
add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
@@ -161,6 +159,10 @@ if(NOT BlocksRuntime_FOUND)
161159
DESTINATION
162160
"${INSTALL_BLOCK_HEADERS_DIR}")
163161
endif()
162+
install(TARGETS
163+
BlocksRuntime
164+
DESTINATION
165+
${INSTALL_TARGET_DIR})
164166
endif()
165167

166168
check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)

dispatch/generic/module.modulemap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Dispatch {
22
requires blocks
33
export *
44
link "dispatch"
5+
link "BlocksRuntime"
56
}
67

78
module DispatchIntrospection [system] [extern_c] {

0 commit comments

Comments
 (0)