Merge "removed group non-boneded call with verlet scheme" into release-4-6
[alexxy/gromacs.git] / cmake / gmxGetCompilerVersion.cmake
1 # This macro attempts to parse the version string of the C compiler in use.
2 # Currently supported are only compilers that accept "-dumpversion" argument:
3 # gcc, Intel Compiler (on Linux and Mac OS), Open64, EkoPath.
4 #
5 # C_COMPILER_VERSION    - version string of the current C compiler (CMAKE_C_COMPILER)
6 # CXX_COMPILER_VERSION  - version string of the current C++ compiler (CMAKE_CXX_COMPILER)
7 #
8 macro(get_compiler_version)
9     if(NOT C_COMPILER_VERSION)
10         execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
11             RESULT_VARIABLE _cc_dumpversion_res
12             OUTPUT_VARIABLE _cc_dumpversion_out
13             ERROR_VARIABLE  _cc_dumpversion_err
14             OUTPUT_STRIP_TRAILING_WHITESPACE)
15
16         if (${_cc_dumpversion_res} EQUAL 0)
17             SET(C_COMPILER_VERSION ${_cc_dumpversion_out}
18                 CACHE STRING "C compiler verstion string" FORCE)
19         else ()
20             SET(C_COMPILER_VERSION ""
21                 CACHE STRING "C compiler verstion string not available" FORCE)
22         endif ()
23     endif()
24
25     if(NOT CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_LOADED)
26         execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
27             RESULT_VARIABLE _cxx_dumpversion_res
28             OUTPUT_VARIABLE _cxx_dumpversion_out
29             ERROR_VARIABLE  _cxx_dumpversion_err
30             OUTPUT_STRIP_TRAILING_WHITESPACE)
31
32         if (${_cxx_dumpversion_res} EQUAL 0)
33             SET(CXX_COMPILER_VERSION ${_cxx_dumpversion_out}
34                 CACHE STRING "C++ compiler verstion string" FORCE)
35         else ()
36             SET(CXX_COMPILER_VERSION ""
37                 CACHE STRING "C++ compiler verstion string not available" FORCE)
38         endif ()
39     endif ()
40
41     if (NOT "${C_COMPILER_VERSION}" STREQUAL "${CXX_COMPILER_VERSION}" AND CMAKE_CXX_COMPILER_LOADED)
42         message(WARNING "The version string of the C and C++ compilers does not match!")
43     endif ()
44
45     mark_as_advanced(C_COMPILER_VERSION CXX_COMPILER_VERSION)
46 endmacro()