From 15a0102a97cf20b2f95571992d4febcdbdea2932 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Fri, 18 Apr 2025 21:03:59 -0700 Subject: [PATCH 1/2] CMake4.0 Fixes: Only pass sdk to swift when set CMake 4.0 does not specify CMAKE_OSX_SYSROOT unless it is set explicitly. When this is the case, passing the `-sdk` flag with an empty path confuses the compiler and results in build failures. This patch fixes things to only pass the sdk to the Swift compiler when the SDK is actually set. --- 3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake | 6 +++--- .../cmake/modules/InitializeSwift.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake b/3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake index 38b20e8..618ee2f 100644 --- a/3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake +++ b/3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake @@ -34,11 +34,11 @@ function(_swift_generate_cxx_header target header) list(TRANSFORM ARG_SEARCH_PATHS PREPEND "-I") endif() - if(APPLE) + if(APPLE AND CMAKE_OSX_SYSROOT) set(SDK_FLAGS "-sdk" "${CMAKE_OSX_SYSROOT}") elseif(WIN32) set(SDK_FLAGS "-sdk" "$ENV{SDKROOT}") - elseif(DEFINED ${CMAKE_SYSROOT}) + elseif(CMAKE_SYSROOT) set(SDK_FLAGS "-sdk" "${CMAKE_SYSROOT}") endif() @@ -54,7 +54,7 @@ function(_swift_generate_cxx_header target header) DEPENDS ${_SwiftSources} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND - ${CMAKE_Swift_COMPILER} -frontend -typecheck + ${CMAKE_Swift_COMPILER} -typecheck ${ARG_SEARCH_PATHS} ${_SwiftSources} ${SDK_FLAGS} diff --git a/3_bidirectional_cxx_interop/cmake/modules/InitializeSwift.cmake b/3_bidirectional_cxx_interop/cmake/modules/InitializeSwift.cmake index b3f4390..c4fa2ea 100644 --- a/3_bidirectional_cxx_interop/cmake/modules/InitializeSwift.cmake +++ b/3_bidirectional_cxx_interop/cmake/modules/InitializeSwift.cmake @@ -26,7 +26,7 @@ endfunction() function(_setup_swift_paths) # If we haven't set the swift library search paths, do that now if(NOT SWIFT_LIBRARY_SEARCH_PATHS) - if(APPLE) + if(CMAKE_OSX_SYSROOT) set(SDK_FLAGS "-sdk" "${CMAKE_OSX_SYSROOT}") endif() From 18ed217997923be708bd4483f52830c6a93a09e5 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Sun, 4 May 2025 14:17:49 -0700 Subject: [PATCH 2/2] Add CMake 4.0.1 to test set Adding CMake 4.0.1, the most recent CMake release, to the set of tested CMake versions. --- .github/workflows/pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 778038e..09fd592 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,6 +22,8 @@ jobs: hash: 2dd48ccd3e3d872ee4cc916f3f4e24812612421007e895f82bf9fc7e49831d62 - version: 3.30.8 hash: adc81f2944e6f86b44e86acea3abea1651ed7890206933484b8b74ac1280314f + - version: 4.0.1 + hash: d66c11c010588c8256ee20a26b45977cd5b2f4aee2b742d4b8a353769940d147 steps: - name: Clone Repo uses: actions/checkout@v4