diff options
author | Evan Wilde <etceterawilde@gmail.com> | 2022-09-12 22:15:24 (GMT) |
---|---|---|
committer | Evan Wilde <etceterawilde@gmail.com> | 2022-09-19 18:37:48 (GMT) |
commit | f6ff19cc9d2ce51791f32b7e4fd0ad6d917a00cc (patch) | |
tree | cff84e33592c04b1a7f5e3c8625aaf2af378ffa6 /Tests | |
parent | 399343486f129f28b61683dbd95bec4ff16e60a0 (diff) | |
download | CMake-f6ff19cc9d2ce51791f32b7e4fd0ad6d917a00cc.zip CMake-f6ff19cc9d2ce51791f32b7e4fd0ad6d917a00cc.tar.gz CMake-f6ff19cc9d2ce51791f32b7e4fd0ad6d917a00cc.tar.bz2 |
Tests: Add mixed Swift+CXX source test case
This test ensures we can configure and build mixed source binaries. The
test configures, but fails to verify due to multiple targets emitting
the `lib.c.o` and `lib.cpp.o` outputs. Both the clang build step and the
swift link step report that they emit the `lib.c.o` and `lib.cpp.o`
outputs. The `.o`'s are emitted by clang, not by swift.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/SwiftMixLib/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/SwiftMixLib/lib.c | 4 | ||||
-rw-r--r-- | Tests/SwiftMixLib/lib.cpp | 4 | ||||
-rw-r--r-- | Tests/SwiftMixLib/lib.swift | 3 | ||||
-rw-r--r-- | Tests/SwiftMixLib/main.swift | 3 |
6 files changed, 23 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/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)) |