aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-06-18 17:25:37 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-06-18 17:25:37 +0200
commiteef8d981398137e242decb3073289d0fb7725451 (patch)
tree823703f6f95a0b16f4818ab5d1b1529930f9bf87 /cmake
parent4e6d746514d3b7ef31cf4cd1ac5b48eb0e3cbe9e (diff)
Fix bug #542: fix detection of compiler version on systems without the head command.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/EigenTesting.cmake18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake
index 3780888af..d9e22ab1a 100644
--- a/cmake/EigenTesting.cmake
+++ b/cmake/EigenTesting.cmake
@@ -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)