Skip to content

Commit e91d835

Browse files
authored
Cmake Analyzers (flameshot-org#4613)
* Add Qt deprecation check * Add Analyzer status message * Fix cppcheck
1 parent 9dfdab8 commit e91d835

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ include(cmake/CompilerWarnings.cmake)
112112
include(cmake/Sanitizers.cmake)
113113
enable_sanitizers(project_options)
114114

115-
# allow for static analysis options include(cmake/StaticAnalyzers.cmake)
116-
117115
if(USE_KDSINGLEAPPLICATION)
118116
if(USE_BUNDLED_KDSINGLEAPPLICATION)
119117
set(KDSingleApplication_EXAMPLES OFF CACHE BOOL "Don't build the examples")
@@ -135,6 +133,10 @@ if(USE_KDSINGLEAPPLICATION)
135133
endif()
136134
endif()
137135

136+
# allow for static analysis options (include after kdsingleApplication because
137+
# of potential conflict if ENABLE_QT_DEPRECATION_CHECK is used)
138+
include(cmake/StaticAnalyzers.cmake)
139+
138140
# ToDo: Check if this is used anywhere
139141
option(BUILD_STATIC_LIBS ON)
140142

cmake/StaticAnalyzers.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
option(ENABLE_CPPCHECK "Enable static analysis with cppcheck" OFF)
22
option(ENABLE_CLANG_TIDY "Enable static analysis with clang-tidy" OFF)
33
option(ENABLE_INCLUDE_WHAT_YOU_USE "Enable static analysis with include-what-you-use" OFF)
4+
set(ENABLE_QT_DEPRECATION_CHECK "" CACHE STRING "Define hex value (e.g. 0x061100 for Qt 6.11) for testing for deprecations. Empty = OFF")
45

56
if(ENABLE_CPPCHECK)
67
find_program(CPPCHECK cppcheck)
78
if(CPPCHECK)
9+
message(STATUS "CPPCHECK is enabled!")
810
set(CMAKE_CXX_CPPCHECK
911
${CPPCHECK}
12+
--library=qt
1013
--suppress=missingInclude
1114
--enable=all
1215
--inline-suppr
13-
--inconclusive
14-
-i
15-
${CMAKE_SOURCE_DIR}/imgui/lib)
16+
--inconclusive)
1617
else()
1718
message(SEND_ERROR "cppcheck requested but executable not found")
1819
endif()
@@ -21,6 +22,7 @@ endif()
2122
if(ENABLE_CLANG_TIDY)
2223
find_program(CLANGTIDY clang-tidy)
2324
if(CLANGTIDY)
25+
message(STATUS "CLANGTIDY is enabled!")
2426
set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-Wno-unknown-warning-option)
2527
else()
2628
message(SEND_ERROR "clang-tidy requested but executable not found")
@@ -30,8 +32,14 @@ endif()
3032
if(ENABLE_INCLUDE_WHAT_YOU_USE)
3133
find_program(INCLUDE_WHAT_YOU_USE include-what-you-use)
3234
if(INCLUDE_WHAT_YOU_USE)
35+
message(STATUS "INCLUDE_WHAT_YOU_USE is enabled!")
3336
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE})
3437
else()
3538
message(SEND_ERROR "include-what-you-use requested but executable not found")
3639
endif()
3740
endif()
41+
42+
if(NOT "${ENABLE_QT_DEPRECATION_CHECK}" STREQUAL "")
43+
message(STATUS "Qt deprecations warnings enabled for: ${ENABLE_QT_DEPRECATION_CHECK}")
44+
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=${ENABLE_QT_DEPRECATION_CHECK})
45+
endif()

0 commit comments

Comments
 (0)