Skip to content

[BUILD] Rename cmake options with prefix OTELCPP_ - #4268

Merged
marcalff merged 13 commits into
open-telemetry:mainfrom
owent:new_cmake_options
Aug 20, 2026
Merged

[BUILD] Rename cmake options with prefix OTELCPP_ #4268
marcalff merged 13 commits into
open-telemetry:mainfrom
owent:new_cmake_options

Conversation

@owent

@owent owent commented Jul 19, 2026

Copy link
Copy Markdown
Member

Fixes #4184

Changes

  • Rename cmake options with prefix OTELCPP_

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

@owent
owent force-pushed the new_cmake_options branch from 98a4eaa to 7f85f9a Compare July 20, 2026 07:01
@owent
owent marked this pull request as ready for review July 20, 2026 07:01
@owent
owent requested a review from a team as a code owner July 20, 2026 07:01
Copilot AI review requested due to automatic review settings July 20, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses CMake option namespace collisions when opentelemetry-cpp is consumed as a subproject (e.g., via FetchContent / add_subdirectory) by introducing an OTELCPP_ prefix for the project’s CMake options and wiring deprecated legacy names to the new ones.

Changes:

  • Introduces OTELCPP_* CMake options (and wrapper helpers) and updates build logic to prefer the new names while warning on legacy names.
  • Updates CMakeLists across components/tests/examples/CI scripts to use OTELCPP_* option checks.
  • Updates documentation, install tests, and packaging/config helpers to reference the new option names.

Reviewed changes

