diff options
author | Brad King <brad.king@kitware.com> | 2015-02-17 18:24:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-02-19 14:26:27 (GMT) |
commit | e6ebc814dfa022680038a3855eb1eee56f6015f0 (patch) | |
tree | ac39d7a1252716751f72ceb435fc1233cdc9f2a7 /Modules/CMakeDetermineFortranCompiler.cmake | |
parent | ec1ec47193fcab7084e8edd977d3bebd1e8c73cb (diff) | |
download | CMake-e6ebc814dfa022680038a3855eb1eee56f6015f0.zip CMake-e6ebc814dfa022680038a3855eb1eee56f6015f0.tar.gz CMake-e6ebc814dfa022680038a3855eb1eee56f6015f0.tar.bz2 |
Fortran: Add infrastructure to detect compiler version (#15372)
Fortran does not offer syntax to compose a string literal at
preprocessing time from numeric compuations. Instead encode each digit
of each component as a separate INFO string and compose them in CMake
code after extraction. Support MAJOR, MINOR, PATCH, and TWEAK
components with up to 8 digits each.
Diffstat (limited to 'Modules/CMakeDetermineFortranCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineFortranCompiler.cmake | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index a4bb86c..3a27127 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -119,6 +119,47 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) set(CMAKE_Fortran_COMPILER_ID_VENDOR_FLAGS_NAG "-V") set(CMAKE_Fortran_COMPILER_ID_VENDOR_REGEX_NAG "NAG Fortran Compiler") + set(_version_info "") + foreach(m MAJOR MINOR PATCH TWEAK) + set(_COMP "_${m}") + set(_version_info "${_version_info} +#if defined(COMPILER_VERSION${_COMP})") + foreach(d 1 2 3 4 5 6 7 8) + set(_version_info "${_version_info} +# undef DEC +# undef HEX +# define DEC(n) DEC_${d}(n) +# define HEX(n) HEX_${d}(n) +# if COMPILER_VERSION${_COMP} == 0 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[0]' +# elif COMPILER_VERSION${_COMP} == 1 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[1]' +# elif COMPILER_VERSION${_COMP} == 2 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[2]' +# elif COMPILER_VERSION${_COMP} == 3 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[3]' +# elif COMPILER_VERSION${_COMP} == 4 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[4]' +# elif COMPILER_VERSION${_COMP} == 5 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[5]' +# elif COMPILER_VERSION${_COMP} == 6 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[6]' +# elif COMPILER_VERSION${_COMP} == 7 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[7]' +# elif COMPILER_VERSION${_COMP} == 8 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[8]' +# elif COMPILER_VERSION${_COMP} == 9 + PRINT *, 'INFO:compiler_version${_COMP}_digit_${d}[9]' +# endif +") + endforeach() + set(_version_info "${_version_info} +#endif") + endforeach() + set(CMAKE_Fortran_COMPILER_ID_VERSION_INFO "${_version_info}") + unset(_version_info) + unset(_COMP) + # Try to identify the compiler. set(CMAKE_Fortran_COMPILER_ID) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) |