ladybird/Meta/CMake/FindSwiftTesting.cmake
Andrew Kaster 0bedc79ca5 CMake: Pull swift-testing from the Swift toolchain
This confirmed works on Xcode 16, and Xcode 16.1 Beta 2, with CMake 3.28
or higher.

On linux, the 6.0.0 release from swiftly is still missing my libstdc++
workaround, so it needs a snapshot to work.
2024-09-23 11:06:26 -06:00

25 lines
1 KiB
CMake

# Finds the swift-testing library
# On Apple platforms, this is a framework included in the Xcode release
find_library(SWIFT_TESTING NAMES Testing
PATHS ${SWIFT_LIBRARY_SEARCH_PATHS}
)
if (SWIFT_TESTING)
if (NOT TARGET SwiftTesting::SwiftTesting)
add_library(SwiftTesting::SwiftTesting IMPORTED UNKNOWN)
message(STATUS "Found SwiftTesting: ${SWIFT_TESTING}")
cmake_path(GET SWIFT_TESTING PARENT_PATH _SWIFT_TESTING_DIR)
set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
IMPORTED_LOCATION "${SWIFT_TESTING}"
INTERFACE_LINK_DIRECTORIES "${_SWIFT_TESTING_DIR}"
)
if (UNIX AND NOT APPLE)
cmake_path(GET _SWIFT_TESTING_DIR PARENT_PATH _SWIFT_TESTING_TARGETLESS_DIR)
set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-load-plugin-library ${_SWIFT_TESTING_TARGETLESS_DIR}/host/plugins/libTestingMacros.so>"
)
endif()
endif()
set(SwiftTesting_FOUND TRUE)
endif()