CMake: Support CMP0157 when available#3321
Open
Steelskin wants to merge 1 commit into
Open
Conversation
CMP0157 (introduced in CMake 3.29) improves Swift support in CMake by handling many build details natively instead of requiring manual configuration. It also introduces an abstraction for selecting the Swift compilation mode per target. Supporting CMP0157 will simplify the Swift toolchain build once the necessary changes have landed in the main Swift repository. These changes make it possible to support CMP0157 set to either OLD or NEW. We cannot yet require CMP0157 to be NEW, because the Swift compiler build (which consumes swift-syntax via FetchContent) has not yet adopted the policy. When the parent project's policy is OLD, swift-syntax falls back to the legacy code path. The OLD support should be removed once the Swift-repo-side changes have landed.
Author
|
@swift-ci please test |
Steelskin
added a commit
to Steelskin/swift
that referenced
this pull request
Apr 22, 2026
CMake 3.29 introduces CMP0157, which improves Swift support in CMake. These changes require swiftlang/swift-syntax#3321 to work properly as swift-syntax does not build with CMP0157 set to NEW otherwise.
Member
|
@etcwilde would you review this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMP0157 (introduced in CMake 3.29) improves Swift support in CMake by handling many build details natively instead of requiring manual configuration. It also introduces an abstraction for selecting the Swift compilation mode per target.
Supporting CMP0157 will simplify the Swift toolchain build once the necessary changes have landed in the main Swift repository.
These changes make it possible to support CMP0157 set to either OLD or NEW. We cannot yet require CMP0157 to be NEW, because the Swift compiler build (which consumes swift-syntax via FetchContent) has not yet adopted the policy. When the parent project's policy is OLD, swift-syntax falls back to the legacy code path. The OLD support should be removed once the Swift-repo-side changes have landed.
These changes unblock further upgrades to CMake, which are currently blocked behind support for CMP0157, and changes to the way linker flags are passed to Swift, starting with CMake 3.30.
There should be no changes in the built artifacts, whether CMP0157 is set to OLD or NEW.
Minimal. The changes were tested locally and will be tested on CI.
Local testing + CI.