Skip to content

Commit 0ad7ca6

Browse files
committed
chore(cmake): refactor handling of clang-tidy
1 parent e390d6c commit 0ad7ca6

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ endif()
130130

131131
find_package(Threads REQUIRED)
132132

133+
include(cmake/clang-tidy.cmake) # Static analysis with clang-tidy
134+
133135
#-------------------------------
134136
# SOURCE FILES CONFIGURATION
135137
#-------------------------------
@@ -265,26 +267,6 @@ if(SDBUSCPP_BUILD_DOCS)
265267
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/docs")
266268
endif()
267269

268-
#----------------------------------
269-
# STATIC ANALYSIS
270-
#----------------------------------
271-
272-
if(SDBUSCPP_CLANG_TIDY)
273-
message(STATUS "Building with static analysis")
274-
find_program(CLANG_TIDY NAMES clang-tidy)
275-
if(NOT CLANG_TIDY)
276-
message(WARNING "clang-tidy not found")
277-
else()
278-
message(STATUS "clang-tidy found: ${CLANG_TIDY}")
279-
# TODO: Check what happens if the targets don't exist
280-
set_target_properties(sdbus-c++-objlib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
281-
set_target_properties(sdbus-c++ PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
282-
set_target_properties(sdbus-c++-unit-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
283-
#set_target_properties(sdbus-c++-integration-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
284-
set_target_properties(sdbus-c++-stress-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
285-
endif()
286-
endif()
287-
288270
#----------------------------------
289271
# CMAKE CONFIG & PACKAGE CONFIG
290272
#----------------------------------

cmake/clang-tidy.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#----------------------------------
2+
# STATIC ANALYSIS
3+
#----------------------------------
4+
5+
if(SDBUSCPP_CLANG_TIDY)
6+
message(STATUS "Building with static analysis")
7+
find_program(CLANG_TIDY NAMES clang-tidy)
8+
if(NOT CLANG_TIDY)
9+
message(WARNING "clang-tidy not found")
10+
else()
11+
message(STATUS "clang-tidy found: ${CLANG_TIDY}")
12+
set(DO_CLANG_TIDY "${CLANG_TIDY}")
13+
#set(DO_CLANG_TIDY "${CLANG_TIDY}" "-fix")
14+
set(CMAKE_CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
15+
endif()
16+
endif()

0 commit comments

Comments
 (0)