Skip to content

Commit

Permalink
[6.0] Explicitly link to Foundation in CMake builds (#709)
Browse files Browse the repository at this point in the history
Cherry-pick #693 into `release/6.0`

* **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
  • Loading branch information
rintaro authored Sep 24, 2024
1 parent 65138ff commit 0781022
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ endif()
project(SwiftTesting
LANGUAGES CXX Swift)

if(NOT APPLE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
find_package(dispatch CONFIG)
endif()
find_package(Foundation CONFIG)
endif()

include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH
Expand Down
8 changes: 8 additions & 0 deletions Sources/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ add_library(Testing
Traits/Trait.swift)
target_link_libraries(Testing PRIVATE
_TestingInternals)
if(NOT APPLE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
target_link_libraries(Testing PUBLIC
dispatch)
endif()
target_link_libraries(Testing PUBLIC
Foundation)
endif()
add_dependencies(Testing
TestingMacros)
target_compile_options(Testing PRIVATE
Expand Down

0 comments on commit 0781022

Please sign in to comment.