From 00df1355470cc6e75b1f0970938fb8d4904e6454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Mon, 10 Mar 2025 20:07:56 +0100 Subject: [PATCH] [CMake] Set CMP0157 to OLD when targeting Android with the Windows toolchain (#1009) There is no early swift-driver build for the Windows toolchain. As a result, swift-testing fails to build properly when CMP0157 is set to NEW due to object files not being generated. This sets CMP0157 to OLD when targeting Android with the Windows toolchain until the early swift-driver is available on Windows. This is analog to https://github.com/swiftlang/swift-corelibs-foundation/pull/5180 ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated. (cherry picked from commit a5dfbc2507eb7b745f164ec52bc5f6d92b9c38e3) --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1be9a4bed..aa20b9792 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,14 @@ cmake_minimum_required(VERSION 3.19.6...3.29) if(POLICY CMP0157) - cmake_policy(SET CMP0157 NEW) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND CMAKE_SYSTEM_NAME STREQUAL Android) + # CMP0157 causes builds to fail when targetting Android with the Windows + # toolchain, because the early swift-driver isn't (yet) available. Disable + # it for now. + cmake_policy(SET CMP0157 OLD) + else() + cmake_policy(SET CMP0157 NEW) + endif() endif() project(SwiftTesting