Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake] Explicitly link Testing to Foundation #693

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
compnerd marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -96,6 +96,14 @@ add_library(Testing
Traits/Trait.swift)
target_link_libraries(Testing PRIVATE
_TestingInternals)
if(NOT APPLE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we need the if(NOT APPLE) guard for these target_link_libraries? I get why it's needed for find_package, but don't we want to link Foundation even on Darwin?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Darwin, Foundation is a framework, so -lFoundation doesn't work.
Yes it links Foundation, but that's done via auto-linking. I.e. import Foundation automatically sets required linker flags.

if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
target_link_libraries(Testing PUBLIC
dispatch)
endif()
compnerd marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(Testing PUBLIC
Foundation)
endif()
if(NOT BUILD_SHARED_LIBS)
# When building a static library, tell clients to autolink the internal
# library.
Expand Down