diff options
author | Evan Wilde <etceterawilde@gmail.com> | 2024-03-22 16:24:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-02 14:42:12 (GMT) |
commit | 3fb4092826319730d529563820eefdaa3449a276 (patch) | |
tree | 55bf5b2febad4bafcc580b839fcd305ca5171583 /Tests/RunCMake/LinkerSelection | |
parent | 659bc156eff0a90c2ea3fdb3d866e07f8c0e436b (diff) | |
download | CMake-3fb4092826319730d529563820eefdaa3449a276.zip CMake-3fb4092826319730d529563820eefdaa3449a276.tar.gz CMake-3fb4092826319730d529563820eefdaa3449a276.tar.bz2 |
Swift: Add CMAKE_LINKER_TYPE support
Extend commit 96a953b1ed (Add options to specify linker tool, 2023-09-27,
v3.29.0-rc1~577^2) with the `CMAKE_Swift_USING_LINKER_*` variables
needed to support `CMAKE_LINKER_TYPE` for Swift.
Diffstat (limited to 'Tests/RunCMake/LinkerSelection')
-rw-r--r-- | Tests/RunCMake/LinkerSelection/AppleClassic.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/LinkerSelection/CustomLinkerType.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/LinkerSelection/RunCMakeTest.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/LinkerSelection/ValidLinkerType.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/LinkerSelection/main.swift | 1 |
5 files changed, 41 insertions, 5 deletions
diff --git a/Tests/RunCMake/LinkerSelection/AppleClassic.cmake b/Tests/RunCMake/LinkerSelection/AppleClassic.cmake index 62a12ad..170ae0c 100644 --- a/Tests/RunCMake/LinkerSelection/AppleClassic.cmake +++ b/Tests/RunCMake/LinkerSelection/AppleClassic.cmake @@ -1,7 +1,12 @@ - enable_language(C) set(CMAKE_LINKER_TYPE APPLE_CLASSIC) add_executable(main main.c) target_link_libraries(main PRIVATE m m) + +if(CMake_TEST_Swift) + enable_language(Swift) + add_executable(main_swift main.swift) + target_link_libraries(main_swift PRIVATE m m) +endif() diff --git a/Tests/RunCMake/LinkerSelection/CustomLinkerType.cmake b/Tests/RunCMake/LinkerSelection/CustomLinkerType.cmake index 4bf98b0..1121608 100644 --- a/Tests/RunCMake/LinkerSelection/CustomLinkerType.cmake +++ b/Tests/RunCMake/LinkerSelection/CustomLinkerType.cmake @@ -15,6 +15,14 @@ if(CMake_TEST_CUDA) set_property(TARGET mainCU PROPERTY LINKER_TYPE "$<$<LINK_LANGUAGE:C>:FOO_C>$<$<LINK_LANGUAGE:CUDA>:FOO_CUDA>") endif() +if(CMake_TEST_Swift) + enable_language(Swift) + + set(CMAKE_Swift_USING_LINKER_FOO_Swift "${CMAKE_Swift_USING_LINKER_LLD}") + add_executable(mainSwift main.swift) + set_property(TARGET mainSwift PROPERTY LINKER_TYPE FOO_Swift) +endif() + # # Generate file for validation # @@ -32,5 +40,14 @@ if(CMake_TEST_CUDA) string(APPEND LINKER_TYPE_OPTION "|${CUDA_LINKER}") endif() +if(CMake_TEST_Swift) + if(CMAKE_Swift_USING_LINKER_MODE STREQUAL "TOOL") + cmake_path(GET CMAKE_Swift_USING_LINKER_FOO_Swift FILENAME Swift_LINKER) + else() + set(Swift_LINKER "${CMAKE_Swift_USING_LINKER_FOO_Swift}") + endif() + string(APPEND LINKER_TYPE_OPTION "|${Swift_LINKER}") +endif() + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER_TYPE_OPTION.cmake" "set(LINKER_TYPE_OPTION \"${LINKER_TYPE_OPTION}\")\n") diff --git a/Tests/RunCMake/LinkerSelection/RunCMakeTest.cmake b/Tests/RunCMake/LinkerSelection/RunCMakeTest.cmake index 8929a0d..0a3f01c 100644 --- a/Tests/RunCMake/LinkerSelection/RunCMakeTest.cmake +++ b/Tests/RunCMake/LinkerSelection/RunCMakeTest.cmake @@ -17,12 +17,11 @@ endif() find_program(LLD_LINKER NAMES ${LINKER_NAMES}) macro(run_cmake_and_build test) - run_cmake_with_options(${test} -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + run_cmake_with_options(${test} + -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMake_TEST_Swift=${CMake_TEST_Swift}) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) set(RunCMake_TEST_NO_CLEAN 1) - if(CMake_TEST_CUDA) - string(APPEND "|${CMAKE_CUDA_USING_LINKER_LLD}") - endif() run_cmake_command(${test}-build ${CMAKE_COMMAND} --build . --config Release --verbose ${ARGN}) unset(RunCMake_TEST_BINARY_DIR) @@ -34,6 +33,7 @@ if(LLD_LINKER) set(CMAKE_VERBOSE_MAKEFILE TRUE) set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) + set(CMAKE_Swift_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) run_cmake_and_build(ValidLinkerType) run_cmake_and_build(CustomLinkerType) diff --git a/Tests/RunCMake/LinkerSelection/ValidLinkerType.cmake b/Tests/RunCMake/LinkerSelection/ValidLinkerType.cmake index a685ac1..9170f5c 100644 --- a/Tests/RunCMake/LinkerSelection/ValidLinkerType.cmake +++ b/Tests/RunCMake/LinkerSelection/ValidLinkerType.cmake @@ -11,6 +11,11 @@ if(CMake_TEST_CUDA) add_executable(mainCU main.cu) endif() +if(CMake_TEST_Swift) + enable_language(Swift) + add_executable(mainSwift main.swift) +endif() + # # Generate file for validation # @@ -27,6 +32,14 @@ if(CMake_TEST_CUDA) endif() string(APPEND LINKER_TYPE_OPTION "|${CUDA_LINKER}") endif() +if(CMake_TEST_Swift) + if(CMAKE_Swift_USING_LINKER_MODE STREQUAL "TOOL") + cmake_path(GET CMAKE_Swift_USING_LINKER_LLD FILENAME LINKER_TYPE_OPTION) + else() + set(Swift_LINKER "${CMAKE_Swift_USING_LINKER_LLD}") + endif() + string(APPEND LINKER_TYPE_OPTION "|${Swift_LINKER}") +endif() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER_TYPE_OPTION.cmake" "set(LINKER_TYPE_OPTION \"${LINKER_TYPE_OPTION}\")\n") diff --git a/Tests/RunCMake/LinkerSelection/main.swift b/Tests/RunCMake/LinkerSelection/main.swift new file mode 100644 index 0000000..b80e322 --- /dev/null +++ b/Tests/RunCMake/LinkerSelection/main.swift @@ -0,0 +1 @@ +print("hi") |