Guard cppcheck dependency on target existence#1
Closed
xroche wants to merge 1 commit into
Closed
Conversation
The `cppcheck` target is only created when CppcheckConfig.cmake finds the cppcheck binary. The unconditional `add_dependencies(cppcheck ...)` breaks CMake configure on systems without cppcheck installed (CI containers, Conan builds, minimal dev setups). Wrap the call in `if(TARGET cppcheck)` so the build works regardless. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
xroche
added a commit
that referenced
this pull request
Mar 19, 2026
When building ddprof as a dependency (Conan, FetchContent), the static analysis targets (cppcheck, clang-tidy, format) are unnecessary. They add configure-time tool lookups and can fail if the tools aren't installed. Add a `DDPROF_ENABLE_STATIC_ANALYSIS` option (ON by default) so consumers can skip them with `-DDDPROF_ENABLE_STATIC_ANALYSIS=OFF`. Also includes the `if(TARGET cppcheck)` guard from PR #1 for safety. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
xroche
added a commit
that referenced
this pull request
Mar 19, 2026
When building ddprof as a dependency (Conan, FetchContent), the static analysis targets (cppcheck, clang-tidy, format) are unnecessary. They add configure-time tool lookups and can fail if the tools aren't installed. Add a `DDPROF_ENABLE_STATIC_ANALYSIS` option (ON by default) so consumers can skip them with `-DDDPROF_ENABLE_STATIC_ANALYSIS=OFF`. Also includes the `if(TARGET cppcheck)` guard from PR #1 for safety. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
xroche
added a commit
that referenced
this pull request
Mar 19, 2026
…taDog#512) Add DDPROF_ENABLE_STATIC_ANALYSIS option to skip analysis targets When building ddprof as a dependency (Conan, FetchContent), the static analysis targets (cppcheck, clang-tidy, format) are unnecessary. They add configure-time tool lookups and can fail if the tools aren't installed. Add a `DDPROF_ENABLE_STATIC_ANALYSIS` option (ON by default) so consumers can skip them with `-DDDPROF_ENABLE_STATIC_ANALYSIS=OFF`. Also includes the `if(TARGET cppcheck)` guard from PR #1 for safety. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: erwan.viollet <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CMake configure fails on systems without cppcheck installed because
add_dependencies(cppcheck DDProf::Parser)references a target that onlyexists when
find_programfinds the cppcheck binary. This breaks CIcontainers, Conan builds, and minimal dev setups.
CMake's
if(TARGET)is the recommended guard for conditionally-created targets.
How
Wrap the
add_dependenciescall inif(TARGET cppcheck). No behaviorchange when cppcheck is installed.
🤖 Generated with Claude Code