Skip to content

Commit 0a2e483

Browse files
authored
Export SwiftTesting_{BUILD_DIR,MACRO_DIR} in CMake (#1659)
### Motivation: These are consumed by XCTest when building lit tests in swiftlang/swift-corelibs-xctest#538 ### Modifications: * Export SwiftTesting_BUILD_DIR in SwiftTestingConfig * Export SwiftTesting_MACRO_DIR in SwiftTestingMacrosConfig SwiftTestingMacrosConfig is a new module exported in this change. Note we can't export this as part of SwiftTestingConfig, because we set SwiftTesting_MACRO=NO when building the Testing project for Linux, so there is no macro path available. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent a03f5ec commit 0a2e483

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

Sources/TestingMacros/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ if(SwiftTesting_BuildMacrosAsExecutables)
127127
target_link_libraries(TestingMacros PRIVATE
128128
SwiftSyntax::SwiftCompilerPlugin)
129129
endif()
130+
131+
# Makes SwiftTesting_MACRO_DIR available after find_package(SwiftTestingMacros)
132+
file(GENERATE
133+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/SwiftTestingMacrosConfig.cmake"
134+
CONTENT "get_filename_component(SwiftTesting_MACRO_DIR \"$<TARGET_FILE:TestingMacros>\" DIRECTORY)\n")

cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# See https://swift.org/LICENSE.txt for license information
77
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
set(SwiftTesting_BUILD_DIR "${CMAKE_BINARY_DIR}") # Exported by SwiftTestingConfig
910
set(SwiftTesting_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/SwiftTestingExports.cmake)
1011

1112
configure_file(SwiftTestingConfig.cmake.in

cmake/modules/SwiftTestingConfig.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
## See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
##
1010

11+
set(SwiftTesting_BUILD_DIR "@SwiftTesting_BUILD_DIR@")
12+
1113
if(NOT TARGET _TestingInterop)
1214
include(@SwiftTesting_EXPORTS_FILE@)
1315
endif()

0 commit comments

Comments
 (0)