Files
swift-mirror/cmake/modules/SwiftImplicitImport.cmake
Rintaro Ishizaki d28e1c963c [CMake] Fix swift_supports_implicit_module failure
swift_supports_implicit_module invokes /path/to/toolchain/usr/bin/swiftc
directly without using `xcrun`. That fails to set necessary
environmental variables to make swiftc infer the SDK path. Because of
that swift_supports_implicit_module used to fail because the test
compilation fails to load the stdlib. This PR workaround it by passing
`-parse-stdlib` to avoid implicit stdlib loading.
2023-03-16 16:13:50 -07:00

22 lines
679 B
CMake

# Test if the Swift compiler supports -disable-implicit-<module>-module-import
function(swift_supports_implicit_module module_name out_var)
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-${module_name}.swift" "")
execute_process(
COMMAND
"${CMAKE_Swift_COMPILER}"
-Xfrontend -disable-implicit-${module_name}-module-import
-Xfrontend -parse-stdlib
-c - -o /dev/null
INPUT_FILE
"${CMAKE_BINARY_DIR}/tmp/empty-check-${module_name}.swift"
OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE
result
)
if(NOT result)
set("${out_var}" "TRUE" PARENT_SCOPE)
else()
set("${out_var}" "FALSE" PARENT_SCOPE)
endif()
endfunction()