Skip to content

Commit 62e1d61

Browse files
committed
build: add export targets for the appropriate components
Ensure that we export the Foundation libraries, plutil, and uuid for users of Foundation against the build tree.
1 parent 54e9adc commit 62e1d61

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ if(ENABLE_TESTING)
5555
add_subdirectory(TestFoundation)
5656
endif()
5757

58+
add_subdirectory(cmake/modules)
59+
5860
# TODO(compnerd) install as a Framework as that is how swift actually is built
5961
install(DIRECTORY
6062
${CMAKE_CURRENT_BINARY_DIR}/CoreFoundation.framework/Headers/

Foundation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ set_target_properties(FoundationXML PROPERTIES
239239
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
240240
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
241241

242+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
243+
Foundation FoundationNetworking FoundationXML)
242244
get_swift_host_arch(swift_arch)
243245
install(TARGETS Foundation FoundationNetworking FoundationXML
244246
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

Tools/plutil/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ add_executable(plutil
44
target_link_libraries(plutil PRIVATE
55
Foundation)
66

7+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)
78
install(TARGETS plutil
89
DESTINATION ${CMAKE_INSTALL_BINDIR})

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(Foundation_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/FoundationExports.cmake)
3+
configure_file(FoundationConfig.cmake.in
4+
${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake)
5+
6+
get_property(Foundation_EXPORTS GLOBAL PROPERTY Foundation_EXPORTS)
7+
export(TARGETS ${Foundation_EXPORTS} FILE ${Foundation_EXPORTS_FILE})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
if(NOT TARGET Foundation)
3+
include(@Foundation_EXPORTS_FILE@)
4+
endif()

uuid/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
2020
endif()
2121
set_target_properties(uuid PROPERTIES
2222
POSITION_INDEPENDENT_CODE YES)
23+
24+
if(NOT BUILD_SHARED_LIBS)
25+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS uuid)
26+
endif()

0 commit comments

Comments
 (0)