Skip to content

Commit

Permalink
Enable Cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeu committed Feb 25, 2024
1 parent 9395534 commit e732b67
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
elif [ "${{ matrix.compiler }}" == "mingw" ]; then
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -G "MinGW Makefiles"
else
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON
fi
- name: Build with ${{ matrix.compiler }}
run: |
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include(GNUInstallDirs)
include(cmake/options.cmake)
include(cmake/conan.cmake)
include(cmake/thirdParties.cmake)
include(cmake/staticAnalyzers.cmake)
include(cmake/compilerOptions.cmake)
include(cmake/getopt.cmake)
include(cmake/src.cmake)
Expand Down
2 changes: 2 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ elseif(MATIO_DEFAULT_FILE_VERSION STREQUAL "7.3")
else()
message(ERROR "Unrecognized MAT file version")
endif()

option(MATIO_ENABLE_CPPCHECK "Enable static analysis with Cppcheck." OFF)
14 changes: 14 additions & 0 deletions cmake/staticAnalyzers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if(MATIO_ENABLE_CPPCHECK)
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
set(CMAKE_C_CPPCHECK ${CPPCHECK}
--suppress=missingInclude
--enable=all
--inline-suppr
--inconclusive -i ${CMAKE_SOURCE_DIR}/imgui/lib
)
message(VERBOSE "Cppcheck finished setting up.")
else()
message(SEND_ERROR "Cppcheck requested but executable not found.")
endif()
endif()

0 comments on commit e732b67

Please sign in to comment.