summaryrefslogtreecommitdiffstats
path: root/Modules/GenerateExportHeader.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2012-02-24 16:48:02 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2012-02-24 16:48:02 (GMT)
commitc28e2769482c12da53a3c01ea45f9ae6cdc1de34 (patch)
treedd3c7f3c06bd655c1f685241204ad217f1f2d087 /Modules/GenerateExportHeader.cmake
parent4412fc0890ab4081432721b7578f9893f89406fd (diff)
downloadCMake-c28e2769482c12da53a3c01ea45f9ae6cdc1de34.zip
CMake-c28e2769482c12da53a3c01ea45f9ae6cdc1de34.tar.gz
CMake-c28e2769482c12da53a3c01ea45f9ae6cdc1de34.tar.bz2
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.
Diffstat (limited to 'Modules/GenerateExportHeader.cmake')
-rw-r--r--Modules/GenerateExportHeader.cmake37
1 files changed, 9 insertions, 28 deletions
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index e1dcb51..51ba6fc 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -154,34 +154,15 @@ endmacro()
macro(_test_compiler_hidden_visibility)
- if(CMAKE_COMPILER_IS_GNUCXX)
- exec_program(${CMAKE_C_COMPILER} ARGS --version
- OUTPUT_VARIABLE _gcc_version_info)
- string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]"
- _gcc_version "${_gcc_version_info}")
- # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the
- # patch level, handle this here:
- if(NOT _gcc_version)
- string(REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.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()
+ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2")
+ set(GCC_TOO_OLD TRUE)
+ message(WARNING "GCC version older than 4.2")
+ elseif(CMAKE_COMPILER_IS_GNUC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.2")
+ set(GCC_TOO_OLD TRUE)
+ message(WARNING "GCC version older than 4.2")
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
+ set(_INTEL_TOO_OLD TRUE)
+ message(WARNING "Intel compiler older than 12.0")
endif()