From: Maksym Mamontov <madf@madf.info>
Date: Sun, 28 Aug 2022 15:26:01 +0000 (+0300)
Subject: Disable cppcheck for foreign libs by default.
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/085c36723242f7bd1e0fd9bf49b950da6cb96039?ds=inline;hp=--cc

Disable cppcheck for foreign libs by default.
---

085c36723242f7bd1e0fd9bf49b950da6cb96039
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e8fd09a..6a3ff749 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,9 @@ option ( BUILD_TESTS "Build tests." OFF )
 option ( BUILD_ALL "Build binaries, libraries and tests." OFF )
 option ( ENABLE_COVERAGE "Enable code coverage analysis." OFF )
 
+# CPPCheck-related
+option ( CPPCHECK_FOREIGN "Run cppcheck over foreign lib code" OFF )
+
 if ( BUILD_ALL )
     set ( BUILD_ALL_MODS ON )
     set ( BUILD_ALL_LIBS ON )
diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt
index 3fec99f1..39e548b1 100644
--- a/projects/CMakeLists.txt
+++ b/projects/CMakeLists.txt
@@ -14,4 +14,22 @@ if ( BUILD_STG )
     add_subdirectory ( stargazer )
 endif ( BUILD_STG )
 
-add_custom_target (cppcheck COMMAND /usr/bin/cppcheck --enable=all --std=c++14 ${CMAKE_SOURCE_DIR}/libs ${CMAKE_SOURCE_DIR}/projects/rscriptd ${CMAKE_SOURCE_DIR}/projects/sgauth ${CMAKE_SOURCE_DIR}/projects/sgconf ${CMAKE_SOURCE_DIR}/projects/stargazer)
+set ( LIB_DIRS ${CMAKE_SOURCE_DIR}/libs/common
+               ${CMAKE_SOURCE_DIR}/libs/conffiles
+               ${CMAKE_SOURCE_DIR}/libs/crypto
+               ${CMAKE_SOURCE_DIR}/libs/ia
+               ${CMAKE_SOURCE_DIR}/libs/logger
+               ${CMAKE_SOURCE_DIR}/libs/pinger
+               ${CMAKE_SOURCE_DIR}/libs/scriptexecuter
+               ${CMAKE_SOURCE_DIR}/libs/srvconf
+    )
+
+if (CPPCHECK_FOREIGN)
+    set ( LIB_DIRS ${LIB_DIRS}
+                   ${CMAKE_SOURCE_DIR}/libs/dotconfpp
+                   ${CMAKE_SOURCE_DIR}/libs/ibpp
+                   ${CMAKE_SOURCE_DIR}/libs/smux
+        )
+endif ()
+
+add_custom_target (cppcheck COMMAND /usr/bin/cppcheck --enable=all --std=c++17 ${LIB_DIRS} ${CMAKE_SOURCE_DIR}/projects/rscriptd ${CMAKE_SOURCE_DIR}/projects/sgauth ${CMAKE_SOURCE_DIR}/projects/sgconf ${CMAKE_SOURCE_DIR}/projects/stargazer)