Skip to content

Commit 1219ae8

Browse files
authored
fixed #14088 - made CMake build with BUILD_CLI=Off work (#7765)
1 parent 23a698d commit 1219ae8

File tree

4 files changed

+70
-5
lines changed

4 files changed

+70
-5
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,46 @@ jobs:
151151
run: |
152152
cmake --build cmake.output --target install
153153
154+
- name: Run CMake on ubuntu (no CLI)
155+
if: matrix.os == 'ubuntu-22.04'
156+
run: |
157+
cmake -S . -B cmake.output_nocli -G "Unix Makefiles" -DBUILD_CLI=Off
158+
159+
- name: Run CMake on ubuntu (no CLI / with tests)
160+
if: matrix.os == 'ubuntu-22.04'
161+
run: |
162+
# the test and CLI code are too intertwined so for now we need to reject that
163+
if cmake -S . -B cmake.output_nocli_tests -G "Unix Makefiles" -DBUILD_TESTS=On -DBUILD_CLI=Off; then
164+
exit 1
165+
else
166+
exit 0
167+
fi
168+
169+
- name: Run CMake on ubuntu (no CLI / with GUI)
170+
if: matrix.os == 'ubuntu-22.04'
171+
run: |
172+
cmake -S . -B cmake.output_nocli_gui -G "Unix Makefiles" -DBUILD_CLI=Off -DBUILD_GUI=On
173+
174+
- name: Run CMake on ubuntu (no GUI)
175+
if: matrix.os == 'ubuntu-22.04'
176+
run: |
177+
cmake -S . -B cmake.output_nogui -G "Unix Makefiles" -DBUILD_GUI=Off
178+
179+
- name: Run CMake on ubuntu (no GUI / with triage)
180+
if: matrix.os == 'ubuntu-22.04'
181+
run: |
182+
# cannot build triage without GUI
183+
if cmake -S . -B cmake.output_nogui_triage -G "Unix Makefiles" -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then
184+
exit 1
185+
else
186+
exit 0
187+
fi
188+
189+
- name: Run CMake on ubuntu (no CLI / no GUI)
190+
if: matrix.os == 'ubuntu-22.04'
191+
run: |
192+
cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_GUI=Off
193+
154194
build_uchar:
155195

156196
strategy:

.github/workflows/selfcheck.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ jobs:
154154
UNUSEDFUNCTION_ONLY: 1
155155
# unusedFunction notest nocli - end
156156

157+
# unusedFunction notest nocli nogui - start
158+
- name: CMake (no test / no cli / no gui)
159+
run: |
160+
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
161+
162+
- name: Generate dependencies (no test / no cli / no gui)
163+
run: |
164+
# make sure the precompiled headers exist
165+
make -C cmake.output.notest_nocli_nogui lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx
166+
167+
# TODO: find a way to report unmatched suppressions without need to add information checks
168+
- name: Self check (unusedFunction / no test / no cli / no gui)
169+
if: false # TODO: the findings are currently too intrusive
170+
run: |
171+
./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
172+
env:
173+
DISABLE_VALUEFLOW: 1
174+
UNUSEDFUNCTION_ONLY: 1
175+
# unusedFunction notest nocli nogui - end
176+
157177
- name: Fetch corpus
158178
run: |
159179
wget https://github.com/danmar/cppcheck/archive/refs/tags/2.8.tar.gz

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ if(LIBXML2_XMLLINT_EXECUTABLE)
4747
add_dependencies(validatePlatforms validatePlatforms-${platformname})
4848
endforeach()
4949

50-
add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml
51-
DEPENDS cppcheck)
50+
if(TARGET cppcheck)
51+
add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml
52+
DEPENDS cppcheck)
5253

53-
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml
54-
DEPENDS cppcheck)
54+
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml
55+
DEPENDS cppcheck)
56+
endif()
5557

5658
add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)
5759

cmake/options.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ option(ENABLE_CHECK_INTERNAL "Enable internal checks"
6262
option(DISABLE_DMAKE "Disable run-dmake dependencies" OFF)
6363
option(BUILD_MANPAGE "Enable man target to build manpage" OFF)
6464

65-
option(BUILD_CLI "Build the cli application" ON)
65+
option(BUILD_CLI "Build the CLI application" ON)
66+
if(NOT BUILD_CLI AND BUILD_TESTS)
67+
message(FATAL_ERROR "Building the tests requires the CLI to be build as well")
68+
endif()
6669

6770
option(BUILD_GUI "Build the qt application" OFF)
6871
option(WITH_QCHART "Enable QtCharts usage in the GUI" OFF)

0 commit comments

Comments
 (0)