forked from open62541/open62541
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: add static analyzer during build process (by option)
- Loading branch information
Showing
8 changed files
with
118 additions
and
39 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
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,3 @@ | ||
Checks: 'cert-*,performance-*,readability-*,-readability-braces-around-statements' | ||
WarningsAsErrors: 'cert-*,performance-*,readability-*,-readability-braces-around-statements' | ||
FormatStyle: file |
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,3 @@ | ||
missingIncludeSystem | ||
unusedFunction | ||
*:build |
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,53 @@ | ||
if(UA_ENABLE_STATIC_ANALYZER STREQUAL MINIMAL OR UA_ENABLE_STATIC_ANALYZER STREQUAL REDUCED OR UA_ENABLE_STATIC_ANALYZER STREQUAL FULL) | ||
# cpplint just gives warnings about coding style | ||
find_program(CPPLINT_EXE NAMES "cpplint") | ||
if(CPPLINT_EXE) | ||
set(CMAKE_C_CPPLINT "${CPPLINT_EXE};--quiet") | ||
set(CMAKE_CXX_CPPLINT "${CPPLINT_EXE};--quiet") | ||
endif() | ||
endif() | ||
if(UA_ENABLE_STATIC_ANALYZER STREQUAL REDUCED OR UA_ENABLE_STATIC_ANALYZER STREQUAL FULL) | ||
# clang-tidy has certain warnings as errors | ||
find_program(CLANG_TIDY_EXE NAMES "clang-tidy") | ||
if(CLANG_TIDY_EXE) | ||
set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXE};-p=compile_commands.json") | ||
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-p=compile_commands.json") | ||
endif() | ||
elseif(UA_ENABLE_STATIC_ANALYZER STREQUAL FULL) | ||
# cppcheck provides just warnings but checks "all" (for now) - huge CPU impact | ||
find_program(CPPCHECK_EXE NAMES "cppcheck") | ||
if(CPPCHECK_EXE) | ||
set(CMAKE_C_CPPCHECK "${CPPCHECK_EXE};--project=compile_commands.json;--enable=all;--inconclusive;--inline-suppr;\ | ||
--suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck-suppressions.txt;-D__GNUC__;-i ${PROJECT_SOURCE_DIR}/build") | ||
set(CMAKE_CXX_CPPCHECK "${CPPCHECK_EXE};--project=compile_commands.json;--enable=all;--inconclusive;--inline-suppr;\ | ||
--suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck-suppressions.txt;-D__GNUC__;-i ${PROJECT_SOURCE_DIR}/build") | ||
endif() | ||
|
||
# "include what you use" requires additional configuration - ignore for now | ||
find_program(IWYU_EXE NAMES "iwyu") | ||
if(IWYU_EXE) | ||
#set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${IWYU_EXE}") | ||
#set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXE}") | ||
endif() | ||
endif() | ||
|
||
# adds new target "clangformat" to enforce clang-format rules | ||
find_program(CLANG_FORMAT_EXE NAMES "clang-format") | ||
if(CLANG_FORMAT_EXE) | ||
file(GLOB_RECURSE FILES_TO_FORMAT | ||
${PROJECT_SOURCE_DIR}/arch/*.c | ||
${PROJECT_SOURCE_DIR}/plugins/*.c | ||
${PROJECT_SOURCE_DIR}/src/*.c | ||
${PROJECT_SOURCE_DIR}/arch/*.h | ||
${PROJECT_SOURCE_DIR}/include/*.h | ||
${PROJECT_SOURCE_DIR}/plugins/*.h | ||
${PROJECT_SOURCE_DIR}/src/*.h | ||
) | ||
add_custom_target( | ||
clangformat COMMAND ${CLANG_FORMAT_EXE} | ||
-style=file | ||
-i | ||
${FILES_TO_FORMAT} | ||
) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
find_package(ClangTools) | ||
add_custom_target(clang-tidy ${CLANG_TIDY_PROGRAM} | ||
${lib_sources} | ||
-p=compile_commands.json | ||
-- | ||
-I${PROJECT_SOURCE_DIR}/include | ||
-I${PROJECT_SOURCE_DIR}/plugins | ||
-I${PROJECT_SOURCE_DIR}/deps | ||
-I${PROJECT_SOURCE_DIR}/src | ||
-I${PROJECT_SOURCE_DIR}/src/server | ||
-I${PROJECT_SOURCE_DIR}/src/client | ||
-I${PROJECT_BINARY_DIR}/src_generated | ||
DEPENDS ${lib_sources} | ||
COMMENT "Run clang-tidy on the library") | ||
add_dependencies(clang-tidy open62541) | ||
|
||
add_custom_target(cpplint cpplint | ||
${lib_sources} | ||
${internal_headers} | ||
${default_plugin_headers} | ||
${default_plugin_sources} | ||
${ua_architecture_headers} | ||
${ua_architecture_sources} | ||
DEPENDS ${lib_sources} | ||
${internal_headers} | ||
${default_plugin_headers} | ||
${default_plugin_sources} | ||
${ua_architecture_headers} | ||
${ua_architecture_sources} | ||
COMMENT "Run cpplint code style checker on the library") |
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