[INSTALL] add cmake components to the package #3220
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3218
Overview
This PR introduces CMake COMPONENTS to the
opentelemetry-cpp
package. Components are essentially named groups of CMake targets and can be passed to thefind_package
function to more selectively include targets and dependencies.For example, with this PR the following will only include the
opentelemetry-cpp::api
header only target and search for no other dependencies that may be needed by other targets of the package.Using components like this provides developers more control over what targets and dependencies CMake includes and should help reduce the scope of dependency issues a developer may encounter when building their instrumented CMake projects against different versions/configurations of the installed
opentelemetry-cpp
package.Please see the updated
INSTALL.md
file of this PR for the proposed components to targets mapping.Backwards compatibility is covered by including all components and finding all dependencies when the developer does not pass any components to find_package as in the case below.
Changes
opentelemetry-cpp-target.cmake
file into target files per component by updating the CMakeinstall
commands that create export sets in the CMakeLists.txt files for each of the targets.opentelemetry-cpp-config.cmake
to include a complete list of all components and all targets. This file now reacts to theopentelemetry-cpp_FIND_COMPONENTS
list set byfind_package
when a developer adds theCOMPONENTS
arguments.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes