Skip to content

Commit 492a703

Browse files
committed
Fix build break with cmake 4.0
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.
1 parent 027916b commit 492a703

File tree

1 file changed

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

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ if (NOT SWIFT_COMPILER_TARGET)
5050
set(SWIFT_OPTIMIZATION_FLAG "-O")
5151
endif()
5252

53+
5354
if (CLR_CMAKE_TARGET_MACCATALYST)
5455
# this is set in configurecompiler.cmake
5556
set(SWIFT_COMPILER_TARGET ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET})
@@ -77,9 +78,14 @@ if (NOT SWIFT_COMPILER_TARGET)
7778
endif()
7879
endif()
7980

81+
set(SWIFT_SDK_FLAG "")
82+
if (CMAKE_OSX_SYSROOT)
83+
set(SWIFT_SDK_FLAG -sdk ${CMAKE_OSX_SYSROOT})
84+
endif()
85+
8086
add_custom_command(
8187
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
88+
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
8389
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift
8490
COMMENT "Compiling Swift file pal_swiftbindings.swift"
8591
)

0 commit comments

Comments
 (0)