瀏覽代碼

CMake: Fix compile flag detection on old CMake

Max Bruckner 8 年之前
父節點
當前提交
2f712c7456
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      CMakeLists.txt

+ 8 - 1
CMakeLists.txt

@@ -33,7 +33,6 @@ if (ENABLE_CUSTOM_COMPILER_FLAGS)
         -Wmissing-prototypes
         -Wstrict-overflow=2
         -Wcast-qual
-        -Wc++-compat
         -Wundef
         -Wswitch-default
         -Wconversion
@@ -41,6 +40,14 @@ if (ENABLE_CUSTOM_COMPILER_FLAGS)
         )
 endif()
 
+# "I am starting to hate CMake" - FSMaxB
+# In older versions of CMake, testing for -Wc++-compat
+# fails because it cannot compile a regular expression
+# This seems to be a bug in the CheckCSourceCompiles module
+if (NOT (CMAKE_MAJOR_VERSION EQUAL 2))
+    list(APPEND custom_compiler_flags "-Wc++-compat")
+endif()
+
 # apply custom compiler flags
 foreach(compiler_flag ${custom_compiler_flags})
     CHECK_C_COMPILER_FLAG(${compiler_flag} "FLAG_SUPPORTED-${compiler_flag}")