mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
Swift: Detect compiler version
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user