mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-09 18:09:02 -05:00
Merge topic 'xcode-pch-swift-cxx'
77c4d2f9a2 Xcode: Fix PCH support with Swift & C++
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9203
This commit is contained in:
@@ -3067,7 +3067,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
|
||||
}
|
||||
|
||||
// Precompile Headers
|
||||
std::string pchHeader = gtgt->GetPchHeader(configName, llang);
|
||||
std::string pchHeader =
|
||||
gtgt->GetPchHeader(configName, langForPreprocessorDefinitions);
|
||||
if (!pchHeader.empty()) {
|
||||
buildSettings->AddAttribute("GCC_PREFIX_HEADER",
|
||||
this->CreateString(pchHeader));
|
||||
|
||||
@@ -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()
|
||||
|
||||
9
Tests/SwiftMixPCH/CMain.c
Normal file
9
Tests/SwiftMixPCH/CMain.c
Normal file
@@ -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;
|
||||
}
|
||||
15
Tests/SwiftMixPCH/CMakeLists.txt
Normal file
15
Tests/SwiftMixPCH/CMakeLists.txt
Normal file
@@ -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>")
|
||||
4
Tests/SwiftMixPCH/SwiftFunc.swift
Normal file
4
Tests/SwiftMixPCH/SwiftFunc.swift
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
func SwiftFunc() -> Int32 {
|
||||
return 0;
|
||||
}
|
||||
1
Tests/SwiftMixPCH/pch.h
Normal file
1
Tests/SwiftMixPCH/pch.h
Normal file
@@ -0,0 +1 @@
|
||||
#define PCH_VALUE 42
|
||||
Reference in New Issue
Block a user