Skip to content

[CMake] Require CMake 3.29 to enable CMP0157 - #2252

Open
charles-zablit wants to merge 1 commit into
swiftlang:mainfrom
charles-zablit:cz/cmake/cmp0157
Open

charles-zablit wants to merge 1 commit into
swiftlang:mainfrom
charles-zablit:cz/cmake/cmp0157

Conversation

@charles-zablit

@charles-zablit charles-zablit commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Require CMake 3.29, which makes CMP0157 NEW: Ninja compiles each Swift module in its own step, separate from the link. The policy no longer adds -wmo to optimized builds, so build-script-helper.py now passes CMAKE_Swift_COMPILATION_MODE=wholemodule, as build.ps1 and build-script do (swiftlang/swift#94066).

Tracking: swiftlang/swift#93995

assisted by Claude

Comment thread CMakeLists.txt Outdated
@@ -8,6 +8,10 @@

cmake_minimum_required(VERSION 3.19.6)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we consider bumping this to 3.29 instead?

Comment thread CMakeLists.txt Outdated
Comment on lines +26 to +28
if(POLICY CMP0157 AND PROJECT_IS_TOP_LEVEL)
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release,RelWithDebInfo,MinSizeRel>,wholemodule,incremental>")
endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we sink this into the caller? That allows the caller to make the choice for wholemodule vs incremental.

@compnerd
compnerd requested a review from etcwilde November 5, 2026 00:17
Comment thread CMakeLists.txt Outdated

cmake_minimum_required(VERSION 3.19.6)

if(POLICY CMP0157)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to not bump the min required to CMake 3.29 or 3.30? There are other parts of the build that already require a newer CMake version. Then we can drop the checks.

Comment thread CMakeLists.txt Outdated
LANGUAGES C CXX Swift)

if(POLICY CMP0157 AND PROJECT_IS_TOP_LEVEL)
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release,RelWithDebInfo,MinSizeRel>,wholemodule,incremental>")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only be setting this if it hasn't already been set so that we aren't overriding the vendor of the driver.

@charles-zablit charles-zablit changed the title [CMake] Enable CMP0157 and keep whole-module builds for optimized configs [CMake] Require CMake 3.29 to enable CMP0157 Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants