Skip to content

Commit a9c314d

Browse files
Fix build break with cmake 4.0 (#114278)
cmake 4.0 no longer sets the CMAKE_OSX_SYSROOT variable for macOS targets: https://cmake.org/cmake/help/v4.0/release/4.0.html#other-changes > Builds targeting macOS no longer choose any SDK or pass an -isysroot flag to the compiler by default. Instead, compilers are expected to choose a default macOS SDK on their own. In order to use a compiler that does not do this, users must now specify -DCMAKE_OSX_SYSROOT=macosx when configuring their build. We need to stop passing the variable to swiftc in that case and rely on the default behavior. Co-authored-by: Alexander Köplinger <[email protected]>
1 parent 5c4ffe3 commit a9c314d

File tree

1 file changed

+6
-1
lines changed
  • src/native/libs/System.Security.Cryptography.Native.Apple

1 file changed

+6
-1
lines changed

src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ if (NOT SWIFT_COMPILER_TARGET)
7777
endif()
7878
endif()
7979

80+
set(SWIFT_SDK_FLAG "")
81+
if (CMAKE_OSX_SYSROOT)
82+
set(SWIFT_SDK_FLAG -sdk ${CMAKE_OSX_SYSROOT})
83+
endif()
84+
8085
add_custom_command(
8186
OUTPUT pal_swiftbindings.o
82-
COMMAND xcrun swiftc -emit-object -static -parse-as-library -enable-library-evolution -g ${SWIFT_OPTIMIZATION_FLAG} -runtime-compatibility-version none -sdk ${CMAKE_OSX_SYSROOT} -target ${SWIFT_COMPILER_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift -o pal_swiftbindings.o
87+
COMMAND xcrun swiftc -emit-object -static -parse-as-library -enable-library-evolution -g ${SWIFT_OPTIMIZATION_FLAG} -runtime-compatibility-version none ${SWIFT_SDK_FLAG} -target ${SWIFT_COMPILER_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift -o pal_swiftbindings.o
8388
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift
8489
COMMENT "Compiling Swift file pal_swiftbindings.swift"
8590
)

0 commit comments

Comments
 (0)