Rename cmake options with prefix OTELCPP_ #4268
Conversation
Fixes OTELCPP_BUILD_DLL and markdownlint Fixes formatting Fixes OTELCPP_BUILD_TESTING and add CHANGELOG
There was a problem hiding this comment.
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4268 +/- ##
==========================================
- Coverage 81.19% 81.18% -0.01%
==========================================
Files 444 444
Lines 18880 18880
==========================================
- Hits 15328 15325 -3
- Misses 3552 3555 +3
🚀 New features to boost your workflow:
|
dbarker
left a comment
There was a problem hiding this comment.
Thanks! Please see initial feedback below. We'll need to add some CI testing for the conversion since it can be high impact.
|
|
||
| # Enable all options with ABI V1 including preview features | ||
|
|
||
| set(WITH_ABI_VERSION_1 ON CACHE BOOL "" FORCE) |
There was a problem hiding this comment.
Can we add a test .cmake file with all the old options and map to their new names? This would let us verify the conversion works in a CI test that configures the project with old options and checks that all the new options are set in the cache. These all-options files should be the source of truth for what options are supported.
| REM Build with nostd implementation. | ||
| REM ########################################################################################## | ||
| set CONFIG=-DWITH_STL:BOOL=OFF %* | ||
| set CONFIG=-DOTELCPP_WITH_STL:BOOL=OFF %* |
There was a problem hiding this comment.
is this file still used or can be removed?
| "msvc_x64_x64" | ||
| ], | ||
| "buildRoot": "${projectDir}\\out\\vs2019\\${name}", | ||
| "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", |
There was a problem hiding this comment.
is this file still used or can be removed?
| endfunction() | ||
|
|
||
| function(_otelcpp_get_legacy_option_name __OPTION_NAME __OUTPUT_VARIABLE) | ||
| if(__OPTION_NAME MATCHES "^OTELCPP_WITH_") |
There was a problem hiding this comment.
The _otelcpp_get_legacy_option_name function currently encodes the old to new mapping as a chain of elseif branches. It makes a bit more challenging to review for completeness. Since the list of options isn't too large, consider replacing the elseif statements here with a single list (in its own cmake/otelcpp_option_map.cmake):
# Each entry is a pair: OLD_NAME;NEW_NAME
set(_OTELCPP_LEGACY_OPTION_MAP
"WITH_OTLP_GRPC;OTELCPP_WITH_OTLP_GRPC"
"BUILD_W3CTRACECONTEXT_TEST;OTELCPP_BUILD_W3CTRACECONTEXT_TEST"
"OPENTELEMETRY_INSTALL;OTELCPP_INSTALL"
# ...
)_otelcpp_get_legacy_option_name would then loop over that list to find the matching new name, and CMake tests could include the same file and iterate the pairs directly. That way we have a single source of truth for the option name changes. What do you think?
Fixes #4184
Changes
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes