From 47e9467c59a915d25bd50265a1ecb17d72038eed Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Mon, 3 Mar 2025 09:28:06 -0800 Subject: [PATCH] Set CMP0157 to OLD only for Windows hosts - **Explanation**: There is no early swift-driver build for the Windows toolchain. As a result, swift-collections fails to build properly when CMP0157 is set to NEW due to object files not being generated. This sets CMP0157 to OLD when targetting Android until the early swift-driver is available on Windows. - **Scope**: The changes are limited to the Android build on Windows. - **Issues**: - swiftlang/swift-foundation#1222 - **Original PRs**: #5180 - **Risk**: Very low. - **Testing**: Fixes the Swift CI 6.1 build. - **Reviewers**: @finagolfin --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 265c9d3de7..c0d46e43cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,15 @@ if(POLICY CMP0156) endif() if(POLICY CMP0157) - # New Swift build model: improved incremental build performance and LSP support - cmake_policy(SET CMP0157 NEW) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND CMAKE_SYSTEM_NAME STREQUAL Android) + # CMP0157 causes swift-collections to fail to compile when targetting + # Android on Windows due to swift-driver not being present during the + # toolchain build. Disable it for now. + cmake_policy(SET CMP0157 OLD) + else() + # New Swift build model: improved incremental build performance and LSP support + cmake_policy(SET CMP0157 NEW) + endif() endif() if (NOT DEFINED CMAKE_C_COMPILER)