Skip to content

CMake: Support CMP0157 when available#3321

Open
Steelskin wants to merge 1 commit into
swiftlang:mainfrom
Steelskin:fabrice/swift-syntax-support-cmp0157
Open

CMake: Support CMP0157 when available#3321
Steelskin wants to merge 1 commit into
swiftlang:mainfrom
Steelskin:fabrice/swift-syntax-support-cmp0157

Conversation

@Steelskin

@Steelskin Steelskin commented Apr 22, 2026

Copy link
Copy Markdown
  • Explanation:

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.

  • Scope:

There should be no changes in the built artifacts, whether CMP0157 is set to OLD or NEW.

  • Risk:

Minimal. The changes were tested locally and will be tested on CI.

  • Testing:

Local testing + CI.

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.
@Steelskin Steelskin requested a review from a team as a code owner April 22, 2026 16:37
@Steelskin

Copy link
Copy Markdown
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.
@rintaro

rintaro commented Apr 30, 2026

Copy link
Copy Markdown
Member

@etcwilde would you review this?

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.

2 participants