diff --git a/Sources/BitCollections/CMakeLists.txt b/Sources/BitCollections/CMakeLists.txt index b287e5b2..c5becdee 100644 --- a/Sources/BitCollections/CMakeLists.txt +++ b/Sources/BitCollections/CMakeLists.txt @@ -7,7 +7,22 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_BIT_SOURCES +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name BitCollections) + add_library(BitCollections + ${COLLECTIONS_BIT_SOURCES}) + target_link_libraries(BitCollections PRIVATE + 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) +endif() + +target_sources(${module_name} PRIVATE "BitArray/BitArray+BitwiseOperations.swift" "BitArray/BitArray+ChunkedBitsIterators.swift" "BitArray/BitArray+Codable.swift" @@ -65,16 +80,3 @@ list(APPEND COLLECTIONS_BIT_SOURCES "Shared/UInt+Tricks.swift" "Shared/_Word.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_BIT_SOURCES ${COLLECTIONS_BIT_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - add_library(BitCollections - ${COLLECTIONS_BIT_SOURCES}) - target_link_libraries(BitCollections PRIVATE - 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) -endif() diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 29525bf5..1bd45045 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -7,6 +7,54 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] +if(COLLECTIONS_SINGLE_MODULE) + if (COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) + set(COLLECTIONS_MODULE_NAME _FoundationCollections) + set(COLLECTIONS_MODULE_TYPE STATIC) + else() + set(COLLECTIONS_MODULE_NAME Collections) + set(COLLECTIONS_MODULE_TYPE) + endif() + + add_library(${COLLECTIONS_MODULE_NAME} ${COLLECTIONS_MODULE_TYPE}) + + if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) + target_compile_options(${COLLECTIONS_MODULE_NAME} PRIVATE + "SHELL:$<$:-Xfrontend -allowable-client -Xfrontend FoundationEssentials>") + endif() + + target_compile_definitions(${COLLECTIONS_MODULE_NAME} PRIVATE COLLECTIONS_SINGLE_MODULE) + set_target_properties(${COLLECTIONS_MODULE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) + + if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) + get_swift_host_os(swift_os) + if(BUILD_SHARED_LIBS) + # Install only the swift module and not the library + set(swift swift) + else() + # Install both the swift module and the binary + set(swift swift_static) + install(TARGETS ${COLLECTIONS_MODULE_NAME} + ARCHIVE DESTINATION lib/swift_static/${swift_os} + LIBRARY DESTINATION lib/swift_static/${swift_os} + RUNTIME DESTINATION bin) + endif() + get_swift_host_arch(swift_arch) + install(FILES $/${COLLECTIONS_MODULE_NAME}.swiftdoc + DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule + RENAME ${swift_arch}.swiftdoc) + install(FILES $/${COLLECTIONS_MODULE_NAME}.swiftmodule + DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule + RENAME ${swift_arch}.swiftmodule) + else() + _install_target(${COLLECTIONS_MODULE_NAME}) + endif() + set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS ${COLLECTIONS_MODULE_NAME}) +else() + add_subdirectory(Collections) +endif() + add_subdirectory(BitCollections) add_subdirectory(DequeModule) add_subdirectory(HashTreeCollections) @@ -14,6 +62,3 @@ add_subdirectory(HeapModule) add_subdirectory(OrderedCollections) add_subdirectory(RopeModule) add_subdirectory(InternalCollectionsUtilities) - -# Add Collections last so it can find global properties set by sub directories -add_subdirectory(Collections) diff --git a/Sources/Collections/CMakeLists.txt b/Sources/Collections/CMakeLists.txt index 745b80c4..9f534a46 100644 --- a/Sources/Collections/CMakeLists.txt +++ b/Sources/Collections/CMakeLists.txt @@ -7,87 +7,17 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -if(COLLECTIONS_SINGLE_MODULE) - if (COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) - set(COLLECTIONS_MODULE_NAME _FoundationCollections) - set(COLLECTIONS_MODULE_TYPE STATIC) - else() - set(COLLECTIONS_MODULE_NAME Collections) - set(COLLECTIONS_MODULE_TYPE) - endif() - - get_property(COLLECTIONS_UTILITIES_SOURCES GLOBAL PROPERTY COLLECTIONS_UTILITIES_SOURCES) - list(TRANSFORM COLLECTIONS_UTILITIES_SOURCES PREPEND "../InternalCollectionsUtilities/") - get_property(COLLECTIONS_BIT_SOURCES GLOBAL PROPERTY COLLECTIONS_BIT_SOURCES) - list(TRANSFORM COLLECTIONS_BIT_SOURCES PREPEND "../BitCollections/") - get_property(COLLECTIONS_DEQUE_SOURCES GLOBAL PROPERTY COLLECTIONS_DEQUE_SOURCES) - list(TRANSFORM COLLECTIONS_DEQUE_SOURCES PREPEND "../DequeModule/") - get_property(COLLECTIONS_HEAP_SOURCES GLOBAL PROPERTY COLLECTIONS_HEAP_SOURCES) - list(TRANSFORM COLLECTIONS_HEAP_SOURCES PREPEND "../HeapModule/") - get_property(COLLECTIONS_ORDERED_SOURCES GLOBAL PROPERTY COLLECTIONS_ORDERED_SOURCES) - list(TRANSFORM COLLECTIONS_ORDERED_SOURCES PREPEND "../OrderedCollections/") - get_property(COLLECTIONS_HASHTREE_SOURCES GLOBAL PROPERTY COLLECTIONS_HASHTREE_SOURCES) - list(TRANSFORM COLLECTIONS_HASHTREE_SOURCES PREPEND "../HashTreeCollections/") - - add_library(${COLLECTIONS_MODULE_NAME} ${COLLECTIONS_MODULE_TYPE} - "Collections.swift" - ${COLLECTIONS_UTILITIES_SOURCES} - ${COLLECTIONS_BIT_SOURCES} - ${COLLECTIONS_DEQUE_SOURCES} - ${COLLECTIONS_HEAP_SOURCES} - ${COLLECTIONS_ORDERED_SOURCES} - ${COLLECTIONS_HASHTREE_SOURCES}) - - if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) - get_property(COLLECTIONS_ROPE_SOURCES GLOBAL PROPERTY COLLECTIONS_ROPE_SOURCES) - list(TRANSFORM COLLECTIONS_ROPE_SOURCES PREPEND "../RopeModule/") - target_sources(${COLLECTIONS_MODULE_NAME} PRIVATE - ${COLLECTIONS_ROPE_SOURCES}) - target_compile_options(${COLLECTIONS_MODULE_NAME} PRIVATE - "SHELL:$<$:-Xfrontend -allowable-client -Xfrontend FoundationEssentials>") - endif() - - target_compile_definitions(${COLLECTIONS_MODULE_NAME} PRIVATE COLLECTIONS_SINGLE_MODULE) - set_target_properties(${COLLECTIONS_MODULE_NAME} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - - if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) - get_swift_host_os(swift_os) - if(BUILD_SHARED_LIBS) - # Install only the swift module and not the library - set(swift swift) - else() - # Install both the swift module and the binary - set(swift swift_static) - install(TARGETS ${COLLECTIONS_MODULE_NAME} - ARCHIVE DESTINATION lib/swift_static/${swift_os} - LIBRARY DESTINATION lib/swift_static/${swift_os} - RUNTIME DESTINATION bin) - endif() - get_swift_host_arch(swift_arch) - install(FILES $/${COLLECTIONS_MODULE_NAME}.swiftdoc - DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule - RENAME ${swift_arch}.swiftdoc) - install(FILES $/${COLLECTIONS_MODULE_NAME}.swiftmodule - DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule - RENAME ${swift_arch}.swiftmodule) - else() - _install_target(${COLLECTIONS_MODULE_NAME}) - endif() - set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS ${COLLECTIONS_MODULE_NAME}) -else() - add_library(Collections +add_library(Collections "Collections.swift") - target_link_libraries(Collections PRIVATE - BitCollections - DequeModule - HeapModule - OrderedCollections - HashTreeCollections - ) - set_target_properties(Collections PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) +target_link_libraries(Collections PRIVATE + BitCollections + DequeModule + HeapModule + OrderedCollections + HashTreeCollections + ) +set_target_properties(Collections PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - _install_target(Collections) - set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS Collections) -endif() +_install_target(Collections) +set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS Collections) diff --git a/Sources/DequeModule/CMakeLists.txt b/Sources/DequeModule/CMakeLists.txt index 69f32e4d..07364b66 100644 --- a/Sources/DequeModule/CMakeLists.txt +++ b/Sources/DequeModule/CMakeLists.txt @@ -7,7 +7,22 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_DEQUE_SOURCES +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name DequeModule) + add_library(DequeModule + ${COLLECTIONS_DEQUE_SOURCES}) + target_link_libraries(DequeModule PRIVATE + 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) +endif() + +target_sources(${module_name} PRIVATE "Deque+Codable.swift" "Deque+Collection.swift" "Deque+CustomReflectable.swift" @@ -26,16 +41,3 @@ list(APPEND COLLECTIONS_DEQUE_SOURCES "_DequeSlot.swift" "_UnsafeWrappedBuffer.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_DEQUE_SOURCES ${COLLECTIONS_DEQUE_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - add_library(DequeModule - ${COLLECTIONS_DEQUE_SOURCES}) - target_link_libraries(DequeModule PRIVATE - 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) -endif() diff --git a/Sources/HashTreeCollections/CMakeLists.txt b/Sources/HashTreeCollections/CMakeLists.txt index ead04f08..0329fe66 100644 --- a/Sources/HashTreeCollections/CMakeLists.txt +++ b/Sources/HashTreeCollections/CMakeLists.txt @@ -7,7 +7,22 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_HASHTREE_SOURCES +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name HashTreeCollections) + add_library(HashTreeCollections + ${COLLECTIONS_HASHTREE_SOURCES}) + target_link_libraries(HashTreeCollections PRIVATE + 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) +endif() + +target_sources(${module_name} PRIVATE "HashNode/_AncestorHashSlots.swift" "HashNode/_Bitmap.swift" "HashNode/_Bucket.swift" @@ -94,16 +109,3 @@ list(APPEND COLLECTIONS_HASHTREE_SOURCES "TreeSet/TreeSet+SetAlgebra union.swift" "TreeSet/TreeSet.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_HASHTREE_SOURCES ${COLLECTIONS_HASHTREE_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - add_library(HashTreeCollections - ${COLLECTIONS_HASHTREE_SOURCES}) - target_link_libraries(HashTreeCollections PRIVATE - 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) -endif() diff --git a/Sources/HeapModule/CMakeLists.txt b/Sources/HeapModule/CMakeLists.txt index d24faae2..a1cc57a6 100644 --- a/Sources/HeapModule/CMakeLists.txt +++ b/Sources/HeapModule/CMakeLists.txt @@ -7,16 +7,10 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_HEAP_SOURCES - "_HeapNode.swift" - "Heap.swift" - "Heap+Descriptions.swift" - "Heap+ExpressibleByArrayLiteral.swift" - "Heap+Invariants.swift" - "Heap+UnsafeHandle.swift") -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_HEAP_SOURCES ${COLLECTIONS_HEAP_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name HeapModule) add_library(HeapModule ${COLLECTIONS_HEAP_SOURCES}) target_link_libraries(HeapModule PRIVATE @@ -27,3 +21,11 @@ if(NOT COLLECTIONS_SINGLE_MODULE) _install_target(HeapModule) set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS HeapModule) endif() + +target_sources(${module_name} PRIVATE + "_HeapNode.swift" + "Heap.swift" + "Heap+Descriptions.swift" + "Heap+ExpressibleByArrayLiteral.swift" + "Heap+Invariants.swift" + "Heap+UnsafeHandle.swift") diff --git a/Sources/InternalCollectionsUtilities/CMakeLists.txt b/Sources/InternalCollectionsUtilities/CMakeLists.txt index e0941f8b..808e36c2 100644 --- a/Sources/InternalCollectionsUtilities/CMakeLists.txt +++ b/Sources/InternalCollectionsUtilities/CMakeLists.txt @@ -7,7 +7,20 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_UTILITIES_SOURCES +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +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) +endif() + +target_sources(${module_name} PRIVATE "autogenerated/Debugging.swift" "autogenerated/Descriptions.swift" "autogenerated/RandomAccessCollection+Offsets.swift" @@ -27,14 +40,3 @@ list(APPEND COLLECTIONS_UTILITIES_SOURCES "_SortedCollection.swift" "_UniqueCollection.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_UTILITIES_SOURCES ${COLLECTIONS_UTILITIES_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - 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) -endif() diff --git a/Sources/OrderedCollections/CMakeLists.txt b/Sources/OrderedCollections/CMakeLists.txt index 333c7e0a..01711386 100644 --- a/Sources/OrderedCollections/CMakeLists.txt +++ b/Sources/OrderedCollections/CMakeLists.txt @@ -7,7 +7,22 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_ORDERED_SOURCES +if(COLLECTIONS_SINGLE_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name OrderedCollections) + add_library(OrderedCollections + ${COLLECTIONS_ORDERED_SOURCES}) + target_link_libraries(OrderedCollections PRIVATE + 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) +endif() + +target_sources(${module_name} PRIVATE "HashTable/_HashTable.swift" "HashTable/_HashTable+Bucket.swift" "HashTable/_HashTable+BucketIterator.swift" @@ -71,16 +86,3 @@ list(APPEND COLLECTIONS_ORDERED_SOURCES "OrderedSet/OrderedSet.swift" "Utilities/_UnsafeBitset.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_ORDERED_SOURCES ${COLLECTIONS_ORDERED_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - add_library(OrderedCollections - ${COLLECTIONS_ORDERED_SOURCES}) - target_link_libraries(OrderedCollections PRIVATE - 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) -endif() diff --git a/Sources/RopeModule/CMakeLists.txt b/Sources/RopeModule/CMakeLists.txt index 60a78007..d33fac92 100644 --- a/Sources/RopeModule/CMakeLists.txt +++ b/Sources/RopeModule/CMakeLists.txt @@ -7,7 +7,22 @@ Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information #]] -list(APPEND COLLECTIONS_ROPE_SOURCES +if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE) + set(module_name ${COLLECTIONS_MODULE_NAME}) +else() + set(module_name _RopeModule) + add_library(_RopeModule + ${COLLECTIONS_ROPE_SOURCES}) + target_link_libraries(_RopeModule PRIVATE + 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) +endif() + +target_sources(${module_name} PRIVATE "BigString/Basics/BigString+Metrics.swift" "BigString/Basics/BigString+Index.swift" "BigString/Basics/BigString+Summary.swift" @@ -85,16 +100,3 @@ list(APPEND COLLECTIONS_ROPE_SOURCES "Utilities/String.Index+ABI.swift" "Utilities/Optional Utilities.swift" ) -set_property(GLOBAL APPEND PROPERTY COLLECTIONS_ROPE_SOURCES ${COLLECTIONS_ROPE_SOURCES}) - -if(NOT COLLECTIONS_SINGLE_MODULE) - add_library(_RopeModule - ${COLLECTIONS_ROPE_SOURCES}) - target_link_libraries(_RopeModule PRIVATE - 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) -endif()