Fix bug #542: fix detection of compiler version on systems without the head command.

This commit is contained in:
Gael Guennebaud 2013-06-18 17:25:37 +02:00
parent 4e6d746514
commit eef8d98139

View File

@ -322,13 +322,21 @@ macro(ei_get_compilerver VAR)
endif()
else()
# on all other system we rely on ${CMAKE_CXX_COMPILER}
# supporting a "--version" flag
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
COMMAND head -n 1
OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
# supporting a "--version" flag
ei_get_compilerver_from_cxx_version_string(${eigen_cxx_compiler_version_string} CNAME CVER)
# check whether the head command exists
find_program(HEAD_EXE head NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH)
if(HEAD_EXE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
COMMAND head -n 1
OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string})
endif()
ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER)
set(${VAR} "${CNAME}-${CVER}")
endif()
endmacro(ei_get_compilerver)