Skip to content

Commit

Permalink
build: add export targets for the appropriate components
Browse files Browse the repository at this point in the history
Ensure that we export the Foundation libraries, plutil, and uuid for users of
Foundation against the build tree.
  • Loading branch information
compnerd committed Nov 5, 2019
1 parent 5025ecf commit 388e84a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ if(ENABLE_TESTING)
add_subdirectory(TestFoundation)
endif()

add_subdirectory(cmake/modules)

# TODO(compnerd) install as a Framework as that is how swift actually is built
install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/CoreFoundation.framework/Headers/
Expand Down
2 changes: 2 additions & 0 deletions Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ set_target_properties(FoundationXML PROPERTIES
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)

set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
Foundation FoundationNetworking FoundationXML)
get_swift_host_arch(swift_arch)
install(TARGETS Foundation FoundationNetworking FoundationXML
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
Expand Down
1 change: 1 addition & 0 deletions Tools/plutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Dar
"SHELL:-Xlinker -rpath -Xlinker $$$$ORIGIN/../lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>:$<TARGET_FILE_DIR:Foundation>")
endif()

set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)
install(TARGETS plutil
DESTINATION ${CMAKE_INSTALL_BINDIR})
7 changes: 7 additions & 0 deletions cmake/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

set(Foundation_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/FoundationExports.cmake)
configure_file(FoundationConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake)

get_property(Foundation_EXPORTS GLOBAL PROPERTY Foundation_EXPORTS)
export(TARGETS ${Foundation_EXPORTS} FILE ${Foundation_EXPORTS_FILE})
4 changes: 4 additions & 0 deletions cmake/modules/FoundationConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

if(NOT TARGET Foundation)
include(@Foundation_EXPORTS_FILE@)
endif()
4 changes: 4 additions & 0 deletions uuid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
endif()
set_target_properties(uuid PROPERTIES
POSITION_INDEPENDENT_CODE YES)

if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS uuid)
endif()

0 comments on commit 388e84a

Please sign in to comment.