From 21a4a675dd74167552e6c78de432cd627e395481 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Tue, 17 May 2022 15:10:41 +0200 Subject: [PATCH] cmake/gcc: disable [-Werror=maybe-uninitialized] for GCC >= 12.1.0 With GCC 12.1.0 there are numerous false-positive warnings on "maybe uninitialized" variables. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 664cadb94..694b6373a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -540,6 +540,12 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") endif() +# GCC >= 12.1.0: Disable analysis on "maybe-uninitialized" variables because of the high false-positive rate +if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-maybe-uninitialized") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized") +endif() + if(CMAKE_C_COMPILER_ID MATCHES "GNU") # Increase inlining limit to allow gcc compilation on e.g. RPi2 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --param large-function-growth=1600")