Merge branch 'release-4-5-patches' of git@git.gromacs.org:gromacs into release-4...
[gromacs/rigid-bodies.git] / cmake / gmxCheckGCCVersion.cmake
blob70e0764d11637a9c07fafab0fd9bb9c2c072ca3f
1 # Check GCC version and if any of the 4.1.x family compiler suites is found
2 # quit the build system generating process. 
4 # The GCC 4.1.x compilers contain an optimization related bug which might 
5 # results in code that exhibits incorrect behaviour and often leads to 
6 # exploding systems or crashes. 
8 # For further details see e.g. 
9 # https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/158799
11 # Szilard Pall (pszilard@cbr.su.se)
14 if(NOT GMX_DISABLE_GCC41_CHECK)
16 if(CMAKE_COMPILER_IS_GNUCC)
17     # if we have -dumpversion flag use that, otherwise try the --version
18     execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
19         RESULT_VARIABLE _gcc_dumpversion_res
20         OUTPUT_VARIABLE _gcc_dumpversion_out
21         OUTPUT_STRIP_TRAILING_WHITESPACE)
22     # if gcc returned with error the -dumpversion is not available 
23     if(${_gcc_dumpversion_res} EQUAL 0)
24         if(${_gcc_dumpversion_out} MATCHES ".*4\\.1\\.[0-9]+.*")
25             message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x 
26                 family (detected version: ${_gcc_dumpversion_out}). These compilers 
27                 contain an optimization related bug which might results in code that 
28                 exhibits incorrect behaviour and often leads to exploding systems or 
29                 crashes. To disable this check set GMX_DISABLE_GCC41_CHECK=YES.")
30         endif()
31     else()    
32         message(WARNING " The GCC compiler in use does not support the -dumpversion flag. 
33             Will attempt parsing the version from the \"gcc --version\" output.")        
34         execute_process(COMMAND ${CMAKE_C_COMPILER} --version
35             OUTPUT_VARIABLE _gcc_version_out
36             OUTPUT_STRIP_TRAILING_WHITESPACE)            
37         if("${_gcc_version_out}" MATCHES ".*4\\.1\\.[0-9]+.*")
38             message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x 
39                 family. These compiler  compilers contain an optimization related bug 
40                 which might results in code that exhibits incorrect behaviour and 
41                 often leads to exploding systems or crashes. To disable this check set 
42                 GMX_DISABLE_GCC41_CHECK=YES.")
43         endif()
44     endif()
45 endif()
47 endif()