From 6c33571b125b5f75189c4a1eef6a2f5c196e5f32 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 11 Nov 2024 17:12:47 +0100 Subject: [PATCH] Always compile with -Wsuggest-override not to forget `override` `override` indicates an override of a virtual method and refuses to compile in case of a signature mismatch across the inheritence hierarchy. This is especially useful when signatures change not to forget anything. Hence, we shall always use `override` whereever applicable. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24995c1f13e..d27a3338f77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,8 @@ set(CMAKE_MACOSX_RPATH 1) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_FULL_LIBDIR}/icinga2") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Winconsistent-missing-override") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics -fno-limit-debug-info") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -fno-limit-debug-info") @@ -249,6 +251,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "SunPro") endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wsuggest-override") + if(CMAKE_SYSTEM_NAME MATCHES AIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -lpthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -lpthread")