Skip to content

Instantly share code, notes, and snippets.

@scivision
Created August 15, 2023 17:12
Show Gist options
  • Save scivision/c8a77b8e006914c089991838cbc14388 to your computer and use it in GitHub Desktop.
Save scivision/c8a77b8e006914c089991838cbc14388 to your computer and use it in GitHub Desktop.
CMake CppCheck example
cmake_minimum_required(VERSION 3.19)
project(DemoCppCheck LANGUAGES C CXX)
option(cppcheck "Run CppCheck static code analysis")
if(cppcheck)
find_program(cppcheck_exe NAMES cppcheck REQUIRED)
set(cppcheck_opts --enable=all --inline-suppr --quiet --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck.supp)
set(CMAKE_C_CPPCHECK ${cppcheck_exe} --std=c11 ${cppcheck_opts})
set(CMAKE_CXX_CPPCHECK ${cppcheck_exe} --std=c++20 ${cppcheck_opts})
endif()
missingIncludeSystem
constParameter
unusedFunction
unmatchedSuppression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment