From c52773feb41f5ad11cc2df232bffcdbd255bed8b Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Fri, 23 Oct 2020 14:11:40 +0200 Subject: [PATCH] Add cppcheck option to the cmake targets and add a cppcheck CI job. --- .gitlab-ci.yml | 15 ++++++++++++++- CMake/VirtualFluidsMacros.cmake | 15 +++++++++++++++ CMakeLists.txt | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e2743898..76441efb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,4 +82,17 @@ benchmark_Include_what_you_use: - cd $CI_PROJECT_DIR/build - rm -r ./* - cmake .. -DBUILD_VF_CPU=ON -DUSE_OPENMP=OFF -DBUILD_VF_INCLUDE_WHAT_YOU_USE=ON - - make \ No newline at end of file + - make + + +benchmark_cppcheck: + stage: deploy + + before_script: + - export DEBIAN_FRONTEND=noninteractive + - apt-get update + - apt-get install cppcheck + + script: + - cd $CI_PROJECT_DIR + - cppcheck src --enable=all diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 14309caeb..6b7964dfd 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -173,6 +173,21 @@ function(vf_add_library) status_lib("include-what-you-use enabled") endif() + # cppcheck + if(BUILD_VF_CPPCHECK) + find_program(CPPCHECK_PROGRAM NAMES cppcheck) + + if(NOT CPPCHECK_PROGRAM) + message(FATAL_ERROR "Could not find the program cppcheck") + endif() + + set_target_properties(${library_name} + PROPERTIES + CXX_CPPCHECK "${CPPCHECK_PROGRAM};--enable=all") + + status_lib("cppcheck enabled") + endif() + ################################################################# ### ADDITIONAL LINK LIBRARIES ### ################################################################# diff --git a/CMakeLists.txt b/CMakeLists.txt index f6176bae0..e1540fd0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(BUILD_VF_GPU "Build VirtualFluids gpu variant" OFF) option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF) option(BUILD_VF_CLANG_TIDY "Add the clang tidy checks to the targets" OFF) option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF) +option(BUILD_VF_CPPCHECK "Add cppcheck to the targets" OFF) option(BUILD_SHARED_LIBS "" ON) -- GitLab