Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d89c800
add support for cmake component deprecation and policy
dbarker Jul 21, 2026
a30f9fb
update deprecation policy
dbarker Jul 21, 2026
8832698
Merge branch 'main' into cmake_support_component_deprecation
ThomsonTan Jul 22, 2026
e585b0d
move cmake install function tests to their own sub folder and main cm…
dbarker Jul 23, 2026
84199e2
explicitly disable all extra componenents and tests
dbarker Jul 24, 2026
47a21c1
disable preview options that bring in ryml
dbarker Jul 24, 2026
634abea
Merge branch 'main' into cmake_support_component_deprecation
dbarker Jul 24, 2026
72cdd88
remove check on the deprecation message. Newer versions of CMake have…
dbarker Jul 24, 2026
1b861d9
Merge branch 'main' into cmake_support_component_deprecation
ThomsonTan Jul 25, 2026
58940a7
Merge branch 'main' into cmake_support_component_deprecation
dbarker Jul 26, 2026
763f037
cmake install function test cleanup and fixes
dbarker Jul 26, 2026
97d2680
fix cmake test arguments for cxx standard and -C/S options
dbarker Jul 26, 2026
15b2377
fix conan tests
dbarker Jul 26, 2026
bd53e99
Merge branch 'main' into cmake_support_component_deprecation
dbarker Jul 30, 2026
78c26c2
Merge branch 'main' into cmake_support_component_deprecation
dbarker Jul 30, 2026
4389c43
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 2, 2026
8bcb3e3
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 5, 2026
22a95fd
add changelog entry
dbarker Aug 5, 2026
f40b420
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 8, 2026
d06dc59
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 10, 2026
d0f895b
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 11, 2026
44bb2da
Merge branch 'main' into cmake_support_component_deprecation
marcalff Aug 13, 2026
8a7b32a
Merge branch 'main' into cmake_support_component_deprecation
dbarker Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/cmake_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- name: Build dependencies with vcpkg submodule
run: |
./ci/setup_windows_ci_environment.ps1
- name: Run Install Functions Tests
run: ./ci/do_ci.ps1 cmake.install_functions.test
- name: Run Tests
run: ./ci/do_ci.ps1 cmake.install.test
- name: Run DLL Tests
Expand All @@ -51,6 +53,8 @@ jobs:
- name: Build dependencies with vcpkg submodule
run: |
./ci/setup_windows_ci_environment.ps1
- name: Run Install Functions Tests
run: ./ci/do_ci.ps1 cmake.install_functions.test
- name: Run Tests
run: ./ci/do_ci.ps1 cmake.install.test

