From 1c5dfc58ea9b3786e40d6e989637057897f7aa26 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 117135113c0..f6b297b5a11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,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") @@ -256,6 +258,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")