From b72b027040bba76438b84aee21c2824008ec07cf Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Tue, 4 Jun 2024 08:58:48 +0200 Subject: [PATCH] fix(ci): Enable -Werror when building with clazy This should fail CI if a warning is generated by clazy, as to the previous state, where it simply quietly continued. --- CMakeLists.txt | 1 + CMakePresets.json | 9 ++++++--- src/kdbindings/CMakeLists.txt | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 568df90..9f57d74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ include(FeatureSummary) option(${PROJECT_NAME}_TESTS "Build the tests" ON) option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON) option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF) +option(${PROJECT_NAME}_ERROR_ON_WARNING "Enable all compiler warnings and treat them as errors" OFF) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules) diff --git a/CMakePresets.json b/CMakePresets.json index e8cfa14..39e1280 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -10,7 +10,8 @@ "CMAKE_BUILD_TYPE": "Debug", "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON", "KDBindings_TESTS" : "ON", - "KDBindings_EXAMPLES" : "ON" + "KDBindings_EXAMPLES" : "ON", + "KDBindings_ERROR_ON_WARNING": "ON" } }, { @@ -23,7 +24,8 @@ "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON", "KDBindings_TESTS" : "ON", "KDBindings_EXAMPLES" : "ON", - "KDBindings_DOCS" : "ON" + "KDBindings_DOCS" : "ON", + "KDBindings_ERROR_ON_WARNING": "ON" } }, { @@ -35,7 +37,8 @@ "CMAKE_BUILD_TYPE": "Debug", "CMAKE_CXX_COMPILER" : "clazy", "KDBindings_TESTS" : "ON", - "KDBindings_EXAMPLES" : "ON" + "KDBindings_EXAMPLES" : "ON", + "KDBindings_ERROR_ON_WARNING" : "ON" }, "warnings": { "uninitialized": true diff --git a/src/kdbindings/CMakeLists.txt b/src/kdbindings/CMakeLists.txt index dead006..9cbdfd5 100644 --- a/src/kdbindings/CMakeLists.txt +++ b/src/kdbindings/CMakeLists.txt @@ -37,6 +37,13 @@ target_include_directories(KDBindings INTERFACE $ $ ) +if(KDBindings_ERROR_ON_WARNING) + if(MSVC) + target_compile_options(KDBindings INTERFACE /W4 /WX) + else() + target_compile_options(KDBindings INTERFACE -Wall -Wextra -Wpedantic -Werror) + endif() +endif() # Generate library version files include(ECMSetupVersion)