You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify README - remove design rationale and redundant examples
Removed verbose explanations about implementation choices and consolidated
documentation to be more practical and concise.
Changes:
- Removed 'Key benefits' section explaining design rationale
- Simplified 'Dependency Handling' section from detailed examples to essential usage
- Reduced cpp_library_map_dependency() documentation from 3 examples to 1
- Removed redundant Examples 2 & 3 (now automatic with dependency provider)
- Simplified Troubleshooting section - removed obsolete issues
- Removed 'Component Merging Not Working' (automatic with provider)
- Removed 'Version Detection Fails' (automatic with provider)
- Added 'Dependency Not Tracked' troubleshooting entry
Net result: 144 lines removed (161 deleted, 17 added)
Focus: Show users HOW to use it, not WHY we designed it that way.
@@ -203,92 +203,40 @@ For information about using installed packages with `find_package()`, see the [C
203
203
204
204
#### Dependency Handling in Installed Packages
205
205
206
-
cpp-library automatically generates correct `find_dependency()` calls in the installed CMake package configuration files by tracking your `find_package()` and `CPMAddPackage()` calls. This ensures downstream users can find and link all required dependencies when using your installed library.
Enable dependency tracking to capture the exact syntax of your dependency requests:
206
+
cpp-library automatically generates `find_dependency()` calls in the installed CMake package configuration. Call `cpp_library_enable_dependency_tracking()` before `project()`:
- ✅ No manual mapping needed for namespaced dependencies
266
-
267
-
**Special Case: Non-namespaced Targets**
268
-
269
-
For non-namespaced targets (like `opencv_core`), the provider cannot determine which package they came from. Use `cpp_library_map_dependency()` to map them:
find_dependency(OpenCV 4.5.0) # Mapped from opencv_core and opencv_imgproc
288
-
```
289
-
290
-
**Note:** Namespaced targets like `Qt6::Core` and `Boost::filesystem` work automatically - the provider tracks the original `find_package()` calls and handles component merging automatically.
291
-
292
240
### Updating cpp-library
293
241
294
242
To update to the latest version of cpp-library in your project:
Registers a custom dependency mapping for `find_dependency()` generation in installed CMake package config files.
415
-
416
-
**Parameters:**
417
-
418
-
-`target`: The target name, either namespaced (e.g., `"Qt5::Core"`, `"stlab::enum-ops"`) or non-namespaced (e.g., `"opencv_core"`)
419
-
-`find_dependency_call`: The complete arguments to pass to `find_dependency()`, including version and any special syntax (e.g., `"Qt5 5.15.0 COMPONENTS Core"`, `"OpenCV 4.5.0"`)
420
-
421
-
**When to use:**
422
-
423
-
-**Required** for non-namespaced targets (e.g., `opencv_core`) - these cannot be automatically detected
424
-
- When automatic version detection fails (cpp-library will generate an error with a helpful example)
425
-
- Dependencies requiring `COMPONENTS` or other special `find_package()` syntax
426
-
- When you need to override automatically detected versions
427
-
428
-
**Automatic behavior:**
429
-
430
-
For namespaced targets (e.g., `Namespace::Target`), cpp-library automatically detects dependency versions from CMake's `<PackageName>_VERSION` variable (set by `find_package()` or CPM after fetching). Most namespaced dependencies work automatically without any mapping needed. If automatic detection fails, you'll get a clear error message showing exactly how to fix it.
The generated config file will include your mappings (note merged Qt components):
486
-
487
-
```cmake
488
-
find_dependency(OpenCV 4.5.0) # From Example 1
489
-
find_dependency(Qt6 6.5.0 COMPONENTS Core Widgets Network) # From Example 2 (merged)
490
-
find_dependency(stlab-enum-ops 1.0.0) # From Example 3
491
-
find_dependency(stlab-copy-on-write 2.1.0) # From Example 3
492
-
```
493
-
494
-
**Note:** Version constraints in `find_dependency()` specify *minimum* versions. Consuming projects can override these with their own version requirements in `find_package()` or `CPMAddPackage()`.
370
+
Namespaced targets like `Qt6::Core` and `Boost::filesystem` are tracked automatically.
495
371
496
372
### Path Conventions
497
373
@@ -592,46 +468,26 @@ Note: Repository names include the namespace prefix for CPM compatibility and co
592
468
593
469
## Troubleshooting
594
470
595
-
### Version Detection Fails
596
-
597
-
**Problem**: Error message: "Cannot determine version for dependency..."
598
-
599
-
**Solution**: Add explicit version mapping before `cpp_library_setup()`:
**Solution**: Ensure `cpp_library_enable_dependency_tracking()` is called before `project()`, and all dependencies are added after `project()` but before `cpp_library_setup()`.
629
485
630
-
### CPM Cannot Find Package
486
+
### CPM Repository Name Mismatch
631
487
632
-
**Problem**: `CPMAddPackage("gh:stlab/enum-ops@1.0.0")` fails with `CPM_USE_LOCAL_PACKAGES`
488
+
**Problem**: `CPMAddPackage()` fails with `CPM_USE_LOCAL_PACKAGES`
633
489
634
-
**Solution**: Repository name must match package name. If package name is `stlab-enum-ops`, repository must be`stlab/stlab-enum-ops`, not `stlab/enum-ops`.
490
+
**Solution**: Repository name must match package name. For package `stlab-enum-ops`, use repository`stlab/stlab-enum-ops`, not `stlab/enum-ops`.
0 commit comments