mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-07 08:10:48 +00:00
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.
This commit is contained in:
@@ -394,6 +394,9 @@ if(BUILD_TESTING)
|
|||||||
if(CMake_TEST_XCODE_SWIFT)
|
if(CMake_TEST_XCODE_SWIFT)
|
||||||
ADD_TEST_MACRO(SwiftMix SwiftMix)
|
ADD_TEST_MACRO(SwiftMix SwiftMix)
|
||||||
endif()
|
endif()
|
||||||
|
if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.1)
|
||||||
|
ADD_TEST_MACRO(SwiftMixLib Swifty)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_Fortran_COMPILER)
|
if(CMAKE_Fortran_COMPILER)
|
||||||
ADD_TEST_MACRO(FortranOnly FortranOnly)
|
ADD_TEST_MACRO(FortranOnly FortranOnly)
|
||||||
|
|||||||
6
Tests/SwiftMixLib/CMakeLists.txt
Normal file
6
Tests/SwiftMixLib/CMakeLists.txt
Normal file
@@ -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)
|
||||||
4
Tests/SwiftMixLib/lib.c
Normal file
4
Tests/SwiftMixLib/lib.c
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
int add_int(int a, int b)
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
4
Tests/SwiftMixLib/lib.cpp
Normal file
4
Tests/SwiftMixLib/lib.cpp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
int add(int a, int b)
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
3
Tests/SwiftMixLib/lib.swift
Normal file
3
Tests/SwiftMixLib/lib.swift
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
public func add(a: Int, b: Int) -> Int {
|
||||||
|
a + b
|
||||||
|
}
|
||||||
3
Tests/SwiftMixLib/main.swift
Normal file
3
Tests/SwiftMixLib/main.swift
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import SwiftMixedLib
|
||||||
|
|
||||||
|
print(add(a: 1, b: 2))
|
||||||
Reference in New Issue
Block a user