[CMAKE] Add support for CMake component deprecation and update the policy#4272
[CMAKE] Add support for CMake component deprecation and update the policy#4272dbarker wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4272 +/- ##
==========================================
- Coverage 81.25% 81.24% -0.01%
==========================================
Files 446 446
Lines 18872 18872
==========================================
- Hits 15332 15330 -2
- Misses 3540 3542 +2 🚀 New features to boost your workflow:
|
…ake file. Add test for component deprecation. Update ci scripts to support running the tests. Add the tests to the cmake.install CI workflow. Address review feedback - set old_component_FOUND when the new name is resolved
Thanks @lalitb. I've addressed the feedback. To add the small test I've moved the existing install "usage tests" into an |
… changed the structure of the message.
| get_property(_REPLACEMENT_COMPONENT DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| PROPERTY OTEL_COMPONENT_REPLACEMENT_${_DEPRECATED_COMPONENT}) | ||
| message(STATUS " Deprecated COMPONENT ${_DEPRECATED_COMPONENT}") | ||
| if(_REPLACEMENT_COMPONENT) |
There was a problem hiding this comment.
The alias resolver is single-pass over the original request list: foreach(_COMPONENT IN LISTS ${requested_components_inout}) iterates the input, and the replacement is only list(APPEND)-ed to _result, so a replacement that is itself deprecated is never resolved further. That makes this a one-hop lookup rather than a resolve-to-final.
| function(resolve_deprecated_components requested_components_inout) | ||
| set(_result ${${requested_components_inout}}) | ||
| foreach(_COMPONENT IN LISTS ${requested_components_inout}) | ||
| if(${_COMPONENT} IN_LIST OTEL_DEPRECATED_COMPONENTS_LIST) |
There was a problem hiding this comment.
if() re-dereferences an unquoted left operand that names a defined variable, so if(${_COMPONENT} IN_LIST ...) can take the wrong branch.
| endif() | ||
|
|
||
| # Test components added: | ||
| set(TEST_COMPONENT_TARGETS |
Fixes # (issue)
The project provides CMake components in the installed package for use with
find_package(opentelemetry-cpp COMPONENTS ...). The names of the components and targets they import are user facing and need a path for deprecation as things change.Some use cases for this include:
The config builder components can be merged with the exporter components they depend on since they bring in no new dependencies.
This PR adds support to the
otel_install_componentCMake function for renaming and merging components while deprecating old component names. Users who callfind_packageon a deprecated component name will see a deprecation warning while the old component name resolves to the new component name.This change is a part of #4240 and tested in that PR.
Changes
otel_install_componentfunctionFor significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes