diff options
author | Brad King <brad.king@kitware.com> | 2019-05-16 18:32:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-05-16 18:41:04 (GMT) |
commit | 0723582208dda7da9815a319973eed596c61a44c (patch) | |
tree | 980e0328196164bf0a9521e5b26b8a0cc7bcef8b | |
parent | 086c51dc045c75662500b39da3341af83281d6df (diff) | |
download | CMake-0723582208dda7da9815a319973eed596c61a44c.zip CMake-0723582208dda7da9815a319973eed596c61a44c.tar.gz CMake-0723582208dda7da9815a319973eed596c61a44c.tar.bz2 |
Swift: Detect compiler version
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 7bf13fa..7036b93 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -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}" |