Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CMAKE] update cmake files in examples directory #3421

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

Merged

Conversation

dbarker
Copy link
Contributor

@dbarker dbarker commented May 16, 2025

Fixes #3399

Updates the examples' cmake files to use the read-only ALIAS targets of opentelemetry-cpp added by #3368 and to use explicitly scoped target properties.

Changes

  • Use public read-only opentelemetry-cpp ALIAS targets (ie: opentelemetry-cpp::api in place of opentelemetry_api)
  • Use target_compile_definitions in place of add_definitions
  • Use target_include_directories in place of include_directories
  • Add explicit scope keywords (ie: PRIVATE, PUBLIC) to target_link_libraries
  • Remove some redundant target linking and includes
    • Rely on the transitive PUBLIC target properties (definitions, linked libraries, include directories)
  • Replace CMAKE_THREAD_LIBS_INIT with the Threads::Threads target where needed, otherwise remove it and rely on the opentelemetry-cpp::common target's public transitive link to Threads.
  • Update the dll target (opentelemetry-cpp::opentelemetry_cpp) to include the directories for headers it depends on. Update the ext_dll component install test to verify.

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 May 16, 2025

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

Name Link
🔨 Latest commit 6eb9fa3
🔍 Latest deploy log https://app.netlify.com/projects/opentelemetry-cpp-api-docs/deploys/682b1521bd500d0008a6e153

Copy link

codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.05%. Comparing base (ba04dbb) to head (6eb9fa3).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3421      +/-   ##
==========================================
+ Coverage   90.04%   90.05%   +0.02%     
==========================================
  Files         212      212              
  Lines        6932     6932              
==========================================
+ Hits         6241     6242       +1     
+ Misses        691      690       -1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…arget. Update the dll component install test to rely on the tranisitive include directories.
@dbarker dbarker marked this pull request as ready for review May 16, 2025 22:30
@dbarker dbarker requested a review from a team as a code owner May 16, 2025 22:30
Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

BTW: Not a problem of this PR, but should OPENTELEMETRY_BUILD_IMPORT_DLL be interface definition of opentelemetry_cpp in ext/src/dll/CMakeLists.txt)? @ThomsonTan

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix

@marcalff marcalff merged commit 82ec2a5 into open-telemetry:main May 19, 2025
67 checks passed
@dbarker dbarker deleted the feature_update_examples_cmake_usage branch May 20, 2025 03:08
@ThomsonTan
Copy link
Contributor

OPENTELEMETRY_BUILD_IMPORT_DLL

LGTM.

BTW: Not a problem of this PR, but should OPENTELEMETRY_BUILD_IMPORT_DLL be interface definition of opentelemetry_cpp in ext/src/dll/CMakeLists.txt)? @ThomsonTan

Yes, I think this is good suggestion. Opened below issue for tracking.

#3436

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.

Use the public read-only opentelemetry-cpp namespace cmake targets in examples
5 participants