]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Keep cmake gcc builds in sync with autotools warnings.
authorRalf Habacker <ralf.habacker@freenet.de>
Thu, 26 Nov 2015 14:02:51 +0000 (15:02 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 11 Feb 2016 22:26:50 +0000 (23:26 +0100)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
cmake/CMakeLists.txt
cmake/modules/MacrosAutotools.cmake

index 977304a97e9647e377abd918e9a8d3af0052f9b8..d85a085e367bf0e2effffcf72f5deedbfc3bad9a 100644 (file)
@@ -206,8 +206,8 @@ if(MSVC)
     # 4133 'type' : incompatible types - from 'type1' to 'type2'
     set(WARNINGS_ERRORS "4002 4003 4013 4028 4031 4047 4114 4133")
 else()
-    set(WARNINGS "sign-compare")
-    set(WARNINGS_DISABLED "")
+    autocompilerwarnings(WARNINGS WARNINGS_DISABLED)
+    set(WARNINGS "${WARNINGS} sign-compare")
     set(WARNINGS_ERRORS "")
 endif()
 generate_warning_cflags(WARNINGS_CFLAGS "${WARNINGS}" "${WARNINGS_DISABLED}" "${WARNINGS_ERRORS}")
index 8bb83cdf36a09bd9c77ea1eb13fc2878dad22410..c333308e7f9c6378c4710bf9dd6a4606ef82fd0f 100644 (file)
@@ -116,6 +116,71 @@ macro(autodefine name)
     endforeach()
 endmacro()
 
+#
+# fetch compiler warnings settings from autotools
+#
+# @param target_warnings the variable name which will contain the warnings keys
+# @param target_disabled_warnings the variable name which will contain the disabled warnings keys
+#
+macro(autocompilerwarnings target_warnings target_disabled_warnings)
+    set(in_warnings 0)
+    set(content)
+    # parse configure_ac
+    foreach(line ${_configure_ac})
+        if(line MATCHES ".*TP_COMPILER_WARNINGS.*")
+            set(in_warnings 1)
+            string(REGEX REPLACE "^.*TP_COMPILER_WARNINGS\\((.*)$" "\\1" temp ${line})
+            set(content "${content}${temp}")
+        elseif(in_warnings EQUAL 1)
+            if(line MATCHES ".*dnl.*")
+                # skip
+            elseif(line MATCHES "\\)$")
+                string(REGEX REPLACE "(.*)\\)$" "\\1" temp ${line})
+                set(content "${content}${temp}")
+                set(in_warnings 2)
+            else()
+                string(STRIP ${line} _line)
+                if(NOT _line STREQUAL "")
+                    set(content "${content}${line}")
+                endif()
+            endif()
+        endif()
+    endforeach()
+
+    # extract macro parts
+    string(REPLACE ";" "#" temp ${content})
+    string(REPLACE "[" "" temp ${temp})
+    string(REPLACE "]" "" temp ${temp})
+    string(REPLACE "," ";" alist ${temp})
+    list(GET alist 0 flag_name)
+    list(GET alist 2 warnings_flag)
+    list(GET alist 3 no_warnings_flag)
+    string(REPLACE "#" ";" warnings_list ${warnings_flag})
+    string(REPLACE "#" ";" no_warnings_list ${no_warnings_flag})
+    list(REMOVE_AT no_warnings_list 0)
+
+    set(warnings)
+    foreach(warning ${warnings_list})
+        string(STRIP ${warning} _warning)
+        if(NOT _warning STREQUAL "")
+            set(warnings "${warnings} ${_warning}")
+        endif()
+    endforeach()
+    set(${target_warnings} "${warnings}")
+
+    set(warnings)
+    foreach(warning ${no_warnings_list})
+        string(STRIP ${warning} _warning)
+        if(NOT _warning STREQUAL "")
+            set(warnings "${warnings} ${_warning}")
+        endif()
+    endforeach()
+    set(${target_disabled_warnings} "${warnings}")
+    if(DEBUG_MACROS)
+        message("autocompilerwarnings returns: warnings: ${${target_warnings}} disabled_warnings: ${${target_disabled_warnings}}")
+    endif()
+endmacro()
+
 macro(autoheaderchecks config_h_in configure_checks_file config_h_cmake)
     file(READ ${configure_checks_file} configure_checks_file_raw)
     file(READ ${config_h_in} _config_h_in_raw)