diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeCCompilerId.c.in | 3 | ||||
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeCXXCompilerId.cpp.in | 3 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 18 | ||||
-rw-r--r-- | Modules/CMakePlatformId.h.in | 40 |
6 files changed, 64 insertions, 2 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 04a5cec..b14cf34 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -1,6 +1,7 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") SET(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@") SET(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@") +SET(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@") SET(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") @SET_MSVC_C_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index c91553a..dd3d2fd 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -109,6 +109,9 @@ int main(int argc, char* argv[]) require += info_compiler[argc]; require += info_platform[argc]; require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif (void)argv; return require; } diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index ea06526..bc3bc2e 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -1,6 +1,7 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") SET(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") SET(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") +SET(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") SET(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") @SET_MSVC_CXX_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 4c8f497..469290e 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -96,6 +96,9 @@ int main(int argc, char* argv[]) int require = 0; require += info_compiler[argc]; require += info_platform[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif (void)argv; return require; } diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index b160dee..686cc9b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -55,8 +55,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Display the final identification result. IF(CMAKE_${lang}_COMPILER_ID) + IF(CMAKE_${lang}_COMPILER_VERSION) + SET(_version " ${CMAKE_${lang}_COMPILER_VERSION}") + ELSE() + SET(_version "") + ENDIF() MESSAGE(STATUS "The ${lang} compiler identification is " - "${CMAKE_${lang}_COMPILER_ID}") + "${CMAKE_${lang}_COMPILER_ID}${_version}") ELSE(CMAKE_${lang}_COMPILER_ID) MESSAGE(STATUS "The ${lang} compiler identification is unknown") ENDIF(CMAKE_${lang}_COMPILER_ID) @@ -65,6 +70,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) #----------------------------------------------------------------------------- @@ -177,9 +183,10 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) IF(NOT CMAKE_${lang}_COMPILER_ID) # Read the compiler identification string from the executable file. SET(COMPILER_ID) + SET(COMPILER_VERSION) SET(PLATFORM_ID) FILE(STRINGS ${file} - CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 3 REGEX "INFO:") + CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 4 REGEX "INFO:") SET(HAVE_COMPILER_TWICE 0) FOREACH(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) IF("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*") @@ -197,6 +204,11 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) STRING(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1" ARCHITECTURE_ID "${info}") ENDIF("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") + IF("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") + STRING(REGEX REPLACE ".*INFO:compiler_version\\[([^]]*)\\].*" "\\1" COMPILER_VERSION "${info}") + STRING(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}") + STRING(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") + ENDIF("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") ENDFOREACH(info) # Check if a valid compiler and platform were found. @@ -204,6 +216,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) SET(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}") SET(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}") SET(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}") + SET(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}") ENDIF(COMPILER_ID AND NOT COMPILER_ID_TWICE) # Check the compiler identification string. @@ -251,6 +264,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index cb3f40a..b69bf63 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -105,6 +105,46 @@ # define ARCHITECTURE_ID "" #endif +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number components. */ +#ifdef COMPILER_VERSION_MAJOR +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the |