Skip to content

Guard cppcheck dependency on target existence#1

Closed
xroche wants to merge 1 commit into
mainfrom
fix/cppcheck-target-guard
Closed

Guard cppcheck dependency on target existence#1
xroche wants to merge 1 commit into
mainfrom
fix/cppcheck-target-guard

Conversation

@xroche

@xroche xroche commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

CMake configure fails on systems without cppcheck installed because
add_dependencies(cppcheck DDProf::Parser) references a target that only
exists when find_program finds the cppcheck binary. This breaks CI
containers, Conan builds, and minimal dev setups.

CMake's if(TARGET)
is the recommended guard for conditionally-created targets.

How

Wrap the add_dependencies call in if(TARGET cppcheck). No behavior
change when cppcheck is installed.

🤖 Generated with Claude Code

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 xroche closed this Mar 19, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant