GenerateExportHeader: improve compiler identification

Use CMAKE_<LANG>_COMPILER_VERSION instead of calling the compiler. This macro
predates those useful variables. This also fixes the issue that g++ version
detection was not working if C language was not enabled.
This commit is contained in:
Rolf Eike Beer 2012-02-24 17:48:02 +01:00
parent 4412fc0890
commit c28e276948
1 changed files with 9 additions and 28 deletions

View File

@ -154,34 +154,15 @@ endmacro()
macro(_test_compiler_hidden_visibility) macro(_test_compiler_hidden_visibility)
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2")
exec_program(${CMAKE_C_COMPILER} ARGS --version set(GCC_TOO_OLD TRUE)
OUTPUT_VARIABLE _gcc_version_info) message(WARNING "GCC version older than 4.2")
string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]" elseif(CMAKE_COMPILER_IS_GNUC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.2")
_gcc_version "${_gcc_version_info}") set(GCC_TOO_OLD TRUE)
# gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the message(WARNING "GCC version older than 4.2")
# patch level, handle this here: elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
if(NOT _gcc_version) set(_INTEL_TOO_OLD TRUE)
string(REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" message(WARNING "Intel compiler older than 12.0")
_gcc_version "${_gcc_version_info}")
endif()
if("${_gcc_version}" VERSION_LESS "4.2")
set(GCC_TOO_OLD TRUE)
message(WARNING "GCC version older than 4.2")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
exec_program(${CMAKE_CXX_COMPILER} ARGS -V
OUTPUT_VARIABLE _intel_version_info)
string(REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1"
_intel_version "${_intel_version_info}")
if(${_intel_version} VERSION_LESS "12.0")
set(_INTEL_TOO_OLD TRUE)
message(WARNING "Intel compiler older than 12.0")
endif()
endif() endif()