mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
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.
This commit is contained in:
parent
7ab1d117f1
commit
0bedc79ca5
Notes:
github-actions[bot]
2024-09-23 17:07:17 +00:00
Author: https://github.com/ADKaster
Commit: 0bedc79ca5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1477
2 changed files with 19 additions and 108 deletions
|
@ -1,45 +1,24 @@
|
|||
# Finds the swift-testing library
|
||||
# On Apple platforms, this is a framework included in the Xcode release
|
||||
|
||||
# FIXME: Using Xcode's library actually doesn't work for rpath reasons
|
||||
# When swift-testing ships better toolchain CMake support, we'll need to revisit this
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Allow the Ninja generators to output messages as they happen by assigning
|
||||
# these jobs to the 'console' job pool
|
||||
set(console_access "")
|
||||
if(CMAKE_GENERATOR MATCHES "^Ninja")
|
||||
set(console_access
|
||||
USES_TERMINAL_CONFIGURE YES
|
||||
USES_TERMINAL_BUILD YES
|
||||
USES_TERMINAL_INSTALL YES
|
||||
)
|
||||
endif()
|
||||
|
||||
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE OPT_IN)
|
||||
FetchContent_Declare(SwiftTesting
|
||||
GIT_REPOSITORY https://github.com/swiftlang/swift-testing.git
|
||||
GIT_TAG d00d46920f9bb35342ad29398ea4740a2bbf3d38
|
||||
PATCH_COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/patches/git-patch.cmake"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/swift-testing//0001-CMake-Allow-ExternalProjects-to-use-console-with-Nin.patch"
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
SYSTEM
|
||||
${console_access}
|
||||
find_library(SWIFT_TESTING NAMES Testing
|
||||
PATHS ${SWIFT_LIBRARY_SEARCH_PATHS}
|
||||
)
|
||||
|
||||
block()
|
||||
add_cxx_compile_options(-Wno-error)
|
||||
set(SwiftTesting_MACRO "<auto>")
|
||||
FetchContent_MakeAvailable(SwiftTesting)
|
||||
add_cxx_compile_options(-Werror)
|
||||
endblock()
|
||||
|
||||
if (NOT TARGET SwiftTesting::SwiftTesting)
|
||||
# FIXME: This should be an interface property on the target itself, if the maintainers intend
|
||||
# for the repository to be fetch-content-able
|
||||
set_property(TARGET Testing APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-load-plugin-executable ${CMAKE_BINARY_DIR}/bin/TestingMacros#TestingMacros>")
|
||||
add_library(SwiftTesting::SwiftTesting ALIAS Testing)
|
||||
set(SwiftTesting_LIBRARIES SwiftTesting::SwiftTesting)
|
||||
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()
|
||||
set(SwiftTesting_FOUND TRUE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue