Skip to content

Commit e5f4b01

Browse files
committed
build: add exports targets
Now that we can build the Swift content as a library, we can do export targets. This enables us to have CMake determine more information about the target, track dependencies across projects, and manage the flags across the trees without the special variables to specify the source and build trees.
1 parent ec3fd9b commit e5f4b01

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,5 @@ add_subdirectory(src)
276276
if(BUILD_TESTING)
277277
add_subdirectory(tests)
278278
endif()
279+
280+
add_subdirectory(cmake/modules)

cmake/modules/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
set(DISPATCH_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/dispatchExports.cmake)
3+
configure_file(dispatchConfig.cmake.in
4+
${CMAKE_CURRENT_BINARY_DIR}/dispatchConfig.cmake)
5+
6+
get_property(DISPATCH_EXPORTS GLOBAL PROPERTY DISPATCH_EXPORTS)
7+
export(TARGETS ${DISPATCH_EXPORTS} FILE ${DISPATCH_EXPORTS_FILE})

cmake/modules/dispatchConfig.cmake.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
set(DISPATCH_HAS_SWIFT_SDK_OVERLAY @ENABLE_SWIFT@)
3+
4+
if(NOT TARGET dispatch)
5+
include(@DISPATCH_EXPORTS_FILE@)
6+
endif()
7+

src/BlocksRuntime/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ if(INSTALL_PRIVATE_HEADERS)
2828
install(FILES Block_private.h
2929
DESTINATION ${INSTALL_BLOCK_HEADERS_DIR})
3030
endif()
31+
set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS dispatch)
3132
install(TARGETS BlocksRuntime
33+
EXPORT dispatchExports
3234
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
3335
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
3436
RUNTIME DESTINATION bin)

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ if(ENABLE_SWIFT)
159159
add_subdirectory(swift)
160160
endif()
161161

162+
set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS dispatch)
162163
install(TARGETS dispatch
164+
EXPORT dispatchExports
163165
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
164166
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
165167
RUNTIME DESTINATION bin)

src/swift/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ install(FILES
4747
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftdoc
4848
DESTINATION ${INSTALL_TARGET_DIR}/${swift_arch})
4949
install(TARGETS swiftDispatch
50+
EXPORT dispatchExports
5051
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
5152
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
5253
RUNTIME DESTINATION bin)
54+
set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS swiftDispatch)
5355
if(NOT BUILD_SHARED_LIBS)
5456
install(TARGETS DispatchStubs
5557
DESTINATION ${INSTALL_TARGET_DIR})

0 commit comments

Comments
 (0)