Copilot reviewed 103 out of 103 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/ports/opentelemetry/portfile.cmake Updates example CMake option name in vcpkg port guidance
tools/build.cmd Updates Windows build script to pass renamed options
test_common/src/http/client/nosend/CMakeLists.txt Switches testing guard to OTELCPP_BUILD_TESTING
test_common/src/CMakeLists.txt Switches test_common subdir guard to OTELCPP_BUILD_TESTING
test_common/CMakeLists.txt Switches test_common target guard to OTELCPP_BUILD_TESTING
test_common/cmake/testing-options.cmake Updates cached CI preset options to OTELCPP_* names
test_common/cmake/preview-options.cmake Updates cached preview preset options to OTELCPP_* names
test_common/cmake/example-options.cmake Updates cached example preset options to OTELCPP_* names
test_common/cmake/component-options.cmake Updates cached component preset options to OTELCPP_* names
test_common/cmake/all-options-abiv2.cmake Updates ABI v2 preset options to OTELCPP_* names
test_common/cmake/all-options-abiv2-preview.cmake Updates ABI v2+preview preset options to OTELCPP_* names
test_common/cmake/all-options-abiv1.cmake Updates ABI v1 preset options to OTELCPP_* names
test_common/cmake/all-options-abiv1-preview.cmake Updates ABI v1+preview preset options to OTELCPP_* names
sdk/test/trace/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
sdk/test/metrics/CMakeLists.txt Renames benchmark/preview option checks to OTELCPP_*
sdk/test/common/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
sdk/test/CMakeLists.txt Renames configuration option checks to OTELCPP_WITH_CONFIGURATION
sdk/src/version/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/trace/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/resource/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/metrics/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/logs/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/configuration/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/common/CMakeLists.txt Renames install option checks to OTELCPP_INSTALL
sdk/src/CMakeLists.txt Renames configuration option checks to OTELCPP_WITH_CONFIGURATION
sdk/CMakeLists.txt Renames configuration/testing option checks to OTELCPP_*
resource_detectors/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
opentracing-shim/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
install/test/cmake/fetch_content_test/CMakeLists.txt Adds assertions validating subproject default for OTELCPP_BUILD_TESTING
install/test/cmake/examples_test/CMakeLists.txt Updates installed-component test to set OTELCPP_* options
install/test/cmake/api_only_test/CMakeLists.txt Updates API-only install test to use OTELCPP_* option names
INSTALL.md Updates documented CMake flags to OTELCPP_* equivalents
functional/otlp/CMakeLists.txt Renames functional test option checks to OTELCPP_WITH_OTLP_*
functional/CMakeLists.txt Renames functional test option checks to OTELCPP_WITH_OTLP_HTTP
ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt Renames curl option checks to OTELCPP_WITH_HTTP_CLIENT_CURL
ext/test/http/CMakeLists.txt Renames curl option checks to OTELCPP_WITH_HTTP_CLIENT_CURL
ext/test/CMakeLists.txt Renames W3C test option checks to OTELCPP_BUILD_W3CTRACECONTEXT_TEST
ext/src/http/client/curl/http_client_curl.cc Updates log message to reference OTELCPP_WITH_OTLP_HTTP_COMPRESSION
ext/src/http/client/curl/CMakeLists.txt Renames curl/logging/compression option checks to OTELCPP_*
ext/src/dll/CMakeLists.txt Renames exporter option checks to OTELCPP_WITH_OTLP_*
ext/src/CMakeLists.txt Renames HTTP/client/DLL option checks to OTELCPP_*
ext/include/opentelemetry/ext/http/client/detail/default_factory.h Updates error text to reference OTELCPP_WITH_HTTP_CLIENT_CURL
ext/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
exporters/zipkin/README.md Updates build instructions to OTELCPP_WITH_ZIPKIN
exporters/zipkin/CMakeLists.txt Renames install/testing/curl option checks to OTELCPP_*
exporters/prometheus/CMakeLists.txt Renames install/testing option checks to OTELCPP_*
exporters/otlp/CMakeLists.txt Renames exporter/testing/benchmark option checks to OTELCPP_*
exporters/ostream/CMakeLists.txt Renames testing/install option checks to OTELCPP_*
exporters/memory/CMakeLists.txt Renames install/testing option checks to OTELCPP_*
exporters/etw/CMakeLists.txt Renames testing/benchmark option checks to OTELCPP_*
exporters/elasticsearch/CMakeLists.txt Renames install/testing option checks to OTELCPP_*
exporters/CMakeLists.txt Renames exporter option checks to OTELCPP_WITH_*
examples/tracer_configurator/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/simple/CMakeLists.txt Renames DLL/testing option checks to OTELCPP_*
examples/plugin/CMakeLists.txt Renames dynamic-loading/testing option checks to OTELCPP_*
examples/otlp/CMakeLists.txt Renames OTLP/DLL option checks to OTELCPP_*
examples/multithreaded/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/multi_processor/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/metrics_simple/CMakeLists.txt Renames DLL/testing option checks to OTELCPP_*
examples/logs_simple/CMakeLists.txt Renames DLL/testing option checks to OTELCPP_*
examples/logger_configurator/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/http/CMakeLists.txt Renames curl option checks to OTELCPP_WITH_HTTP_CLIENT_CURL
examples/explicit_parent/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/etw_threads/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/environment_carrier/CMakeLists.txt Renames DLL/testing option checks to OTELCPP_*
examples/custom_http_client/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
examples/configuration/CMakeLists.txt Renames exporter/DLL/testing option checks to OTELCPP_*
examples/common/metrics_foo_library/CMakeLists.txt Renames DLL option check to OTELCPP_BUILD_DLL
examples/common/logs_foo_library/CMakeLists.txt Renames DLL option check to OTELCPP_BUILD_DLL
examples/common/foo_library/CMakeLists.txt Renames DLL option check to OTELCPP_BUILD_DLL
examples/CMakeLists.txt Renames example gating options to OTELCPP_*
examples/batch/CMakeLists.txt Renames testing option checks to OTELCPP_BUILD_TESTING
docs/deprecation-process.md Updates deprecation documentation to use OTELCPP_* option names
docs/dependencies.md Updates STL option reference to OTELCPP_WITH_STL
docs/build-as-dll.md Updates DLL option reference to OTELCPP_BUILD_DLL
docs/abi-version-policy.md Updates ABI option references to OTELCPP_WITH_ABI_VERSION_*
docs/abi-policy.md Updates STL option reference to OTELCPP_WITH_STL
docker/Dockerfile Updates docker build flags to OTELCPP_* options
CMakeSettings.json Updates VS CMakeSettings variables to OTELCPP_* options
CMakeLists.txt Adds OTELCPP_* options, subproject-friendly defaults, and legacy option forwarding
cmake/tools.cmake Introduces helper wrappers to define options with deprecated legacy aliases
cmake/ryml.cmake Updates install toggle variable to OTELCPP_INSTALL
cmake/protobuf.cmake Updates install/utf8 validity option usage to OTELCPP_*
cmake/patch-imported-config.cmake Renames testing option checks to OTELCPP_BUILD_TESTING
cmake/package.cmake Renames package/tarball option to OTELCPP_TARBALL
cmake/opentelemetry-proto.cmake Renames OTLP gRPC/install checks to OTELCPP_*
cmake/opentelemetry-build-external-component.cmake Renames external component path option to OTELCPP_EXTERNAL_COMPONENT_PATH
cmake/nlohmann-json.cmake Updates install toggle variable to OTELCPP_INSTALL
cmake/ms-gsl.cmake Updates install toggle variable to OTELCPP_INSTALL
cmake/grpc.cmake Updates install toggle variable to OTELCPP_INSTALL
cmake/curl.cmake Updates install toggle variable to OTELCPP_INSTALL
ci/README.md Updates CI documentation to reference OTELCPP_WITH_STL
ci/do_ci.sh Updates CI CMake configure flags to OTELCPP_* options
ci/do_ci.ps1 Updates Windows CI CMake configure flags to OTELCPP_* options
CHANGELOG.md Documents the CMake option renames and deprecation/precedence rules
api/test/trace/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
api/test/logs/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
api/test/common/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
api/test/CMakeLists.txt Renames dynamic-loading option checks to OTELCPP_SKIP_DYNAMIC_LOADING_TESTS
api/test/baggage/CMakeLists.txt Renames benchmark option checks to OTELCPP_WITH_BENCHMARK
api/CMakeLists.txt Renames core build option checks to OTELCPP_* and updates related messages
.github/workflows/codeql-analysis.yml Updates CodeQL workflow configure flags to OTELCPP_WITH_OPENTRACING
.github/copilot-instructions.md Updates documented build flags to OTELCPP_* options

