Skip to content

Commit

Permalink
fix(ci): Enable -Werror when building with clazy
Browse files Browse the repository at this point in the history
This should fail CI if a warning is generated by clazy, as to the
previous state, where it simply quietly continued.
  • Loading branch information
LeonMatthesKDAB committed Jun 4, 2024
1 parent 4d5425e commit b72b027
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand All @@ -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"
}
},
{
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/kdbindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ target_include_directories(KDBindings INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>
)
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)
Expand Down

0 comments on commit b72b027

Please sign in to comment.