Files
swift-mirror/cmake/modules/SwiftImplicitImport.cmake
Eric Miotto 5b69b93858 Ensure module tracing is off when checking disable-implicit* flags (#68453)
In some internal configurations we set the
`SWIFT_LOADED_MODULE_TRACE_FILE` environment variable when running the
build of the compiler -- as a result, this causes `-parse` to always
fails, preventing to detect properly if we can use `disable-implicit*`
flags.

Addresses rdar://115338219
2023-09-12 23:20:08 -07:00

24 lines
745 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_COMMAND}
-E env --unset=SWIFT_LOADED_MODULE_TRACE_FILE
"${CMAKE_Swift_COMPILER}"
-Xfrontend -disable-implicit-${module_name}-module-import
-Xfrontend -parse-stdlib
-parse -
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()