diff options
| author | yangwei <[email protected]> | 2024-08-07 13:07:00 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-08-12 15:48:31 +0800 |
| commit | f1b3928c7093dafb553ef51f49db58659525e502 (patch) | |
| tree | 9d82b6bfff6053627eed2521d0f6bfe232c44b54 /CMakeLists.txt | |
| parent | 526171618ff2e51ac86704095cf218b6e2d86702 (diff) | |
🔧 build(enable cppcheck on build): eliminate cppcheck error
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cbfdacd..61b786b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,40 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set (CMAKE_INSTALL_PREFIX "/opt/tsg/stellar" CACHE PATH "default install path" FORCE) endif() +find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck) +if (CMAKE_CXX_CPPCHECK) + list( + APPEND CMAKE_CXX_CPPCHECK + "--enable=all" + "--std=c++11" + "--error-exitcode=1" + "--suppress=unusedFunction" + "--suppress=missingInclude" + "--suppress=uselessAssignmentPtrArg" + "--suppress=unmatchedSuppression" + "--suppress=variableScope" + "--suppress=unreadVariable" + "--suppress=cstyleCast" + "--suppress=memleakOnRealloc" + "--suppress=constParameter" + "--suppress=uselessAssignmentArg" + "--suppress=uninitvar" + "--suppress=unusedStructMember" + "--suppress=unreachableCode" + "--suppress=internalAstError" + "--suppress=nullPointerRedundantCheck" + "--suppress=ctunullpointer" + "--suppress=redundantAssignment" + "--suppress=duplicateValueTernary" + "--suppress=funcArgOrderDifferent" + "--suppress=*:${PROJECT_SOURCE_DIR}/vendors/*" + "--suppress=*:${PROJECT_SOURCE_DIR}/deps/*" + ) + set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK}) +else() + message(FATAL_ERROR "Could not find the program cppcheck.") +endif() + option(ENABLE_PIC "Generate position independent code (necessary for shared libraries)" TRUE) option(ENABLE_WARNING_ALL "Enable all optional warnings which are desirable for normal code" TRUE) |
