option(GMX_IA32_ASM "Add SSE assembly files for IA32" OFF)
option(GMX_X86_64_ASM "Add SSE assembly files for X86_64" OFF)
option(USE_VERSION_H "Generate development version string/information" ON)
+option(GMX_DISABLE_GCC41_CHECK "Disable check for (buggy) gcc 4.1.x" OFF)
#######################################################################
# Check for options incompatible with OpenMM build #
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+# check for buggy GCC 4.1.x
+include(gmxCheckGCCVersion)
+
include(gmxCFlags)
gmx_c_flags()
--- /dev/null
+# Check GCC version and if any of the 4.1.x family compiler suites is found
+# quit the build system generating process.
+#
+# The GCC 4.1.x compilers contain an optimization related bug which might
+# results in code that exhibits incorrect behaviour and often leads to
+# exploding systems or crashes.
+#
+# For further details see e.g.
+# https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/158799
+#
+# Szilard Pall (pszilard@cbr.su.se)
+#
+
+if(NOT GMX_DISABLE_GCC41_CHECK)
+
+if(CMAKE_COMPILER_IS_GNUCC)
+ # if we have -dumpversion flag use that, otherwise try the --version
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ RESULT_VARIABLE _gcc_dumpversion_res
+ OUTPUT_VARIABLE _gcc_dumpversion_out
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ # if gcc returned with error the -dumpversion is not available
+ if(${_gcc_dumpversion_res} EQUAL 0)
+ if(${_gcc_dumpversion_out} MATCHES ".*4\\.1.*")
+ message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x
+ family (detected version: ${_gcc_dumpversion_out}). These compilers
+ contain an optimization related bug which might results in code that
+ exhibits incorrect behaviour and often leads to exploding systems or
+ crashes. To disable this check set GMX_DISABLE_GCC41_CHECK=YES.")
+ endif()
+ else()
+ message(WARNING " The GCC compiler in use does not support the -dumpversion flag.
+ Will attempt parsing the version from the \"gcc --version\" output.")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} --version
+ OUTPUT_VARIABLE _gcc_version_out
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if("${_gcc_version_out}" MATCHES ".*4\\.1.*")
+ message(FATAL_ERROR " The GCC compiler in use seems to belong to the 4.1.x
+ family. These compiler compilers contain an optimization related bug
+ which might results in code that exhibits incorrect behaviour and
+ often leads to exploding systems or crashes. To disable this check set
+ GMX_DISABLE_GCC41_CHECK=YES.")
+ endif()
+ endif()
+endif()
+
+endif()