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
Automate find_dependency generation for installed packages
Added logic to introspect INTERFACE_LINK_LIBRARIES and generate appropriate find_dependency() calls in installed CMake package config files. Updated documentation to explain dependency handling, added a helper function in cpp-library-install.cmake, and modified the config template to include generated dependencies. This ensures downstream users automatically find and link required dependencies.
For information about using installed packages with `find_package()`, see the [CPM.cmake documentation](https://github.com/cpm-cmake/CPM.cmake) about [controlling how dependencies are found](https://github.com/cpm-cmake/CPM.cmake#cpm_use_local_packages).
125
125
126
+
#### Dependency Handling in Installed Packages
127
+
128
+
cpp-library automatically generates correct `find_dependency()` calls in the installed CMake package configuration files by introspecting your target's `INTERFACE_LINK_LIBRARIES`. This ensures downstream users can find and link all required dependencies.
129
+
130
+
**How it works:**
131
+
132
+
When you link dependencies to your target using `target_link_libraries()`, cpp-library analyzes these links during installation and generates appropriate `find_dependency()` calls. For example:
133
+
134
+
```cmake
135
+
# In your library's CMakeLists.txt
136
+
add_library(my-lib INTERFACE)
137
+
138
+
# Link dependencies - these will be automatically handled during installation
139
+
target_link_libraries(my-lib INTERFACE
140
+
stlab::copy-on-write # Internal CPM dependency
141
+
stlab::enum-ops # Internal CPM dependency
142
+
Threads::Threads # System dependency
143
+
)
144
+
```
145
+
146
+
When installed, the generated `my-libConfig.cmake` will include:
0 commit comments