summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-21 12:18:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-09-21 12:19:05 (GMT)
commita50346c1d0ebf355ba27177817bc4b45259b0810 (patch)
treedd5fb1d016492173fc1fe95e0a7f7afd0e6a4649 /Tests
parent4930c36252a1bf63a67be2d196da2254f6d2280f (diff)
parentf6ff19cc9d2ce51791f32b7e4fd0ad6d917a00cc (diff)
downloadCMake-a50346c1d0ebf355ba27177817bc4b45259b0810.zip
CMake-a50346c1d0ebf355ba27177817bc4b45259b0810.tar.gz
CMake-a50346c1d0ebf355ba27177817bc4b45259b0810.tar.bz2
Merge topic 'swift-mix-cxx'
f6ff19cc9d Tests: Add mixed Swift+CXX source test case 399343486f Tests: Add swift compiler version to test check a9509cec7e Ninja: Fix mixed Swift/CXX library target generation Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7679
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt3
-rw-r--r--Tests/CheckSwift.cmake2
-rw-r--r--Tests/SwiftMixLib/CMakeLists.txt6
-rw-r--r--Tests/SwiftMixLib/lib.c4
-rw-r--r--Tests/SwiftMixLib/lib.cpp4
-rw-r--r--Tests/SwiftMixLib/lib.swift3
-rw-r--r--Tests/SwiftMixLib/main.swift3
7 files changed, 25 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index abe742e..3540aaa 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -394,6 +394,9 @@ if(BUILD_TESTING)
if(CMake_TEST_XCODE_SWIFT)
ADD_TEST_MACRO(SwiftMix SwiftMix)
endif()
+ if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.1)
+ ADD_TEST_MACRO(SwiftMixLib Swifty)
+ endif()
endif()
if(CMAKE_Fortran_COMPILER)
ADD_TEST_MACRO(FortranOnly FortranOnly)
diff --git a/Tests/CheckSwift.cmake b/Tests/CheckSwift.cmake
index fcbae7e..099c298 100644
--- a/Tests/CheckSwift.cmake
+++ b/Tests/CheckSwift.cmake
@@ -14,6 +14,7 @@ if(NOT DEFINED CMAKE_Swift_COMPILER)
project(CheckSwift Swift)
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_Swift_COMPILER \\\"\${CMAKE_Swift_COMPILER}\\\")\\n\"
+ \"set(CMAKE_Swift_COMPILER_VERSION \\\"\${CMAKE_Swift_COMPILER_VERSION}\\\")\\n\"
\"set(CMAKE_Swift_FLAGS \\\"\${CMAKE_Swift_FLAGS}\\\")\\n\")
")
@@ -54,6 +55,7 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
message(STATUS "${_desc} - ${CMAKE_Swift_COMPILER}")
set(CMAKE_Swift_COMPILER "${CMAKE_Swift_COMPILER}" CACHE FILEPATH "Swift compiler")
+ set(CMAKE_Swift_COMPILER_VERSION "${CMAKE_Swift_COMPILER_VERSION}" CACHE FILEPATH "Swift compiler version")
set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}" CACHE STRING "Swift flags")
mark_as_advanced(CMAKE_Swift_COMPILER)
diff --git a/Tests/SwiftMixLib/CMakeLists.txt b/Tests/SwiftMixLib/CMakeLists.txt
new file mode 100644
index 0000000..40d3498
--- /dev/null
+++ b/Tests/SwiftMixLib/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.24)
+project(SwiftMixLib C CXX Swift)
+
+add_library(SwiftMixedLib lib.c lib.cpp lib.swift)
+add_executable(Swifty main.swift)
+target_link_libraries(Swifty PUBLIC SwiftMixedLib)
diff --git a/Tests/SwiftMixLib/lib.c b/Tests/SwiftMixLib/lib.c
new file mode 100644
index 0000000..8eca512
--- /dev/null
+++ b/Tests/SwiftMixLib/lib.c
@@ -0,0 +1,4 @@
+int add_int(int a, int b)
+{
+ return a + b;
+}
diff --git a/Tests/SwiftMixLib/lib.cpp b/Tests/SwiftMixLib/lib.cpp
new file mode 100644
index 0000000..3e156b8
--- /dev/null
+++ b/Tests/SwiftMixLib/lib.cpp
@@ -0,0 +1,4 @@
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/Tests/SwiftMixLib/lib.swift b/Tests/SwiftMixLib/lib.swift
new file mode 100644
index 0000000..61009d8
--- /dev/null
+++ b/Tests/SwiftMixLib/lib.swift
@@ -0,0 +1,3 @@
+public func add(a: Int, b: Int) -> Int {
+ a + b
+}
diff --git a/Tests/SwiftMixLib/main.swift b/Tests/SwiftMixLib/main.swift
new file mode 100644
index 0000000..d2e9364
--- /dev/null
+++ b/Tests/SwiftMixLib/main.swift
@@ -0,0 +1,3 @@
+import SwiftMixedLib
+
+print(add(a: 1, b: 2))