Skip to content

Commit cd448bb

Browse files
rintarogrynspan
andauthored
[6.0.2][CMake] Explicitly link Testing to Foundation (#713)
Cherry-pick #693 into `release/6.0.2` * **Explanation**: Previously in CMake builds, when `Foundation` was not in the regular search directory (e.g. resource directory or SDK search paths) `#if canImport(Foundation)` used to fail, and the functionalities are not included. This patch provides a way to provide `Foundation_DIR` for `find_packgage(Foundation CONFIG)`, so that clients can correctly link Testing to Foundation * **Scope**: CMake builds * **Risk**: Low. No actual code changes. * **Testing**: Passes current test suite Also manually tested the build toolchain * **Issues**: N/A * **Reviewer**: @stmontgomery --------- Co-authored-by: Jonathan Grynspan <[email protected]>
1 parent 981ef15 commit cd448bb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Diff for: CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ endif()
1515
project(SwiftTesting
1616
LANGUAGES CXX Swift)
1717

18+
if(NOT APPLE)
19+
if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
20+
find_package(dispatch CONFIG)
21+
endif()
22+
find_package(Foundation CONFIG)
23+
endif()
24+
1825
include(GNUInstallDirs)
1926

2027
list(APPEND CMAKE_MODULE_PATH

Diff for: Sources/Testing/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ add_library(Testing
9494
Traits/Trait.swift)
9595
target_link_libraries(Testing PRIVATE
9696
_TestingInternals)
97+
if(NOT APPLE)
98+
if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
99+
target_link_libraries(Testing PUBLIC
100+
dispatch)
101+
endif()
102+
target_link_libraries(Testing PUBLIC
103+
Foundation)
104+
endif()
97105
if(NOT BUILD_SHARED_LIBS)
98106
# When building a static library, tell clients to autolink the internal
99107
# library.

0 commit comments

Comments
 (0)