diff --git a/CMakeLists.txt b/CMakeLists.txt index 14ecd3bab41d3214592b5ab0519f745e86a6051e..5c495c1df2c52de690bfcfd46a42f71d9a38dfd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ include(test/Test) if(OGS_COVERAGE AND NOT IS_SUBPROJECT) include(Coverage) endif() +include(CppCheck) #################### ### More Options ### diff --git a/Jenkinsfile b/Jenkinsfile index 70024250cb3a30ae6cd23125493fcd48aef9978e..cd63f591e9ecfc50d7a6c404fb180fbf7d626d08 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -98,6 +98,7 @@ pipeline { build { target="tests" } build { target="ctest" } build { target="doc" } + build { target="cppcheck" } } } post { @@ -117,6 +118,7 @@ pipeline { ], tools: [doxygen(pattern: 'build/DoxygenWarnings.log')], failedTotalAll: 1 + recordIssues tools: [cppCheck(pattern: 'build/cppcheck.log')] } success { publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: true, diff --git a/scripts/cmake/CppCheck.cmake b/scripts/cmake/CppCheck.cmake new file mode 100644 index 0000000000000000000000000000000000000000..07f058cb2f567836d09244923fbceff0c7da71b7 --- /dev/null +++ b/scripts/cmake/CppCheck.cmake @@ -0,0 +1,22 @@ +if(NOT CPPCHECK_TOOL_PATH) + return() +endif() + +if(DEFINED ENV{NUM_THREADS}) + set(CPPCHECK_THREADS -j $ENV{NUM_THREADS}) +endif() + +add_custom_target(cppcheck + COMMAND ${CPPCHECK_TOOL_PATH} + # --force + --enable=all + # --inconclusive + ${CPPCHECK_THREADS} + -i ${PROJECT_BINARY_DIR}/CMakeFiles + -i ${PROJECT_SOURCE_DIR}/ThirdParty + -i ${PROJECT_SOURCE_DIR}/Applications/DataExplorer + -i ${PROJECT_SOURCE_DIR}/Tests + --xml --xml-version=2 + --output-file=${PROJECT_BINARY_DIR}/cppcheck.log + ${PROJECT_SOURCE_DIR} +) diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index a2086a41132219edc8db1b63c6442b3ea1b60c05..7e64186db25927a6287ae5d52210d4cef4fdcea5 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -18,7 +18,7 @@ endif() # Find gnu profiler gprof find_program(GPROF_PATH gprof DOC "GNU profiler gprof" QUIET) -find_package(cppcheck QUIET) +find_program(CPPCHECK_TOOL_PATH cppcheck) find_package(PythonInterp QUIET) diff --git a/scripts/docker/Dockerfile.gcc.full b/scripts/docker/Dockerfile.gcc.full index 4836baee0877c0cf7b17cbcde59a32ae9e1c0f96..8ac8fa30d4a3c97787110effea0d7586209515f0 100644 --- a/scripts/docker/Dockerfile.gcc.full +++ b/scripts/docker/Dockerfile.gcc.full @@ -43,7 +43,6 @@ USER root RUN apt-get update && apt-get install -y \ biber \ clang-tidy \ - cppcheck \ doxygen \ graphviz \ libxml2-utils \ @@ -54,6 +53,14 @@ RUN curl https://include-what-you-use.org/downloads/include-what-you-use-0.8-x86 && tar xf include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -C /usr/ --strip-components=1 \ && rm include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz +# cppcheck +RUN curl -L -o 1.86.tar.gz https://github.com/danmar/cppcheck/archive/1.86.tar.gz \ + && tar xf 1.86.tar.gz \ + && cd cppcheck-1.86 \ + && make SRCDIR=build CFGDIR=/usr/share/cppcheck/ CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" \ + && make install CFGDIR=/usr/share/cppcheck/ \ + && cd .. && rm -r cppcheck-1.86 1.86.tar.gz + RUN apt-get install -y mesa-common-dev libgl1-mesa-dev libxt-dev wget USER jenkins