summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-25 15:15:07 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-01-25 15:15:28 (GMT)
commit35246ed9c4bba6980d4cc95cda1be534231eaa1d (patch)
tree1d433d6ef784b4aa0c5349dccb81de5716495574 /Tests
parenta8f0e347907cf0c442c5c2be3dbe4e9f7d7c63d7 (diff)
parentb2129a14f47a92dfb0c662882885d335b98811d7 (diff)
downloadCMake-35246ed9c4bba6980d4cc95cda1be534231eaa1d.zip
CMake-35246ed9c4bba6980d4cc95cda1be534231eaa1d.tar.gz
CMake-35246ed9c4bba6980d4cc95cda1be534231eaa1d.tar.bz2
Merge topic 'swift-windows'
b2129a14f4 Tests: Fix SwiftMix tests' runtime library selection on Windows 4f49f7fc0b Tests: Fix SwiftOnly test on Windows 2dec0c0308 Tests: Fix RunCMake.Swift expected output on Windows 79f1f509b1 Tests: Fix RunCMake.Swift's build output checks Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Jeremy Day <jadaytime@gmail.com> Merge-request: !9169
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt2
-rw-r--r--Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt4
-rw-r--r--Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt2
-rw-r--r--Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt6
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake42
-rw-r--r--Tests/SwiftMix/CMakeLists.txt5
-rw-r--r--Tests/SwiftMixLib/CMakeLists.txt3
-rw-r--r--Tests/SwiftOnly/SubA/SubA.swift1
-rw-r--r--Tests/SwiftOnly/SubB/SubB.swift2
9 files changed, 39 insertions, 28 deletions
diff --git a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt
index 0955c61..d593b92 100644
--- a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt
+++ b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt
@@ -1 +1 @@
-swiftc .* -output-file-map CMakeFiles/greetings_default.dir//output-file-map.json .*
+swiftc(.exe)? .* -output-file-map CMakeFiles(/|\\)greetings_default.dir(//|\\\\)output-file-map.json .*
diff --git a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt
index 3d70f12..ec396d7 100644
--- a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt
+++ b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt
@@ -1,2 +1,2 @@
-swiftc -j [0-9]+ -num-threads [0-9]+ -c @CMakeFiles/L.dir/L.o.swift.rsp
-.*swiftc -emit-library -static -o libL.a @CMakeFiles/L.rsp
+swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c @CMakeFiles(/|\\)L.dir(/|\\)L.o(bj)?.swift.rsp
+.*swiftc(.exe)? -emit-library -static -o (libL.a|L.lib) @CMakeFiles(/|\\)L.rsp
diff --git a/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt b/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt
index 7a882f8..efa3336 100644
--- a/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt
+++ b/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt
@@ -1,2 +1,2 @@
ninja explain: A.swiftmodule is dirty
-ninja explain: libB.a is dirty
+ninja explain: (libB.a|B.lib) is dirty
diff --git a/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt b/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt
index d644d6b..8e5b97c 100644
--- a/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt
+++ b/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt
@@ -1,3 +1,3 @@
-.*Building Swift object A.swiftmodule CMakeFiles/A.dir/a.swift.o
-.*Building Swift object B.swiftmodule CMakeFiles/B.dir/b.swift.o
-FAILED: B.swiftmodule CMakeFiles/B.dir/b.swift.o
+.*Building Swift object A.swiftmodule CMakeFiles(/|\\)A.dir(/|\\)a.swift.o(bj)?
+.*Building Swift object B.swiftmodule CMakeFiles(/|\\)B.dir(/|\\)b.swift.o(bj)?
+FAILED: B.swiftmodule CMakeFiles(/|\\)B.dir(/|\\)b.swift.o(bj)?
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index 56158e3..3711efb 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -35,60 +35,62 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
# Test that intermediate static libraries are rebuilt when the public
# interface of their dependency changes
block()
- set(IncrementalSwift_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncrementalSwift-build)
- set(IncrementalSwift_TEST_NO_CLEAN 1)
- set(IncrementalSwift_TEST_OUTPUT_MERGE 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncrementalSwift-build)
# Since files are modified during test, the files are created in the cmake
# file into the build directory
run_cmake(IncrementalSwift)
- run_cmake_command(IncrementalSwift-first ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(IncrementalSwift-first ${CMAKE_COMMAND} --build .)
# Modify public interface of libA requiring rebuild of libB
- file(WRITE ${IncrementalSwift_TEST_BINARY_DIR}/a.swift
+ file(WRITE ${RunCMake_TEST_BINARY_DIR}/a.swift
"public func callA() -> Float { return 32.0 }\n")
# Note: We still expect this to fail, but instead of failure at link time,
# it should fail while re-compiling libB because the function changed
- run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR} -- -d explain)
+ run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build . -- -d explain)
endblock()
block()
- set(CMP0157-OLD_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build)
- set(CMP0157-OLD_TEST_NO_CLEAN 1)
- set(CMP0157-OLD_TEST_OUTPUT_MERGE 1)
-
run_cmake(CMP0157-NEW)
+ run_cmake(CMP0157-WARN)
+
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build)
run_cmake(CMP0157-OLD)
+ set(RunCMake_TEST_NO_CLEAN 1)
# -n: dry-run to avoid actually compiling, -v: verbose to capture executed command
- run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build ${CMP0157-OLD_TEST_BINARY_DIR} -- -n -v)
- run_cmake(CMP0157-WARN)
+ run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build . -- -n -v)
endblock()
block()
- set(CompileCommands_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompileCommands-build)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompileCommands-build)
run_cmake(CompileCommands)
- run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build ${CompileCommands_TEST_BINARY_DIR})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build .)
endblock()
block()
- set(ForceResponseFile_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build)
run_cmake(ForceResponseFile)
+ set(RunCMake_TEST_NO_CLEAN 1)
# -v: verbose to capture executed commands -n: dry-run to avoid actually compiling
- run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build ${ForceResponseFile_TEST_BINARY_DIR} -- -vn)
+ run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build . -- -vn)
endblock()
block()
if(CMAKE_SYSTEM_NAME MATCHES Windows)
- set(ImportLibraryFlags_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ImportLibraryFlags-build)
run_cmake(ImportLibraryFlags)
- run_cmake_command(ImportLibraryFlags-check ${CMAKE_COMMAND} --build ${SwiftLibraryModuleCommand_TEST_BINARY_DIR} -- -n -v)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(ImportLibraryFlags-check ${CMAKE_COMMAND} --build . -- -n -v)
endif()
endblock()
block()
- set(SwiftLibraryModuleCommand_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build)
run_cmake(SwiftLibraryModuleCommand)
- run_cmake_command(SwiftLibraryModuleCommand-check ${CMAKE_COMMAND} --build ${SwiftLibraryModuleCommand_TEST_BINARY_DIR} -- -n -v)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(SwiftLibraryModuleCommand-check ${CMAKE_COMMAND} --build . -- -n -v)
endblock()
endif()
elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config")
diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt
index e8b6521..a4bb19b 100644
--- a/Tests/SwiftMix/CMakeLists.txt
+++ b/Tests/SwiftMix/CMakeLists.txt
@@ -1,6 +1,9 @@
-cmake_minimum_required(VERSION 3.3)
+cmake_minimum_required(VERSION 3.15)
project(SwiftMix C Swift)
+# Swift on Windows only provides a release runtime.
+set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+
add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h)
set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h")
target_compile_options(SwiftMix PRIVATE "$<$<COMPILE_LANGUAGE:C>:-Werror=objc-method-access>")
diff --git a/Tests/SwiftMixLib/CMakeLists.txt b/Tests/SwiftMixLib/CMakeLists.txt
index a52fc94..d23c6ba 100644
--- a/Tests/SwiftMixLib/CMakeLists.txt
+++ b/Tests/SwiftMixLib/CMakeLists.txt
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.24)
project(SwiftMixLib C CXX Swift)
+# Swift on Windows only provides a release runtime.
+set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+
add_library(SwiftMixedLib lib.c lib.cpp lib.swift)
add_executable(Swifty main.swift)
target_link_libraries(Swifty PUBLIC SwiftMixedLib)
diff --git a/Tests/SwiftOnly/SubA/SubA.swift b/Tests/SwiftOnly/SubA/SubA.swift
index e69de29..09ddd88 100644
--- a/Tests/SwiftOnly/SubA/SubA.swift
+++ b/Tests/SwiftOnly/SubA/SubA.swift
@@ -0,0 +1 @@
+public func hi() { print("hi") }
diff --git a/Tests/SwiftOnly/SubB/SubB.swift b/Tests/SwiftOnly/SubB/SubB.swift
index d593c4c..142fdaa 100644
--- a/Tests/SwiftOnly/SubB/SubB.swift
+++ b/Tests/SwiftOnly/SubB/SubB.swift
@@ -1 +1,3 @@
import SubA
+
+public var number = 42