CMake/Tests/SwiftMixPCH/CMakeLists.txt
Mikko Lehtonen 77c4d2f9a2 Xcode: Fix PCH support with Swift & C++
Previously, when a mixed language target ends up with `Swift` as the
`LINKER_LANGUAGE`, the PCH file was not set for the target at all.

Fixes: #21224
2024-01-30 12:50:40 -05:00

16 lines
465 B
CMake

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>")