Expand Down Expand Up @@ -78,6 +82,8 @@ jobs:
sudo -E apt-get update
sudo -E apt-get install -y libabsl-dev libcurl4-openssl-dev zlib1g-dev nlohmann-json3-dev libprotobuf-dev libgrpc++-dev protobuf-compiler protobuf-compiler-grpc
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "googletest;benchmark"
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -108,6 +114,8 @@ jobs:
- name: Install Dependencies
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_latest
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -138,6 +146,8 @@ jobs:
- name: Install Dependencies
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_stable
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -172,6 +182,8 @@ jobs:
- name: Install Dependencies
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_minimum
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -209,6 +221,8 @@ jobs:
run: |
conan install install/conan/conanfile_stable.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
conan cache clean --source --build
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -248,6 +262,8 @@ jobs:
run: |
conan install install/conan/conanfile_latest.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
conan cache clean --source --build
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -288,6 +304,8 @@ jobs:
run: |
conan install install/conan/conanfile_stable.txt --build=missing -of /Users/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
conan cache clean --source --build
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down Expand Up @@ -320,6 +338,8 @@ jobs:
brew install grpc
brew install nlohmann-json
brew install prometheus-cpp
- name: Run Install Functions Tests
run: ./ci/do_ci.sh cmake.install_functions.test
- name: Run Tests (static libs)
env:
BUILD_SHARED_LIBS: 'OFF'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Increment the:
`json_assign_visitor` in the Elasticsearch log exporter, and the
`TestMode`/`test_mode` enums in the OTLP functional test binaries.
[#4196](https://github.com/open-telemetry/opentelemetry-cpp/issues/4196)

* [CMAKE] Add support for CMake component deprecation and update the policy
[#4272](https://github.com/open-telemetry/opentelemetry-cpp/pull/4272)

* [METRICS SDK] Fix Windows metrics tail latency on the synchronous record path:
`SyncMetricStorage::attribute_hashmap_lock_` now uses `std::mutex` instead of
`common::SpinLockMutex`. The spin lock's final `sleep_for(1ms)` back-off is
Expand Down
27 changes: 27 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,33 @@ switch ($action) {

exit 0
}
"cmake.install_functions.test" {
Remove-Item -Recurse -Force "$BUILD_DIR\*"
Remove-Item -Recurse -Force "$INSTALL_TEST_DIR\*"
cd "$BUILD_DIR"
mkdir "$BUILD_DIR\install_functions_test"
cd "$BUILD_DIR\install_functions_test"
$INSTALL_FUNCTIONS_CMAKE_OPTIONS = @(
"-DVCPKG_TARGET_TRIPLET=x64-windows",
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
)
$CMAKE_OPTIONS_STRING = $INSTALL_FUNCTIONS_CMAKE_OPTIONS -join " "
cmake "-DCMAKE_PREFIX_PATH=$INSTALL_TEST_DIR" `
"-DINSTALL_TEST_CMAKE_OPTIONS=$CMAKE_OPTIONS_STRING" `
"-DINSTALL_TEST_DIR=$INSTALL_TEST_DIR" `
"-DOPENTELEMETRY_SOURCE_DIR=$SRC_DIR" `
-S "$SRC_DIR\install\test\cmake\install_functions_test"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
ctest -C Debug --output-on-failure
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
exit 0
}
"cmake.dll.install.test" {
cd "$BUILD_DIR"
Remove-Item -Recurse -Force "$BUILD_DIR\*"
Expand Down
13 changes: 13 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,19 @@ elif [[ "$1" == "cmake.do_not_install.test" ]]; then
cmake --build . "${CMAKE_BUILD_ARGS[@]}"
ctest --output-on-failure
exit 0
elif [[ "$1" == "cmake.install_functions.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
rm -rf ${INSTALL_TEST_DIR}/*
export LD_LIBRARY_PATH="${INSTALL_TEST_DIR}/lib:$LD_LIBRARY_PATH"
mkdir -p "${BUILD_DIR}/install_functions_test"
cd "${BUILD_DIR}/install_functions_test"
cmake "-DCMAKE_PREFIX_PATH=${INSTALL_TEST_DIR}" \
"-DINSTALL_TEST_DIR=${INSTALL_TEST_DIR}" \
"-DOPENTELEMETRY_SOURCE_DIR=${SRC_DIR}" \
-S "${SRC_DIR}/install/test/cmake/install_functions_test"
ctest --output-on-failure
exit 0
elif [[ "$1" == "cmake.install.test" ]]; then
if [[ -n "${BUILD_SHARED_LIBS}" && "${BUILD_SHARED_LIBS}" == "ON" ]]; then
CMAKE_OPTIONS+=("-DBUILD_SHARED_LIBS=ON")
Expand Down
55 changes: 48 additions & 7 deletions cmake/find-package-support-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,46 @@
include("${CMAKE_CURRENT_LIST_DIR}/component-definitions.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty-dependency-definitions.cmake")

#-------------------------------------------------------------------------
# Function to resolve deprecated component names to their aliases.
# Components without an alias are removed from the list
#-------------------------------------------------------------------------
function(resolve_deprecated_components requested_components_inout)
set(_result ${${requested_components_inout}})
foreach(_COMPONENT IN LISTS ${requested_components_inout})
if(_COMPONENT IN_LIST OTEL_DEPRECATED_COMPONENTS_LIST)
set(_replacement_var "COMPONENT_${_COMPONENT}_REPLACEMENT")
if(DEFINED ${_replacement_var})
message(DEPRECATION "opentelemetry-cpp: component `${_COMPONENT}` is deprecated, use `${${_replacement_var}}` instead.")
list(REMOVE_ITEM _result ${_COMPONENT})
Comment thread
dbarker marked this conversation as resolved.
Resolved
list(APPEND _result ${${_replacement_var}})
Comment thread
dbarker marked this conversation as resolved.
Resolved
else()
message(DEPRECATION "opentelemetry-cpp: component `${_COMPONENT}` is deprecated with no replacement.")
list(REMOVE_ITEM _result ${_COMPONENT})
endif()
endif()
endforeach()
list(REMOVE_DUPLICATES _result)
set(${requested_components_inout} "${_result}" PARENT_SCOPE)
endfunction()

#-------------------------------------------------------------------------
# Function to set the <package>_<component>_FOUND variable for requested
# deprecated component names that have a replacement component.
#-------------------------------------------------------------------------
function(set_deprecated_components_found requested_components_in)
foreach(_COMPONENT IN LISTS ${requested_components_in})
if(_COMPONENT IN_LIST OTEL_DEPRECATED_COMPONENTS_LIST)
set(_replacement_var "COMPONENT_${_COMPONENT}_REPLACEMENT")
if(DEFINED ${_replacement_var}
AND ${CMAKE_FIND_PACKAGE_NAME}_${${_replacement_var}}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_${_COMPONENT}_FOUND TRUE
CACHE BOOL "whether ${CMAKE_FIND_PACKAGE_NAME} deprecated component ${_COMPONENT} is found (via replacement ${${_replacement_var}})" FORCE)
endif()
endif()
endforeach()
endfunction()

#-------------------------------------------------------------------------
# Function to get installed components.
#-------------------------------------------------------------------------
Expand Down Expand Up @@ -33,7 +73,6 @@ function(get_dependent_components component_in dependent_components_out)
set(${dependent_components_out} ${result} PARENT_SCOPE)
endfunction()


#-------------------------------------------------------------------------
# Function to get requested components.
#-------------------------------------------------------------------------
Expand All @@ -44,13 +83,15 @@ function(get_requested_components installed_components_in requested_components_o
message(DEBUG "get_requested_components: No components explicitly requested. Importing all installed components including: ${result}")
set(${requested_components_out} ${result} PARENT_SCOPE)
else()
message(DEBUG "get_requested_components: Components requested: ${opentelemetry-cpp_FIND_COMPONENTS}")
foreach(_COMPONENT IN LISTS opentelemetry-cpp_FIND_COMPONENTS)
if(NOT ${_COMPONENT} IN_LIST OTEL_BUILT_COMPONENTS_LIST)
set(REQUESTED_COMPONENTS ${opentelemetry-cpp_FIND_COMPONENTS})
message(DEBUG "get_requested_components: Components requested: ${REQUESTED_COMPONENTS}")
resolve_deprecated_components(REQUESTED_COMPONENTS)
foreach(_COMPONENT IN LISTS REQUESTED_COMPONENTS)
if(NOT _COMPONENT IN_LIST OTEL_BUILT_COMPONENTS_LIST)
message(ERROR " get_requested_components: Component `${_COMPONENT}` is not a built component of the opentelemetry-cpp package. Built components include: ${OTEL_BUILT_COMPONENTS_LIST}")
return()
endif()
if(NOT ${_COMPONENT} IN_LIST ${installed_components_in})
if(NOT _COMPONENT IN_LIST ${installed_components_in})
message(ERROR " get_requested_components: Component `${_COMPONENT}` is supported by opentelemetry-cpp but not installed. Installed components include: ${${installed_components_in}}")
return()
endif()
Expand All @@ -69,7 +110,7 @@ endfunction()
#-------------------------------------------------------------------------
function(get_component_targets component_in targets_out)
set(result "")
if(NOT ${component_in} IN_LIST OTEL_BUILT_COMPONENTS_LIST)
if(NOT component_in IN_LIST OTEL_BUILT_COMPONENTS_LIST)
message(ERROR " get_component_targets: Component `${component_in}` component is not a built component of the opentelemetry-cpp package.")
else()
set(targets_var "COMPONENT_${component_in}_TARGETS")
Expand Down Expand Up @@ -116,7 +157,7 @@ endfunction()
#-------------------------------------------------------------------------
function (is_dependency_required dependency_in components_in is_required_out)
foreach(_component IN LISTS ${components_in})
if(${dependency_in} IN_LIST COMPONENT_${_component}_THIRDPARTY_DEPENDS)
if(dependency_in IN_LIST COMPONENT_${_component}_THIRDPARTY_DEPENDS)
set(${is_required_out} TRUE PARENT_SCOPE)
return()
endif()
Expand Down
Loading
Loading