[CMake] Enable CMP0157 and keep whole-module builds for optimized configs (#324)

Enable CMP0157 so Ninja compiles each Swift module in its own step,
separate from the link. Optimized configurations keep `-wmo`, as under
the old policy.

Tracking: swiftlang/swift#93995

assisted by Claude
This commit is contained in:
Charles Zablit authored and GitHub committed 2026-11-05 13:43:34 +00:00
1 parent 84f03fafec
commit 5e9d180069
1 file changed
+8
+8
View File
@@ -14,9 +14,17 @@
cmake_minimum_required(VERSION 3.19)
if(POLICY CMP0157)
cmake_policy(SET CMP0157 NEW)
endif()
project(SwiftCertificates
LANGUAGES Swift)
if(POLICY CMP0157 AND PROJECT_IS_TOP_LEVEL)
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release,RelWithDebInfo,MinSizeRel>,wholemodule,incremental>")
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
include(SwiftSupport)