diff --git a/CMakeLists.txt b/CMakeLists.txt index 064f063e0..efb367756 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ See https://swift.org/LICENSE.txt for license information #]] cmake_minimum_required(VERSION 3.16) -project(swift-collections +project(SwiftCollections LANGUAGES C Swift) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) @@ -29,9 +29,4 @@ add_subdirectory(Sources) # if(BUILD_TESTING) # add_subdirectory(Tests) # endif() - -get_property(SWIFT_COLLECTIONS_EXPORTS GLOBAL PROPERTY SWIFT_COLLECTIONS_EXPORTS) -export(TARGETS ${SWIFT_COLLECTIONS_EXPORTS} - NAMESPACE SwiftCollections:: - FILE swift-collections-config.cmake - EXPORT_LINK_INTERFACE_LIBRARIES) +add_subdirectory(cmake/modules) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt new file mode 100644 index 000000000..e07591af3 --- /dev/null +++ b/cmake/modules/CMakeLists.txt @@ -0,0 +1,19 @@ +#[[ +This source file is part of the Swift Collections Open Source Project + +Copyright (c) 2021 Apple Inc. and the Swift project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +set(SWIFT_COLLECTIONS_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/SwiftCollectionsExports.cmake) + +configure_file(SwiftCollectionsConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/SwiftCollectionsConfig.cmake) + +get_property(SWIFT_COLLECTIONS_EXPORTS GLOBAL PROPERTY SWIFT_COLLECTIONS_EXPORTS) +export(TARGETS ${SWIFT_COLLECTIONS_EXPORTS} + NAMESPACE SwiftCollections:: + FILE ${SWIFT_COLLECTIONS_EXPORTS_FILE} + EXPORT_LINK_INTERFACE_LIBRARIES) diff --git a/cmake/modules/SwiftCollectionsConfig.cmake.in b/cmake/modules/SwiftCollectionsConfig.cmake.in new file mode 100644 index 000000000..3343244d9 --- /dev/null +++ b/cmake/modules/SwiftCollectionsConfig.cmake.in @@ -0,0 +1,12 @@ +#[[ +This source file is part of the Swift Collections Open Source Project + +Copyright (c) 2021 Apple Inc. and the Swift project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +if(NOT TARGET SwiftCollections) + include(@SWIFT_COLLECTIONS_EXPORTS_FILE@) +endif()