Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INSTALL] add cmake components to the package #3220

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dbarker
Copy link
Contributor

@dbarker dbarker commented Dec 23, 2024

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 the find_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.

# only find and include the api target
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api)

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.

# include all targets and find all dependencies of the package
find_package(opentelemetry-cpp CONFIG REQUIRED)

Changes

  1. Breaks up the single opentelemetry-cpp-target.cmake file into target files per component by updating the CMake install commands that create export sets in the CMakeLists.txt files for each of the targets.
  2. Updates the opentelemetry-cpp-config.cmake to include a complete list of all components and all targets. This file now reacts to the opentelemetry-cpp_FIND_COMPONENTS list set by find_package when a developer adds the COMPONENTS arguments.
  3. Updates the INSTALL.md file with the proposed components to targets mapping and guidance on usage.
  4. TODO - add ci tests on the installed packages/components/targets.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

Copy link

netlify bot commented Dec 23, 2024

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 80a3cb3
🔍 Latest deploy log https://app.netlify.com/sites/opentelemetry-cpp-api-docs/deploys/676a0181f03f5a0008727e3a

@dbarker
Copy link
Contributor Author

dbarker commented Dec 23, 2024

Posting this as draft and seeking feedback. Interested in thoughts/concerns on the general approach and the proposed component to target mapping.

If the proposed changes look reasonable, I'd be happy to add the ci tests to verify the changes.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.16%. Comparing base (4998eb1) to head (80a3cb3).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3220   +/-   ##
=======================================
  Coverage   88.16%   88.16%           
=======================================
  Files         198      198           
  Lines        6224     6224           
=======================================
  Hits         5487     5487           
  Misses        737      737           

@dbarker dbarker changed the title add cmake components to group targets [INSTALL] add cmake components to the package Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CMake find_package for opentelemetry-cpp components
1 participant