Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ if(NOT SWIFT_SYSTEM_NAME)
endif()
endif()

set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)

if(CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Darwin)
Expand Down
7 changes: 4 additions & 3 deletions Sources/BasicContainers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name BasicContainers)
add_library(BasicContainers
${COLLECTIONS_ARRAY_SOURCES})
target_link_libraries(BasicContainers PRIVATE
target_link_libraries(BasicContainers PUBLIC
InternalCollectionsUtilities ContainersPreview)
set_target_properties(BasicContainers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(BasicContainers)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS BasicContainers)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(BasicContainers InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
7 changes: 4 additions & 3 deletions Sources/BitCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name BitCollections)
add_library(BitCollections
${COLLECTIONS_BIT_SOURCES})
target_link_libraries(BitCollections PRIVATE
target_link_libraries(BitCollections PUBLIC
InternalCollectionsUtilities)
set_target_properties(BitCollections PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(BitCollections)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS BitCollections)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(BitCollections InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
16 changes: 13 additions & 3 deletions Sources/Collections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@ See https://swift.org/LICENSE.txt for license information

add_library(Collections
"Collections.swift")
target_link_libraries(Collections PRIVATE
target_link_libraries(Collections PUBLIC
BitCollections
DequeModule
HeapModule
OrderedCollections
HashTreeCollections
_RopeModule
)
set_target_properties(Collections PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(Collections)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS Collections)

# All the .exported targets from Package.swift
swift_module_re_exports(Collections BasicContainers)
swift_module_re_exports(Collections BitCollections)
swift_module_re_exports(Collections ContainersPreview)
swift_module_re_exports(Collections DequeModule)
swift_module_re_exports(Collections HeapModule)
swift_module_re_exports(Collections OrderedCollections)
swift_module_re_exports(Collections TrailingElementsModule)
swift_module_re_exports(Collections _RopeModule)
swift_module_re_exports(Collections HashTreeCollections)
7 changes: 4 additions & 3 deletions Sources/ContainersPreview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name ContainersPreview)
add_library(ContainersPreview
${COLLECTIONS_CONTAINERS_SOURCES})
target_link_libraries(ContainersPreview PRIVATE
target_link_libraries(ContainersPreview PUBLIC
InternalCollectionsUtilities)
set_target_properties(ContainersPreview PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(ContainersPreview)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS ContainersPreview)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(ContainersPreview InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
7 changes: 4 additions & 3 deletions Sources/DequeModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name DequeModule)
add_library(DequeModule
${COLLECTIONS_DEQUE_SOURCES})
target_link_libraries(DequeModule PRIVATE
target_link_libraries(DequeModule PUBLIC
InternalCollectionsUtilities)
set_target_properties(DequeModule PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(DequeModule)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS DequeModule)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(DequeModule InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
7 changes: 4 additions & 3 deletions Sources/HashTreeCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name HashTreeCollections)
add_library(HashTreeCollections
${COLLECTIONS_HASHTREE_SOURCES})
target_link_libraries(HashTreeCollections PRIVATE
target_link_libraries(HashTreeCollections PUBLIC
InternalCollectionsUtilities)
set_target_properties(HashTreeCollections PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(HashTreeCollections)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS HashTreeCollections)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(HashTreeCollections InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
7 changes: 4 additions & 3 deletions Sources/HeapModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name HeapModule)
add_library(HeapModule
${COLLECTIONS_HEAP_SOURCES})
target_link_libraries(HeapModule PRIVATE
target_link_libraries(HeapModule PUBLIC
InternalCollectionsUtilities)
set_target_properties(HeapModule PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(HeapModule)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS HeapModule)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(HeapModule InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
2 changes: 0 additions & 2 deletions Sources/InternalCollectionsUtilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ else()
set(module_name InternalCollectionsUtilities)
add_library(InternalCollectionsUtilities
${COLLECTIONS_UTILITIES_SOURCES})
set_target_properties(InternalCollectionsUtilities PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(InternalCollectionsUtilities)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS InternalCollectionsUtilities)
Expand Down
7 changes: 4 additions & 3 deletions Sources/OrderedCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name OrderedCollections)
add_library(OrderedCollections
${COLLECTIONS_ORDERED_SOURCES})
target_link_libraries(OrderedCollections PRIVATE
target_link_libraries(OrderedCollections PUBLIC
InternalCollectionsUtilities)
set_target_properties(OrderedCollections PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(OrderedCollections)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS OrderedCollections)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(OrderedCollections InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
7 changes: 4 additions & 3 deletions Sources/RopeModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ else()
set(module_name _RopeModule)
add_library(_RopeModule
${COLLECTIONS_ROPE_SOURCES})
target_link_libraries(_RopeModule PRIVATE
target_link_libraries(_RopeModule PUBLIC
InternalCollectionsUtilities)
set_target_properties(_RopeModule PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(_RopeModule)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS _RopeModule)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(_RopeModule InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
5 changes: 3 additions & 2 deletions Sources/TrailingElementsModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ if(COLLECTIONS_SINGLE_MODULE)
else()
set(module_name TrailingElementsModule)
add_library(TrailingElementsModule)
set_target_properties(TrailingElementsModule PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(TrailingElementsModule)
set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS TrailingElementsModule)

# Re-export InternalCollectionsUtilities so dependents can access it
swift_module_re_exports(TrailingElementsModule InternalCollectionsUtilities)
endif()

target_sources(${module_name} PRIVATE
Expand Down
11 changes: 11 additions & 0 deletions cmake/modules/SwiftSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,14 @@ function(_install_target module)
DESTINATION lib/${swift}/${COLLECTIONS_PLATFORM}/${module_name}.swiftmodule
RENAME ${COLLECTIONS_MODULE_TRIPLE}.swiftmodule)
endfunction()

# Makes <exported> importable by any target listing <exporter> in its
# target_link_libraries.
function(swift_module_re_exports exporter exported)
set(swift_module_directory "$<TARGET_PROPERTY:${exported},Swift_MODULE_DIRECTORY>")
set(binary_directory "$<TARGET_PROPERTY:${exported},BINARY_DIR>")
set_property(TARGET ${exporter}
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
"$<IF:$<STREQUAL:${swift_module_directory},>,${binary_directory},${swift_module_directory}>")
endfunction()