Skip to content

Commit e731c22

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 2accb0b commit e731c22

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-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 BlocksRuntime)
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ install(FILES
4646
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule
4747
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftdoc
4848
DESTINATION ${INSTALL_TARGET_DIR}/${swift_arch})
49+
set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS swiftDispatch)
4950
install(TARGETS swiftDispatch
51+
EXPORT dispatchExports
5052
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
5153
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
5254
RUNTIME DESTINATION bin)
5355
if(NOT BUILD_SHARED_LIBS)
56+
set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS DispatchStubs)
5457
install(TARGETS DispatchStubs
58+
EXPORT dispatchExports
5559
DESTINATION ${INSTALL_TARGET_DIR})
5660
endif()

0 commit comments

Comments
 (0)