-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
tidy
target for running clang-tidy
- Loading branch information
1 parent
fe8d8a9
commit 3316223
Showing
5 changed files
with
102 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Checks: > | ||
bugprone-*, | ||
clang-analyzer-*, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-narrowing-conversions, | ||
-clang-analyzer-core.NonNullParamChecker, | ||
-clang-analyzer-security.insecureAPI.strcpy, | ||
HeaderFilterRegex: '.*' | ||
WarningsAsErrors: '*' | ||
UseColor: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Check executable exists | ||
if(NOT EXISTS ${CLANG_TIDY_EXECUTABLE}) | ||
find_program(CLANG_TIDY_EXEC_TEMP ${CLANG_TIDY_EXECUTABLE}) | ||
if(CLANG_TIDY_EXEC_TEMP) | ||
set(CLANG_TIDY_EXECUTABLE ${CLANG_TIDY_EXEC_TEMP}) | ||
unset(CLANG_TIDY_EXEC_TEMP) | ||
else() | ||
message(FATAL_ERROR "Unable to find clang-tidy executable: \"${CLANG_TIDY_EXECUTABLE}\"") | ||
endif() | ||
endif() | ||
|
||
# Check executable version | ||
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_TIDY_VERSION) | ||
string(REGEX MATCH "version ([0-9]+)" CLANG_TIDY_VERSION ${CLANG_TIDY_VERSION}) | ||
unset(CLANG_TIDY_VERSION) | ||
if(CMAKE_MATCH_1 GREATER_EQUAL 14) | ||
message(STATUS "Using clang-tidy version ${CMAKE_MATCH_1}") | ||
else() | ||
message(FATAL_ERROR "clang-tidy version ${CMAKE_MATCH_1} is too low") | ||
endif() | ||
|
||
# Find Python and run-clang-tidy script | ||
find_package(Python 3 REQUIRED) | ||
|
||
find_program(RUN_CLANG_TIDY run-clang-tidy) | ||
if(NOT RUN_CLANG_TIDY) | ||
message(FATAL_ERROR "Failed to find run-clang-tidy script") | ||
endif() | ||
|
||
# Run | ||
execute_process(COMMAND ${Python_EXECUTABLE} ${RUN_CLANG_TIDY} -clang-tidy-binary ${CLANG_TIDY_EXECUTABLE} -quiet -p ${PROJECT_BINARY_DIR} RESULTS_VARIABLE EXIT_CODE) | ||
if(NOT EXIT_CODE STREQUAL 0) | ||
message(FATAL_ERROR "Analysis failed") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters