cmake: Add check for GCC 4.5.1 and warn user. (#2533)
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 26 Sep 2018 00:33:48 +0000 (17:33 -0700)
committerAina Niemetz <aina.niemetz@gmail.com>
Wed, 26 Sep 2018 00:33:48 +0000 (17:33 -0700)
CMakeLists.txt

index 453f1bcf73e18fb44f4deed97cfa38c17e5015a5..3eced0885127f80c0b1969e846714cb593f9037f 100644 (file)
@@ -216,6 +216,24 @@ endif()
 # allow calling ctest from the root build directory.
 enable_testing()
 
+#-----------------------------------------------------------------------------#
+# Check GCC version.
+#
+# GCC version 4.5.1 builds MiniSat incorrectly with -O2, which results in
+# incorrect answers.
+
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+  execute_process(
+    COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
+    OUTPUT_VARIABLE GCC_VERSION
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(GCC_VERSION VERSION_EQUAL "4.5.1")
+    message(FATAL_ERROR
+      "GCC 4.5.1's optimizer is known to build MiniSat incorrectly "
+      "(and by extension CVC4).")
+  endif()
+endif()
+
 #-----------------------------------------------------------------------------#
 # Check options, find packages and configure build.