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: 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index e2cd3029058..cfe46dc26a3 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(TARGET cppcheck) + 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)