diff options
author | Brad King <brad.king@kitware.com> | 2024-01-31 14:01:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-31 14:01:45 (GMT) |
commit | 2a008138420b0a2cc867f5d3e47accc7d2fda5e0 (patch) | |
tree | 019a7b2fa05325b311e172e0460f4441604faf3e /Tests | |
parent | eb9124bd195817efcc17bf8d5b44d487efa0046b (diff) | |
parent | 77c4d2f9a213f0c6bda0fb78238d621ecbb3676d (diff) | |
download | CMake-2a008138420b0a2cc867f5d3e47accc7d2fda5e0.zip CMake-2a008138420b0a2cc867f5d3e47accc7d2fda5e0.tar.gz CMake-2a008138420b0a2cc867f5d3e47accc7d2fda5e0.tar.bz2 |
Merge topic 'xcode-pch-swift-cxx'
77c4d2f9a2 Xcode: Fix PCH support with Swift & C++
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9203
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/SwiftMixPCH/CMain.c | 9 | ||||
-rw-r--r-- | Tests/SwiftMixPCH/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/SwiftMixPCH/SwiftFunc.swift | 4 | ||||
-rw-r--r-- | Tests/SwiftMixPCH/pch.h | 1 |
5 files changed, 30 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index a1619ec..a7a456c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -412,6 +412,7 @@ if(BUILD_TESTING) PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") if(CMake_TEST_Swift) ADD_TEST_MACRO(SwiftOnly SwiftOnly) + ADD_TEST_MACRO(SwiftMixPCH SwiftMixPCH) if(CMake_TEST_XCODE_SWIFT) ADD_TEST_MACRO(SwiftMix SwiftMix) endif() diff --git a/Tests/SwiftMixPCH/CMain.c b/Tests/SwiftMixPCH/CMain.c new file mode 100644 index 0000000..4cd78e6 --- /dev/null +++ b/Tests/SwiftMixPCH/CMain.c @@ -0,0 +1,9 @@ +#ifndef PCH_VALUE +# error "PCH_VALUE not defined" +#endif + +int main(void) +{ + const int value = PCH_VALUE; + return value == 42 ? 0 : 1; +} diff --git a/Tests/SwiftMixPCH/CMakeLists.txt b/Tests/SwiftMixPCH/CMakeLists.txt new file mode 100644 index 0000000..d5704f1 --- /dev/null +++ b/Tests/SwiftMixPCH/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.15) +if(POLICY CMP0157) + cmake_policy(SET CMP0157 NEW) +endif() + +project(SwiftMixPCH C Swift) + +# Swift on Windows only provides a release runtime. +set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) + +add_executable(SwiftMixPCH CMain.c SwiftFunc.swift) +target_precompile_headers(SwiftMixPCH PRIVATE pch.h) + +# We don't want swift to emit main() +target_compile_options(SwiftMixPCH PRIVATE "$<$<COMPILE_LANGUAGE:Swift>:-parse-as-library>") diff --git a/Tests/SwiftMixPCH/SwiftFunc.swift b/Tests/SwiftMixPCH/SwiftFunc.swift new file mode 100644 index 0000000..d49c36f --- /dev/null +++ b/Tests/SwiftMixPCH/SwiftFunc.swift @@ -0,0 +1,4 @@ + +func SwiftFunc() -> Int32 { + return 0; +} diff --git a/Tests/SwiftMixPCH/pch.h b/Tests/SwiftMixPCH/pch.h new file mode 100644 index 0000000..6de0669 --- /dev/null +++ b/Tests/SwiftMixPCH/pch.h @@ -0,0 +1 @@ +#define PCH_VALUE 42 |