Swift: Detect compiler version

This commit is contained in:
Brad King
2019-05-16 14:32:35 -04:00
parent 086c51dc04
commit 0723582208

View File

@@ -84,6 +84,30 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endif()
endif()
# For Swift we need to explicitly query the version.
if(lang STREQUAL "Swift"
AND CMAKE_${lang}_COMPILER
AND NOT CMAKE_${lang}_COMPILER_VERSION)
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}"
-version
OUTPUT_VARIABLE output ERROR_VARIABLE output
RESULT_VARIABLE result
TIMEOUT 10
)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
"${output}\n"
)
if(output MATCHES [[Swift version ([0-9]+\.[0-9]+(\.[0-9]+)?)]])
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}")
if(NOT CMAKE_${lang}_COMPILER_ID)
set(CMAKE_Swift_COMPILER_ID "Apple")
endif()
endif()
endif()
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}"