Merge topic 'ewilde/swift-static-try-compile'

c6e52ef7f2 Swift: Support static-library try-compile type

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9520
This commit is contained in:
Brad King
2024-05-17 15:11:50 +00:00
committed by Kitware Robot
3 changed files with 19 additions and 1 deletions

View File

@@ -24,7 +24,10 @@ if(NOT CMAKE_Swift_COMPILER_WORKS)
# Clear result from normal variable.
unset(CMAKE_Swift_COMPILER_WORKS)
# Puts test result in cache variable.
set(__CMAKE_Swift_TEST_SOURCE "print(\"CMake\")\n")
string(CONCAT __CMAKE_Swift_TEST_SOURCE
"public struct CMakeStruct {"
" let x: Int"
"}")
try_compile(CMAKE_Swift_COMPILER_WORKS
SOURCE_FROM_VAR main.swift __CMAKE_Swift_TEST_SOURCE
OUTPUT_VARIABLE __CMAKE_Swift_COMPILER_OUTPUT)

View File

@@ -0,0 +1 @@
enable_language(Swift)

View File

@@ -69,6 +69,20 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build .)
endblock()
block()
# Try enabling Swift with a static-library try-compile
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/StaticLibTryCompile-build)
set(RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY)
run_cmake(EnableSwift)
endblock()
block()
# Try enabling Swift with an executable try-compile
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExecutableTryCompile-build)
set(RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=EXECUTABLE)
run_cmake(EnableSwift)
endblock()
block()
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build)
run_cmake(ForceResponseFile)