Skip to content

Commit 985651f

Browse files
committed
build: use -isystem on non-Darwin targets
The use of `-isysroot` is a Darwin specific behaviour. It is used to switch to a platform SDK, however, other targets use the `--sysroot` flag. Windows uses a custom mechanism which is a set of system header paths.
1 parent c404785 commit 985651f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,19 @@ function(_add_variant_c_compile_link_flags)
8585
${${CFLAGS_RESULT_VAR_NAME}}
8686
"-target" "${SWIFT_SDK_${CFLAGS_SDK}_ARCH_${CFLAGS_ARCH}_TRIPLE}")
8787

88-
list(APPEND result
89-
"-isysroot" "${SWIFT_SDK_${CFLAGS_SDK}_PATH}")
88+
if("${CFLAGS_SDK}" STREQUAL "OSX" OR
89+
"${CFLAGS_SDK}" STREQUAL "TVOS" OR
90+
"${CFLAGS_SDK}" STREQUAL "TVOS_SIMULATOR" OR
91+
"${CFLAGS_SDK}" STREQUAL "IOS" OR
92+
"${CFLAGS_SDK}" STREQUAL "IOS_SIMULATOR" OR
93+
"${CFLAGS_SDK}" STREQUAL "WATCHOS" OR
94+
"${CFLAGS_SDK}" STREQUAL "WATCHOS_SIMULATOR")
95+
list(APPEND result "-isysroot" "${SWIFT_SDK_${CFLAGS_SDK}_PATH}")
96+
else()
97+
if(NOT "${SWIFT_SDK_${CFLAGS_SDK}_PATH}" STREQUAL "/")
98+
list(APPEND result "--sysroot=${SWIFT_SDK_${CFLAGS_SDK}_PATH}")
99+
endif()
100+
endif()
90101

91102
if("${CFLAGS_SDK}" STREQUAL "ANDROID")
92103
list(APPEND result

0 commit comments

Comments
 (0)