From 4d5425e86e2b987bd54f79b27f0babf3ede5527d Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Fri, 17 May 2024 19:09:49 +0200 Subject: [PATCH 1/4] Actions: Use Aseprite version of get-ninja Due to https://github.com/turtlesec-no/get-ninja/issues/4 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e587b25..e89d4c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v4 - name: Install ninja-build tool - uses: turtlesec-no/get-ninja@main + uses: aseprite/get-ninja@main - name: Make sure MSVC is found when Ninja generator is in use uses: ilammy/msvc-dev-cmd@v1 From 0ae98e61d92b064eaa724333a2a3609e3ad1dd2a Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Tue, 4 Jun 2024 08:58:48 +0200 Subject: [PATCH 2/4] 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..ac7c610 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 /W3 /WX) + else() + target_compile_options(KDBindings INTERFACE -Wall -Wextra -Wpedantic -Werror) + endif() +endif() # Generate library version files include(ECMSetupVersion) From f33778b1eda0a87dd61d5d1e3bb6b171cd66f92b Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Tue, 4 Jun 2024 09:08:34 +0200 Subject: [PATCH 3/4] fix(clazy): Ignore warnings generated by doctest --- tests/binding/tst_binding.cpp | 4 ++++ tests/node/tst_node.cpp | 13 ++++++++----- tests/property/tst_property.cpp | 4 ++++ tests/signal/tst_signal.cpp | 4 ++++ tests/utils/tst_gen_index_array.cpp | 4 ++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/binding/tst_binding.cpp b/tests/binding/tst_binding.cpp index 22010d1..beaf943 100644 --- a/tests/binding/tst_binding.cpp +++ b/tests/binding/tst_binding.cpp @@ -22,6 +22,10 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +// The expansion of TEST_CASE from doctest leads to a clazy warning. +// As this issue originates from doctest, disable the warning. +// clazy:excludeall=non-pod-global-static + using namespace KDBindings; static_assert(std::is_destructible>{}); diff --git a/tests/node/tst_node.cpp b/tests/node/tst_node.cpp index 1748a4a..b5ccbe5 100644 --- a/tests/node/tst_node.cpp +++ b/tests/node/tst_node.cpp @@ -19,6 +19,10 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +// The expansion of TEST_CASE from doctest leads to a clazy warning. +// As this issue originates from doctest, disable the warning. +// clazy:excludeall=non-pod-global-static + using namespace KDBindings; static_assert(std::is_destructible>{}); @@ -404,15 +408,14 @@ TEST_CASE("bindable_value_type and operator_node") REQUIRE(node2.evaluate() == (OP(OP(VALUE)))); \ } -TEST_CASE("Test unary operators") -{ +TEST_CASE("Test unary operators"){ KDBINDINGS_UNARY_OPERATOR_TEST(!, bool, true) - KDBINDINGS_UNARY_OPERATOR_TEST(~, uint8_t, 25) + KDBINDINGS_UNARY_OPERATOR_TEST(~, uint8_t, 25) - KDBINDINGS_UNARY_OPERATOR_TEST(+, int, -10) + KDBINDINGS_UNARY_OPERATOR_TEST(+, int, -10) - KDBINDINGS_UNARY_OPERATOR_TEST(-, int, 10) + KDBINDINGS_UNARY_OPERATOR_TEST(-, int, 10) } #define KDBINDINGS_BINARY_OPERATOR_TEST(OP, TYPE, VALUE, OTHER) \ diff --git a/tests/property/tst_property.cpp b/tests/property/tst_property.cpp index 798eba4..3676da5 100644 --- a/tests/property/tst_property.cpp +++ b/tests/property/tst_property.cpp @@ -16,6 +16,10 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +// The expansion of TEST_CASE from doctest leads to a clazy warning. +// As this issue originates from doctest, disable the warning. +// clazy:excludeall=non-pod-global-static + using namespace KDBindings; static_assert(std::is_nothrow_destructible>{}); diff --git a/tests/signal/tst_signal.cpp b/tests/signal/tst_signal.cpp index f0b5a2d..71f5cbf 100644 --- a/tests/signal/tst_signal.cpp +++ b/tests/signal/tst_signal.cpp @@ -20,6 +20,10 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +// The expansion of TEST_CASE from doctest leads to a clazy warning. +// As this issue originates from doctest, disable the warning. +// clazy:excludeall=non-pod-global-static + using namespace KDBindings; static_assert(std::is_nothrow_destructible>{}); diff --git a/tests/utils/tst_gen_index_array.cpp b/tests/utils/tst_gen_index_array.cpp index 1939d8d..667ad0c 100644 --- a/tests/utils/tst_gen_index_array.cpp +++ b/tests/utils/tst_gen_index_array.cpp @@ -15,6 +15,10 @@ #include +// The expansion of TEST_CASE from doctest leads to a clazy warning. +// As this issue originates from doctest, disable the warning. +// clazy:excludeall=non-pod-global-static + using namespace KDBindings::Private; static_assert(std::is_nothrow_destructible>{}); From 273cb8da018dac4e134204e44b49d8b0d08708e6 Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Tue, 4 Jun 2024 09:26:01 +0200 Subject: [PATCH 4/4] feat(preset): Add clazy test preset --- CMakePresets.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index 39e1280..c3ffffc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -97,6 +97,12 @@ "configurePreset": "dev", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": false} + }, + { + "name": "clazy", + "configurePreset": "clazy", + "output": {"outputOnFailure": true}, + "execution": {"noTestsAction": "error", "stopOnFailure": false} } ] }