Direct answer
Conan’s CMakeDeps generator writes CMake configuration files that a consumer project locates with find_package, and those files define the package and target names the consumer links against. The consumer contract is those names, not the Conan settings behind them. Before changing CMakeDeps settings or package layout, record which package names the consumer calls find_package on and which targets it links, then verify those names still resolve. The concrete win is a consumer whose CMake does not change when a dependency’s Conan recipe or layout changes underneath it. The concrete loss is that a generated config file that resolves proves discovery, not runtime behavior, and CMakeDeps does not guarantee consumer compatibility across settings changes. The practical implication is that the target contract is the thing to keep stable, and everything else is generator configuration. Ask Claude Code to map the expected package and target names before touching any generator setting.
Why a renamed target costs a build
A consumer CMake file names targets that Conan generates. When a package’s layout changes, its generator settings change, or the toolchain hands CMake a different set of inputs, the names a consumer expects can stop resolving. The failure is a configure error naming a missing target, which reads as a CMake problem and is actually a contract change.
The cost compounds because two files are involved. The consumer names the target. CMakeDeps generates it. A reviewer who reads only the consumer cannot tell whether the name moved because the package changed, the generator setting changed, or the toolchain changed. That distinction is the whole review.
Evidence and its limits
Official, F041: Conan’s CMakeDeps documentation describes generation of CMake configuration files that consumers can locate with find_package. The Conan pages were not fetched in this pass, so verify target naming and current configuration keys before drafting.
Official: The CMakeToolchain documentation describes the toolchain generator that hands CMake the environment and presets.
Official: The consuming packages tutorial documents the consumer side of locating and linking generated targets.
Official: The CMake build helper documents the build-system integration used to drive CMake from Conan.
Official: The CMake Presets Manual documents the presets CMakeToolchain can produce, which connect the two tools.
Official, agent loop: Claude Code best practices recommends pairing an edit with a pass-or-fail check. For this review that check is a configure that resolves every expected find_package and target.
Derived, F042: The package-to-target map and the discovery contract inventory below are an editorial compatibility checklist, not a guarantee about any generated target.
No claim here depends on a Conan version, a specific package recipe, or a benchmark.
What CMakeDeps Generates
CMakeDeps is one of Conan’s generators. Its job is to write the files CMake needs to find and link a dependency, and its output is what a consumer’s find_package reads.
| CMakeDeps output | Purpose | Consumed by |
|---|---|---|
| Package config file | Satisfies a find_package call |
CMake configure |
| Target definitions | Named targets to link | Consumer CMake |
| Version and dependency data | Transitive package info | CMake resolution |
Treat the table as an ownership statement. CMakeDeps owns the generated files. The consumer owns the names it expects. Keeping those two aligned is the contract.
CMakeToolchain is a separate generator with a separate job: it produces the toolchain and presets that tell CMake how to build. The two are not interchangeable, and a review that conflates them will change the wrong file.
Read consumer find_package calls
Start from the consumer, because that is where the contract lives. Every find_package call names a package the consumer expects Conan to provide, and every target_link_libraries names a target.
find_package(MyLib REQUIRED)
target_link_libraries(app PRIVATE MyLib::MyLib)Record three things per dependency: the package name in find_package, the target names linked, and the namespace pattern used. The namespace is where most surprises live, because a target that resolves without its namespace or with the wrong one is a different contract than the one the consumer meant.
| Consumer call | Package name | Targets expected | Namespace |
|---|---|---|---|
find_package(MyLib) |
MyLib |
MyLib::MyLib |
Namespaced |
find_package(ZLIB) |
ZLIB |
ZLIB::ZLIB |
Namespaced |
find_package(Threads) |
Threads |
Threads::Threads |
Namespaced |
The consumer file is the record of intent. A target name that changed in the generated output is a defect in the review, not a reason to rewrite the consumer.
Map generated target names
The generated target names come from the package. For each find_package call, record which targets the generated config is expected to define.
| Conan package | find_package name |
Generated targets | Consumer links |
|---|---|---|---|
mylib/1.4.0 |
MyLib |
MyLib::MyLib |
MyLib::MyLib |
zlib/1.3 |
ZLIB |
ZLIB::ZLIB |
ZLIB::ZLIB |
bzip2/1.0.8 |
BZip2 |
BZip2::BZip2 |
BZip2::BZip2 |
Treat the table as a claim to verify, not a guarantee. F042 records that inventing a generated target name for a package is the failure to avoid. The name comes from the package’s generated config, and the way to see it is to generate the files and read them rather than to guess from the recipe.
A package whose target name does not match the find_package name is a real case, and it is the one that breaks consumers silently. The map is where that mismatch surfaces.
Inspect CMakeDeps Configuration
CMakeDeps carries configuration that shapes its output. The settings the generator exposes decide file layout and some naming behavior, and they are the things a change review has to enumerate before touching.
| Setting kind | What it affects | Review question |
|---|---|---|
| Generator enablement | Whether CMakeDeps runs at all | Is the expected generator active? |
| Output location | Where generated files land | Does find_package find them? |
| User-provided overrides | Names or layout per package | What did the override change? |
Examine the generator configuration as the thing that decides the output shape. A setting change that moves the generated files or renames a target is a consumer-facing change even though it lives in Conan configuration, and the map above is what catches it.
Connect CMakeToolchain Inputs
CMakeToolchain produces the toolchain file and presets CMake reads. The generator settings that shape the toolchain decide which compiler, flags, and preset names reach CMake.
| CMakeToolchain output | Purpose | Connects to |
|---|---|---|
| Toolchain file | Compiler and flags for CMake | Configure step |
| CMake presets | Named configure and build inputs | CMake presets |
| User-provided blocks | Extra toolchain content | Consumer CMake |
The preset connection is worth naming. A toolchain that emits presets gives CMake a named contract for configure inputs, and the review of those inputs is covered in the CMake presets guide. The toolchain decides the environment; CMakeDeps decides the targets. Keep the two reviews separate.
Review layout changes
A layout change moves where Conan puts files, including the generated CMake files. A layout that moves the generated config out of the path find_package searches will break consumer discovery even when every target name is unchanged.
| Change | Affects targets | Affects discovery | Review action |
|---|---|---|---|
| Target renamed | Yes | No | Consumer must follow, or fix the generator |
| Generated file moved | No | Yes | Fix the search path |
| Generator setting changed | Possibly | Possibly | Regenerate and diff |
| Package version bumped | Possibly | No | Re-read the map |
Read the table as a triage rule. A configure error naming a missing target is a discovery problem until proven otherwise, because discovery is the cheaper thing to check.
Keep consumer contracts explicit
The discovery contract is the artifact that makes the review durable. One row per dependency, with the package name, the targets, and the namespace pattern.
| Dependency | Package name | Targets | Namespace | Verified |
|---|---|---|---|---|
mylib |
MyLib |
MyLib::MyLib |
Namespaced | Configure resolves |
zlib |
ZLIB |
ZLIB::ZLIB |
Namespaced | Configure resolves |
Keep the contract next to the consumer CMake. A contract that lives in a ticket is a contract nobody reads during the next generator change. The contract that lives in the repo is what a reviewer checks when a recipe or layout changes.
A worked walkthrough of one layout change
Consider a consumer that calls find_package(MyLib REQUIRED) and links MyLib::MyLib. A package maintainer changes the recipe’s layout, and the generated config moves out of the path CMake searches. Configure fails with an error naming a missing target, which reads as a CMake problem and is actually a discovery problem.
The instinctive fix is renaming targets in the consumer. That is the wrong axis, because the target names did not change. The generated config moved, and find_package no longer finds it.
Start from the consumer contract, not the generated output.
Read every find_package call and every target_link_libraries in the consumer, and record the package name, the target names, and the namespace pattern. This is the contract, and it is the artifact that stays stable while generator settings and layout change underneath.
conan install . --generator CMakeDeps --generator CMakeToolchainRegenerate the files and check where CMakeDeps wrote them. Compare that path against what the consumer’s find_package searches. A layout change that moves the config out of the search path is a discovery defect, and the fix is in the search path or the layout, not in a consumer rename.
Run the configure and confirm every expected package and target resolves. That resolution is the pass condition for the change, and it is the evidence the contract held.
Record the discovery contract next to the consumer CMake: one row per dependency with the package name, targets, and namespace. The contract that lives in the repo is what a reviewer checks during the next generator change.
Anti-patterns that look like fixes
Four patterns recur around CMakeDeps work, and each one hides a decision a reviewer needs to see.
| Pattern | What it looks like | Why it hurts | Do instead |
|---|---|---|---|
| Renaming consumer targets | Changing the consumer to match generated output | The contract was stable; discovery moved | Fix the search path or layout |
| Inventing target names | Guessing a package’s target from its recipe | F042 records this as the failure to avoid | Generate and read the config |
| Conflating the two generators | Changing CMakeToolchain for a target problem | Toolchain and deps are separate generators | Review them apart |
| Claiming runtime proof | “The target resolved, so it works” | Resolution proves discovery, not behavior | Separate executed check |
Inventing target names deserves the most caution, and the guardrail in this post’s avoid list forbids it explicitly. A generated target name comes from the package’s config, and the only reliable way to know it is to generate the files and read them.
None of these is a Conan defect. They are review hazards, and the package-to-target map plus the configure check are what catch them.
A runbook for the next generator change
The checklist earlier in this post is the pass condition. The runbook below is the sequence to follow when a CMakeDeps setting or layout change is proposed.
Read the consumer CMake and record every find_package name, target, and namespace. This is the contract, and it is what the change must preserve or deliberately change.
Build the package-to-target map by generating the files and reading them. Do not guess names from the recipe.
Enumerate the CMakeDeps settings the change touches and what each affects. Keep CMakeToolchain inputs separate, because the toolchain decides the environment and CMakeDeps decides the targets.
Run the configure and confirm every expected package and target resolves. Paste the resolution result into the change description.
Record the discovery contract next to the consumer CMake, and note any deliberate change to a target name as a contract change rather than a side effect.
The runbook takes minutes and produces the artifacts a reviewer needs: the target contract and the resolution result. Skipping it produces a change that reports success while a consumer fails to configure.
Where this habit pays across the batch
The contract-first habit in this post is the same one the rest of the batch applies to different constructs. CMake presets asks for the resolved preset inputs before a configure, and CMake find_package vs FetchContent asks for a resolution trace before choosing a dependency path.
The JVM posts apply the same discipline to version and variant policy. Gradle constraints vs dependencies asks for a resolved-graph diff, Gradle capability conflicts asks for a component inventory, Gradle variant attributes asks for the consumer request, and Maven optional dependencies asks for an import scan.
The .NET posts apply it to package versions and generated code. NuGet central package management asks for a props and override inventory, .NET multi-targeting asks for a per-framework matrix and build, and C# source generators asks for the generator’s input change before reading its output. For generated-code ownership in another ecosystem, Cargo build scripts covers generated-artifact contracts including rerun conditions.
That consistency is deliberate. The constructs differ, but the shape is the same: read the evidence the tool already produces, then make the smallest change the evidence supports.
The same shape extends to the ecosystems covered in earlier batches. On the Python side, dependency groups versus extras separates local workflow requirements from published optional features, and stub drift audits a package’s declared types against its documented runtime surface. TypedDict boundaries covers separating truly optional keys from missing data before replacing broad dictionary annotations.
On the Go side, module compatibility covers keeping an exported API change inside an import contract, and graph pruning covers why an indirect dependency entry is graph metadata rather than something to delete. Workspace boundaries covers deciding what belongs in go.work versus what stays a module requirement.
On the Rust side, feature unification covers mapping which optional APIs a workspace build actually exposes, and workspace inheritance covers centralizing metadata without hiding crate-local exceptions. Profile boundaries covers separating diagnostic and optimization settings from options that change observable program behavior.
Keeping a consumer contract stable has a direct analog in Cargo workspace inheritance, where the same “which fields stay shared and which stay local” question applies to workspace metadata rather than generated CMake targets. Both are contract questions, and both reward recording the expected surface before changing the mechanism behind it.
Working alongside the review bottleneck
A generator change with a pasted target contract and resolution result is cheap to review. A change described as “updated the layout” is a reviewer reproducing the work, and reproduction is the expensive part. The Claude Code code review bottleneck covers what happens when generation outpaces the review that has to accept it.
The same reasoning appears in Claude Code cost per verified change, which treats verified work as a separate unit from generated output. A resolution result against a recorded contract is a verified unit. A “trust me, the targets still work” description is not.
When the review queue is long enough that verification slips, the failure mode is a merge that nobody actually checked. Prevent false success from passing tests covers the case where a successful configure is the only evidence, and a moved config is exactly the case where green proves less than it appears to.
The concrete win, loss, and implication
The concrete win is a consumer whose CMake survives a dependency change. A package that moves its recipe or layout, or a generator whose settings shift, does not force a consumer rewrite as long as the package and target names the consumer expects still resolve.
The concrete loss is the guarantee gap. CMakeDeps generates the files, and a config file that resolves proves discovery. It does not prove the target behaves correctly at runtime, and it does not promise that a settings change is invisible to every consumer. That verification is separate work this post does not claim.
The practical implication is that the target contract is the stable surface, and generator configuration is the mechanism behind it. Teams that keep the discovery contract resolve fewer “why is this target missing” incidents. Teams that change generator settings and read the consumer afterward spend the difference debugging configure errors.
Related reading on build integration
Consumer-contract questions continue across the batch. CMake presets covers recording configure inputs, and CMake find_package vs FetchContent covers choosing the dependency boundary the generated config satisfies.
For generated-code ownership in other ecosystems, C# source generators covers reviewing a generator’s contract rather than its output, and Cargo build scripts covers generated-artifact contracts including rerun conditions.
For dependency ownership in other ecosystems, Maven optional dependencies covers which optional libraries a consumer must declare directly, and Gradle variant attributes covers how a consumer request selects a producer variant.
Review habits sit upstream of every generator change. Ask what Claude Code verification requires before calling a target contract stable, and prevent false success from passing tests when a configure that resolves is the only evidence.
Checklist before changing CMakeDeps settings or layout
Run this list against the change. Each row is a pass condition.
| Check | Pass condition | If it fails |
|---|---|---|
| Package-to-target map | Every find_package name and target recorded |
Build the map first |
| Consumer names | Unchanged, or change justified | Fix the generator, not the consumer |
| Namespace pattern | Recorded per dependency | Confirm the pattern |
| Generator settings | Enumerated before the change | List them |
| Discovery | Configure resolves every target | Check the search path |
| Toolchain separate | CMakeToolchain not conflated with CMakeDeps | Review the two apart |
| Runtime claim | Not made from resolution | Separate executed check |
Working with Claude Code on a generator change
Give the agent the consumer CMake files and the Conan generator configuration. Ask for the package-to-target map from the consumer before any setting change. The agent session works best when the check is a configure that resolves every expected find_package and target, which is the shape the official best-practices guidance recommends.
Ask the agent to report four things when it finishes. The package and target names the consumer expects. The CMakeDeps settings it changed and why. The CMakeToolchain inputs, kept separate. The configure result showing every expected target resolved. A report that omits the resolution check has not finished, because a target name that no longer resolves is the defect the review exists to catch.
Reviewing whether a target rename is acceptable is the reviewer’s job. The agent reads recipes and can run configure, but deciding which names the consumer should expect is a design decision. The Claude Code verification guide covers the review questions: what changed, what proves it, and what was not checked.
Data gap and future update
F041 and F042 rest on Conan pages that were not fetched in the research pass, so exact target naming conventions and current generator configuration keys should be rechecked against the Conan 2 documentation before a real change. This post does not invent generated target names for any package. A future update should record, per project, which packages the consumer uses, the target names each generates, and the Conan version the observations were taken at.
No benchmark, build-time measurement, or runtime compatibility claim is made here. Whether a generated target behaves correctly requires executed evidence this post does not have.
One AI API Key option for OpenAI-format agents
Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.
OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. It is a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility notes before choosing an agent route, or read the quickstart for the request shape.
FAQ
Does CMakeDeps guarantee my consumer keeps working?
No. It generates the config files a consumer’s find_package reads, and a resolved target proves discovery, not runtime behavior or cross-version compatibility. The expected names belong in the discovery contract, verified on every generator change.
What is the difference between CMakeDeps and CMakeToolchain?
CMakeDeps generates the dependency config and targets a consumer links against. CMakeToolchain generates the toolchain and presets that tell CMake how to build. They are separate generators with separate jobs, and a review should not conflate them.
Where do generated target names come from?
From the package’s generated config. F042 records inventing a generated target name for a package as the failure to avoid. Generate the files and read them rather than guessing from the recipe.
Why did a target stop resolving after a layout change?
Usually because the generated config moved out of the path find_package searches. Target names can be unchanged while discovery breaks. Check the search path before assuming a rename.
Can I rename a target in the consumer instead?
Only if you own the consumer and the rename is intended. The consumer file is the record of the contract, and a rename there is a change every downstream user sees. Prefer fixing the generator or layout when the intent was to keep the contract stable.
Related reading in this batch
This post is one of ten build-system and dependency guides written together. CMake Presets and CMake find_package vs FetchContent complete the C++ set.
The JVM posts cover dependency and variant boundaries: Gradle Constraints vs Dependencies, Gradle Capability Conflicts, Gradle Variant Attributes, and Maven Optional Dependencies.
The .NET posts cover version and generated-code boundaries: NuGet Central Package Management, .NET Multi-Targeting, and C# Source Generators.
More from this batch
- CMake Presets: Give Claude Code Reproducible Configure Inputs
- CMake find_package vs FetchContent: Choose a Dependency Boundary
- C# Source Generators: Review Generated Contracts With Claude Code
- Gradle Variant Attributes: Match Consumers to the Right Artifact
- Maven Optional Dependencies: Keep Transitive Expectations Explicit
More Claude Code troubleshooting
- Python Protocols vs ABCs: Preserve Interface Contracts With Claude Code
- pnpm Peer Diagnostics: Read Resolution Reports Before Claude Code Pins
- TypeScript Project References: A Claude Code Boundary Guide
- OpenAPI Generator Customization: Keep Templates and Config in Sync
- GraphQL Code Generator Client Presets: Review Generated Boundaries
- Protocol Buffer Reserved Fields: A Claude Code Wire Compatibility Guide
- sqlc Query Annotations: Align SQL and Generated Types With Claude Code
- Django Deprecation Runway: Plan Framework Maintenance With Claude Code
- Rails Upgrade Sequence: Order Major Changes With Claude Code
- Angular Update Guide: Build a Migration Plan With Claude Code
Sources
- Official: Conan 2: CMakeDeps, supporting F041 on generating config files consumers locate with
find_package. - Official: Conan 2: CMakeToolchain, toolchain generator and its inputs.
- Official: Conan 2: Consuming Packages, consumer-side discovery and linking.
- Official: Conan 2: CMake Build Helper, CMake build-system integration.
- Official: CMake Presets Manual, presets CMakeToolchain can produce.
- Official: Claude Code Docs: Best Practices, supporting the resolution check.