Comment thread CMakeLists.txt
Comment thread test_common/src/http/client/nosend/CMakeLists.txt Outdated
Comment thread tools/build.cmd Outdated
Comment thread tools/build.cmd Outdated
Comment thread exporters/otlp/CMakeLists.txt
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.62%. Comparing base (1d54d33) to head (e73732e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4268      +/-   ##
==========================================
- Coverage   82.63%   82.62%   -0.00%     
==========================================
  Files         512      512              
  Lines       20138    20138              
==========================================
- Hits        16639    16637       -2     
- Misses       3499     3501       +2     
Files with missing lines Coverage Δ
...telemetry/ext/http/client/detail/default_factory.h 100.00% <ø> (ø)
ext/src/http/client/curl/http_client_curl.cc 90.33% <ø> (ø)

... and 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.

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Please see initial feedback below. We'll need to add some CI testing for the conversion since it can be high impact.

Comment thread test_common/cmake/all-options-abiv1-preview.cmake
Comment thread tools/build.cmd Outdated
Comment thread CMakeSettings.json
Comment thread cmake/tools.cmake Outdated
@owent
owent force-pushed the new_cmake_options branch 2 times, most recently from 1857a05 to 953ec4b Compare July 21, 2026 17:51
Comment thread CHANGELOG.md Outdated

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the updates. Please see some feedback and questions below.

Comment thread ci/do_ci.sh
Comment thread CMakeLists.txt Outdated
Comment thread cmake/tools.cmake
Comment thread cmake/tools.cmake
@owent
owent force-pushed the new_cmake_options branch 2 times, most recently from 4c5b9f4 to 74f1718 Compare July 27, 2026 13:32
@dbarker dbarker added discuss To discuss in SIG meeting pr:please-review This PR is ready for review labels Jul 27, 2026
@owent
owent force-pushed the new_cmake_options branch from 74f1718 to a19dbd8 Compare July 28, 2026 06:19
Comment thread ci/do_ci.sh
Comment thread CMakeLists.txt Outdated
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread api/CMakeLists.txt
@dbarker

dbarker commented Jul 28, 2026

Copy link
Copy Markdown
Member

Thanks for the PR @owent ! Please see some feedback above. The main risk I see is that on the next release this change will trigger CMake deprecation warnings in many projects. This is communicated in the release notes well, but may still cause friction as CI workflows will need to be updated. Leaving the discuss tag on the PR to get feedback from others in the SIG meetings coming up.

@owent
owent force-pushed the new_cmake_options branch 2 times, most recently from d373649 to d9abef6 Compare July 30, 2026 15:55
Comment thread ext/src/dll/input.src
Comment thread cmake/tools.cmake Outdated
Comment thread CMakeLists.txt Outdated
@owent
owent force-pushed the new_cmake_options branch from 01902b3 to 4192a30 Compare August 4, 2026 15:11
@dbarker dbarker added the pr:fix-merge-conflicts Please fix merge conflicts for this pr label Aug 8, 2026
@owent
owent requested a review from lalitb August 9, 2026 14:19
@owent
owent force-pushed the new_cmake_options branch from 4192a30 to c94de26 Compare August 17, 2026 08:12
@owent
owent force-pushed the new_cmake_options branch from c94de26 to 647ced2 Compare August 17, 2026 09:07
@dbarker dbarker removed the pr:fix-merge-conflicts Please fix merge conflicts for this pr label Aug 17, 2026

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix.

Please move changes to file ./ext/src/dll/input.src to a separate PR.

This helps investigations in general, like when using git bisect, as this change seems unrelated.

Looks ok otherwise.

owent added 11 commits August 20, 2026 12:23
Fixes OTELCPP_BUILD_DLL and markdownlint

Fixes formatting

Fixes OTELCPP_BUILD_TESTING and add CHANGELOG

^ Conflicts:
^	sdk/src/CMakeLists.txt
^	sdk/src/configuration/CMakeLists.txt
^	sdk/test/CMakeLists.txt

^ Conflicts:
^	CHANGELOG.md
^	install/test/cmake/examples_test/CMakeLists.txt

^ Conflicts:
^	ci/do_ci.sh
^	examples/configuration/CMakeLists.txt
^	exporters/otlp/CMakeLists.txt
^	sdk/src/configuration/CMakeLists.txt
Using a map to maintain legacy options

Add legacy option checking

Fixes zlib dep
…iffers. Add available conditions for otelcpp_option_flag.
@owent
owent force-pushed the new_cmake_options branch from 3265dad to 2256650 Compare August 20, 2026 04:25
@owent owent mentioned this pull request Aug 20, 2026
3 tasks
@owent

owent commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Thanks for the fix.

Please move changes to file ./ext/src/dll/input.src to a separate PR.

This helps investigations in general, like when using git bisect, as this change seems unrelated.

Looks ok otherwise.

The changes in ./ext/src/dll/input.sr is reverted. And so CI / CMake -> exporter proto (Build as DLL) (pull_request) failed.

I raise another PR #4461 to add these symbols.

@owent
owent requested a review from marcalff August 20, 2026 06:25
@marcalff
marcalff dismissed their stale review August 20, 2026 09:27

Resolved

@marcalff marcalff changed the title Rename cmake options with prefix OTELCPP_ [BUILD] Rename cmake options with prefix OTELCPP_ Aug 20, 2026
@marcalff

Copy link
Copy Markdown
Member

Thanks for the fix.
Please move changes to file ./ext/src/dll/input.src to a separate PR.
This helps investigations in general, like when using git bisect, as this change seems unrelated.
Looks ok otherwise.

The changes in ./ext/src/dll/input.sr is reverted. And so CI / CMake -> exporter proto (Build as DLL) (pull_request) failed.

I raise another PR #4461 to add these symbols.

Thanks @owent.

This is my analysis of why it failed:

Before this fix, the windows DLL CI used:

  "cmake.exporter.otprotocol.dll.test" {
    cd "$BUILD_DIR"
    cmake $SRC_DIR `
      -DVCPKG_TARGET_TRIPLET=x64-windows `
      -DOPENTELEMETRY_BUILD_DLL=1 `
      -DWITH_OTPROTCOL=ON `
      "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"

It turns out WITH_OTPROTCOL=ON does nothing, so the single DLL was built without OTLP GRPC and without OTLP HTTP, and it passed.

With this change, the single DDL is built with:

      -DOTELCPP_BUILD_DLL=1 `
      -DOTELCPP_WITH_OTLP_GRPC=ON `
      -DOTELCPP_WITH_OTLP_HTTP=ON `

which means OTLP GRPC and OTLP HTTP are now included, and it failed because of missing exports.

The missing exports are now fixed in #4461 which is an issue of its own.
This work, #4268, just exposed an existing issue while cleaning up cmake options.

Comment thread sdk/src/configuration/CMakeLists.txt Outdated

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Thanks @owent

@marcalff
marcalff merged commit 7ea30f4 into open-telemetry:main Aug 20, 2026
75 checks passed
@owent
owent deleted the new_cmake_options branch September 3, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discuss To discuss in SIG meeting pr:please-review This PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CMAKE] Add an OTELCPP_ prefix to CMake options

6 participants