From d096c9f6de1f455fb24c8425da87e89c4707515f Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 5 Jun 2025 11:19:41 +0200 Subject: [PATCH 1/4] fixed CMake with `BUILD_CLI=OFF` --- CMakeLists.txt | 10 ++++++---- cmake/options.cmake | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2cd3029058..860f9b9a0f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,11 +47,13 @@ if(LIBXML2_XMLLINT_EXECUTABLE) add_dependencies(validatePlatforms validatePlatforms-${platformname}) endforeach() - add_custom_target(errorlist-xml $ --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml - DEPENDS cppcheck) + if (BUILD_CLI) + add_custom_target(errorlist-xml $ --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml + DEPENDS cppcheck) - add_custom_target(example-xml $ --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml - DEPENDS cppcheck) + add_custom_target(example-xml $ --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml + DEPENDS cppcheck) + endif() add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml) diff --git a/cmake/options.cmake b/cmake/options.cmake index f4efb2f329a..5765f9a9595 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -62,7 +62,10 @@ option(ENABLE_CHECK_INTERNAL "Enable internal checks" option(DISABLE_DMAKE "Disable run-dmake dependencies" OFF) option(BUILD_MANPAGE "Enable man target to build manpage" OFF) -option(BUILD_CLI "Build the cli application" ON) +option(BUILD_CLI "Build the CLI application" ON) +if(NOT BUILD_CLI AND BUILD_TESTS) + message(FATAL_ERROR "Building the tests requires the CLI to be build as well") +endif() option(BUILD_GUI "Build the qt application" OFF) option(WITH_QCHART "Enable QtCharts usage in the GUI" OFF) From 03437130054d918019354a3d04e1f905c6edd156 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 22 Aug 2025 18:42:33 +0200 Subject: [PATCH 2/4] use `if (TARGET x)` check --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 860f9b9a0f1..cfe46dc26a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ if(LIBXML2_XMLLINT_EXECUTABLE) add_dependencies(validatePlatforms validatePlatforms-${platformname}) endforeach() - if (BUILD_CLI) + if(TARGET cppcheck) add_custom_target(errorlist-xml $ --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml DEPENDS cppcheck) From 32a159b0d07a2e8e146a88be080e8973b3587345 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 26 Aug 2025 11:51:10 +0200 Subject: [PATCH 3/4] selfcheck.yml: add `unusedFunction` check without CLI and without GUI --- .github/workflows/selfcheck.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index 69aab78db07..fd9a5f77bde 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -154,6 +154,26 @@ jobs: UNUSEDFUNCTION_ONLY: 1 # unusedFunction notest nocli - end + # unusedFunction notest nocli nogui - start + - name: CMake (no test / no cli / no gui) + run: | + cmake -S . -B cmake.output.notest_nocli_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On + + - name: Generate dependencies (no test / no cli / no gui) + run: | + # make sure the precompiled headers exist + make -C cmake.output.notest_nocli_nogui lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx + + # TODO: find a way to report unmatched suppressions without need to add information checks + - name: Self check (unusedFunction / no test / no cli / no gui) + if: false # TODO: the findings are currently too intrusive + run: | + ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest_nocli_nogui/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr + env: + DISABLE_VALUEFLOW: 1 + UNUSEDFUNCTION_ONLY: 1 + # unusedFunction notest nocli nogui - end + - name: Fetch corpus run: | wget https://github.com/danmar/cppcheck/archive/refs/tags/2.8.tar.gz From 12f095088fefa1d7a12fc550bf395e4062288b4f Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 26 Aug 2025 11:58:58 +0200 Subject: [PATCH 4/4] CI-unixish.yml: test various `BUILD_*` CMake option combination --- .github/workflows/CI-unixish.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 0116dc5ed1e..7bd5b325f22 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -151,6 +151,46 @@ jobs: run: | cmake --build cmake.output --target install + - name: Run CMake on ubuntu (no CLI) + if: matrix.os == 'ubuntu-22.04' + run: | + cmake -S . -B cmake.output_nocli -G "Unix Makefiles" -DBUILD_CLI=Off + + - name: Run CMake on ubuntu (no CLI / with tests) + if: matrix.os == 'ubuntu-22.04' + run: | + # the test and CLI code are too intertwined so for now we need to reject that + if cmake -S . -B cmake.output_nocli_tests -G "Unix Makefiles" -DBUILD_TESTS=On -DBUILD_CLI=Off; then + exit 1 + else + exit 0 + fi + + - name: Run CMake on ubuntu (no CLI / with GUI) + if: matrix.os == 'ubuntu-22.04' + run: | + cmake -S . -B cmake.output_nocli_gui -G "Unix Makefiles" -DBUILD_CLI=Off -DBUILD_GUI=On + + - name: Run CMake on ubuntu (no GUI) + if: matrix.os == 'ubuntu-22.04' + run: | + cmake -S . -B cmake.output_nogui -G "Unix Makefiles" -DBUILD_GUI=Off + + - name: Run CMake on ubuntu (no GUI / with triage) + if: matrix.os == 'ubuntu-22.04' + run: | + # cannot build triage without GUI + if cmake -S . -B cmake.output_nogui_triage -G "Unix Makefiles" -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then + exit 1 + else + exit 0 + fi + + - name: Run CMake on ubuntu (no CLI / no GUI) + if: matrix.os == 'ubuntu-22.04' + run: | + cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_GUI=Off + build_uchar: strategy: