Skip to content

Commit ca4a507

Browse files
committed
move cmake install tests to a top level install dir. Clean up comments and cmake messages. Run the ci install test on the more modern grpc version and with abseil
1 parent 56e6654 commit ca4a507

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+111
-100
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ jobs:
537537
cmake_install_test:
538538
name: CMake install test
539539
runs-on: ubuntu-24.04
540+
env:
541+
INSTALL_TEST_DIR: '/home/runner/install_test'
542+
CXX_STANDARD: '17'
540543
steps:
541544
- uses: actions/checkout@v4
542545
with:
@@ -545,21 +548,21 @@ jobs:
545548
run: |
546549
sudo -E ./ci/setup_googletest.sh
547550
sudo -E ./ci/setup_ci_environment.sh
548-
- name: run cmake install
551+
- name: install dependencies
549552
env:
550-
CXX_STANDARD: '14'
551-
PROTOBUF_VERSION: '21.3'
552-
GRPC_VERSION: 'v1.49.2'
553+
ABSEIL_CPP_VERSION: '20230125.3'
554+
PROTOBUF_VERSION: '23.3'
555+
GRPC_VERSION: 'v1.55.0'
553556
run: |
557+
sudo ./ci/install_abseil.sh
554558
sudo ./ci/install_protobuf.sh
555-
sudo ./ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf
556-
- name: build and run tests
559+
sudo ./ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf -p abseil
560+
- name: build and test
557561
run: |
558-
export OTEL_CPP_TEST_INSTALL_DIR=$HOME/test-install
559562
./ci/do_ci.sh cmake.install.test
560563
- name: verify packages
561564
run: |
562-
export PKG_CONFIG_PATH=$HOME/test-install/lib/pkgconfig:$PKG_CONFIG_PATH
565+
export PKG_CONFIG_PATH=$INSTALL_TEST_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
563566
./ci/verify_packages.sh
564567
565568
plugin_test:

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ if(WITH_PROMETHEUS)
394394
endif()
395395
endif()
396396

397+
message(STATUS "Building WITH_ABSEIL=${WITH_ABSEIL}")
398+
397399
if(WITH_ABSEIL)
398400
if(NOT TARGET absl::strings)
399401
find_package(absl CONFIG REQUIRED)
@@ -796,9 +798,9 @@ if(OPENTELEMETRY_INSTALL)
796798
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake"
797799
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake"
798800
"${CMAKE_CURRENT_BINARY_DIR}/thirdparty-built-with-flags.cmake"
799-
"${CMAKE_CURRENT_LIST_DIR}/cmake/install/component-definitions.cmake"
800-
"${CMAKE_CURRENT_LIST_DIR}/cmake/install/thirdparty-dependency-definitions.cmake"
801-
"${CMAKE_CURRENT_LIST_DIR}/cmake/install/find-package-support-functions.cmake"
801+
"${CMAKE_CURRENT_LIST_DIR}/cmake/component-definitions.cmake"
802+
"${CMAKE_CURRENT_LIST_DIR}/cmake/thirdparty-dependency-definitions.cmake"
803+
"${CMAKE_CURRENT_LIST_DIR}/cmake/find-package-support-functions.cmake"
802804
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
803805
COMPONENT cmake-config)
804806

ci/do_ci.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function run_benchmarks
6262
mkdir -p "${BUILD_DIR}"
6363
[ -z "${PLUGIN_DIR}" ] && export PLUGIN_DIR=$HOME/plugin
6464
mkdir -p "${PLUGIN_DIR}"
65-
[ -z "${OTEL_CPP_TEST_INSTALL_DIR}" ] && export OTEL_CPP_TEST_INSTALL_DIR=$HOME/otel_cpp_test_install
66-
mkdir -p "${OTEL_CPP_TEST_INSTALL_DIR}"
65+
[ -z "${INSTALL_TEST_DIR}" ] && export INSTALL_TEST_DIR=$HOME/install_test
66+
mkdir -p "${INSTALL_TEST_DIR}"
6767

6868
MAKE_COMMAND="make -k -j \$(nproc)"
6969

@@ -232,19 +232,19 @@ elif [[ "$1" == "cmake.abseil.test" ]]; then
232232
elif [[ "$1" == "cmake.opentracing_shim.test" ]]; then
233233
cd "${BUILD_DIR}"
234234
rm -rf *
235-
rm -rf ${OTEL_CPP_TEST_INSTALL_DIR}/*
235+
rm -rf ${INSTALL_TEST_DIR}/*
236236
cmake "${CMAKE_OPTIONS[@]}" \
237237
-DCMAKE_CXX_FLAGS="-Werror -Wno-error=redundant-move $CXXFLAGS" \
238238
-DWITH_OPENTRACING=ON \
239-
-DCMAKE_INSTALL_PREFIX=${OTEL_CPP_TEST_INSTALL_DIR} \
239+
-DCMAKE_INSTALL_PREFIX=${INSTALL_TEST_DIR} \
240240
"${SRC_DIR}"
241241
make -j $(nproc)
242242
make test
243243
make install
244-
export LD_LIBRARY_PATH="${OTEL_CPP_TEST_INSTALL_DIR}/lib:$LD_LIBRARY_PATH"
245-
cmake -S "${SRC_DIR}/cmake/install/test" \
244+
export LD_LIBRARY_PATH="${INSTALL_TEST_DIR}/lib:$LD_LIBRARY_PATH"
245+
cmake -S "${SRC_DIR}/install/test/cmake" \
246246
-B "${BUILD_DIR}/install_test" \
247-
"-DCMAKE_PREFIX_PATH=${OTEL_CPP_TEST_INSTALL_DIR}" \
247+
"-DCMAKE_PREFIX_PATH=${INSTALL_TEST_DIR}" \
248248
"-DCOMPONENTS_TO_TEST=shims_opentracing"
249249
ctest --test-dir "${BUILD_DIR}/install_test" --output-on-failure
250250
exit 0
@@ -425,9 +425,10 @@ elif [[ "$1" == "cmake.do_not_install.test" ]]; then
425425
elif [[ "$1" == "cmake.install.test" ]]; then
426426
cd "${BUILD_DIR}"
427427
rm -rf *
428-
rm -rf ${OTEL_CPP_TEST_INSTALL_DIR}/*
428+
rm -rf ${INSTALL_TEST_DIR}/*
429429
cmake "${CMAKE_OPTIONS[@]}" \
430-
-DCMAKE_INSTALL_PREFIX=${OTEL_CPP_TEST_INSTALL_DIR} \
430+
-DCMAKE_INSTALL_PREFIX=${INSTALL_TEST_DIR} \
431+
-DWITH_ABSEIL=ON \
431432
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
432433
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
433434
-DWITH_OTLP_GRPC=ON \
@@ -442,10 +443,10 @@ elif [[ "$1" == "cmake.install.test" ]]; then
442443
"${SRC_DIR}"
443444
make -j $(nproc)
444445
make install
445-
export LD_LIBRARY_PATH="${OTEL_CPP_TEST_INSTALL_DIR}/lib:$LD_LIBRARY_PATH"
446-
cmake -S "${SRC_DIR}/cmake/install/test" \
446+
export LD_LIBRARY_PATH="${INSTALL_TEST_DIR}/lib:$LD_LIBRARY_PATH"
447+
cmake -S "${SRC_DIR}/install/test/cmake" \
447448
-B "${BUILD_DIR}/install_test" \
448-
"-DCMAKE_PREFIX_PATH=${OTEL_CPP_TEST_INSTALL_DIR}" \
449+
"-DCMAKE_PREFIX_PATH=${INSTALL_TEST_DIR}" \
449450
"-DCOMPONENTS_TO_TEST=api;sdk;ext_common;ext_http_curl;exporters_in_memory;exporters_ostream;exporters_otlp_common;exporters_otlp_file;exporters_otlp_grpc;exporters_otlp_http;exporters_prometheus;exporters_elasticsearch;exporters_zipkin"
450451
ctest --test-dir "${BUILD_DIR}/install_test" --output-on-failure
451452
exit 0
File renamed without changes.

cmake/templates/opentelemetry-cpp-config.cmake.in

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# Finding opentelemetry-cpp in CMake projects
88
# ========================================
99
#
10-
# - find_package(opentelemetry-cpp CONFIG) to import all installed targets and dependencies
10+
# - find_package(opentelemetry-cpp CONFIG REQUIRED) to import all installed targets and dependencies
1111
# - find_package(opentelemetry-cpp CONFIG COMPONENTS ...) to import specific components' targets and dependencies
1212
#
13-
# Supported use cases
13+
# Example usage
1414
# -------------------
1515
#
1616
# 1. **No Components Specified**
@@ -22,28 +22,18 @@
2222
# find_package(opentelemetry-cpp CONFIG REQUIRED)
2323
#
2424
#
25-
# 2. **Subset of Required Components Specified**
25+
# 2. **Components Specified**
2626
#
27-
# If you request only a subset (e.g. one component), the package will import the
28-
# requested component and resolve additional dependencies as needed.
27+
# When a component is specified, its third-party dependencies are found;
28+
# then, targets from that component, along with the components on which it depends, are imported.
2929
#
3030
# .. code-block:: cmake
3131
#
3232
# find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS exporters_otlp_grpc)
3333
#
34-
# 3. **Components Specified Out-of-Order**
35-
#
36-
# The package automatically sorts components based on their inter-dependencies.
37-
# For instance, even if the components are listed out-of-order:
38-
#
39-
# .. code-block:: cmake
40-
#
41-
# find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS exporters_ostream sdk api)
42-
#
43-
# the correct dependency order is applied internally.
4434
#
4535
#.. note::
46-
# To troubleshoot issues with ``find_package(opentelemetry-cpp)``, run CMake with debug logging enabled:
36+
# To troubleshoot issues with ``find_package(opentelemetry-cpp CONFIG REQUIRED)``, run CMake with debug logging enabled:
4737
#
4838
# .. code-block:: bash
4939
#
@@ -74,7 +64,10 @@
7464
# opentelemetry-cpp_<component>_FOUND - True if the requested component is found.
7565
# ::
7666
#
77-
# This module includes the following components for use with `find_package(opentelemetry-cpp COMPONENTS ...)`
67+
#
68+
# CMake Components and Targets Supported
69+
# --------------------
70+
# opentelemetry-cpp supports the following components and targets. This install may include a subset.
7871
#
7972
# COMPONENTS
8073
# api
@@ -158,8 +151,7 @@
158151
#
159152
# - **component-definitions.cmake**
160153
# This file defines the available opentelemetry-cpp components, the targets associated with each
161-
# component, and the inter-component dependency relationships. It ensures that, regardless of the
162-
# order in which components are specified, all necessary dependencies and targets are imported correctly.
154+
# component, and the inter-component dependencies.
163155
#
164156

165157

@@ -205,7 +197,7 @@ set(_OPENTELEMETRY_CPP_TARGETS "")
205197
get_targets(_REQUESTED_COMPONENTS _OPENTELEMETRY_CPP_TARGETS)
206198
check_targets_imported(_OPENTELEMETRY_CPP_TARGETS)
207199

208-
# Set OPENTELEMETRY_CPP_* variables to preserve legacy CMake style
200+
# Set OPENTELEMETRY_CPP_* variables
209201
set(OPENTELEMETRY_CPP_LIBRARIES)
210202

211203
foreach(_TARGET IN LISTS _OPENTELEMETRY_CPP_TARGETS)

cmake/templates/thirdparty-built-with-flags.cmake.in

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# CMAKE flags to capture the build configuration for the insalled package
66
# BUILT_WITH_<dependency> is set to true if the installed package requires that dependency
77
# See the thirdparty-dependency-deinfitions.cmake for the supported dependency list and
8-
# mapping to opentelemetry-cpp components that may require them.
8+
# mapping to opentelemetry-cpp components.
99
#-------------------------------------------------------------------------
1010

1111
# Initialize dependency expected flags
@@ -20,10 +20,6 @@ set(BUILT_WITH_prometheus-cpp FALSE)
2020
set(BUILT_WITH_OpenTracing FALSE)
2121

2222
# absl:
23-
# Expected TRUE if either:
24-
# - WITH_ABSEIL is enabled, OR
25-
# - WITH_OTLP_GRPC is enabled, OR
26-
# - WITH_OTLP_HTTP or WITH_OTLP_FILE is enabled and Protobuf version is at least 3.22.0.
2723
if(@WITH_ABSEIL@)
2824
set(BUILT_WITH_absl TRUE)
2925
elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@ OR @WITH_OTLP_GRPC@)
@@ -35,7 +31,6 @@ elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@ OR @WITH_OTLP_GRPC@)
3531
endif()
3632

3733
# CURL and ZLIB:
38-
# Expected TRUE if WITH_HTTP_CLIENT_CURL is enabled and we're building static libraries.
3934
if(@WITH_HTTP_CLIENT_CURL@ AND NOT "@BUILD_SHARED_LIBS@")
4035
if("@CURL_FOUND@")
4136
set(BUILT_WITH_CURL TRUE)
@@ -46,7 +41,6 @@ if(@WITH_HTTP_CLIENT_CURL@ AND NOT "@BUILD_SHARED_LIBS@")
4641
endif()
4742

4843
# nlohmann_json:
49-
# Expected TRUE if both USE_NLOHMANN_JSON is true and the package was found during build.
5044
if("@USE_NLOHMANN_JSON@" AND "@nlohmann_json_FOUND@")
5145
set(BUILT_WITH_nlohmann_json TRUE)
5246
endif()

cmake/install/thirdparty-dependency-definitions.cmake renamed to cmake/thirdparty-dependency-definitions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(THIRD_PARTY_DEPENDENCIES_SUPPORTED
1818
)
1919

2020
#-----------------------------------------------------------------------
21-
# Flags to determine if find_dependency(dep) or find_dependency(dep CONFIG) should be used
21+
# Flags to determine if CONFIG search mode should be used in find_dependency(...)
2222
#-----------------------------------------------------------------------
2323

2424
# absl

cmake/install/test/CMakeLists.txt renamed to install/test/cmake/CMakeLists.txt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ else()
1313
STATUS "CMAKE_CXX_STANDARD is set to default of ${CMAKE_CXX_STANDARD}")
1414
endif()
1515

16-
include(${CMAKE_SOURCE_DIR}/../../install/component-definitions.cmake)
16+
include(${CMAKE_SOURCE_DIR}/../../../cmake/component-definitions.cmake)
1717

18-
# If COMPONENTS_TO_TEST is not set, then test all components
18+
# Check that COMPONENTS_TO_TEST is set and contains valid components
1919
if(NOT COMPONENTS_TO_TEST)
20-
set(COMPONENTS_TO_TEST ${opentelemetry-cpp_COMPONENTS})
20+
message(FATAL_ERROR "COMPONENTS_TO_TEST is not set")
2121
else()
2222
set(COMPONENTS_ARE_VALID TRUE)
2323
foreach(component ${COMPONENTS_TO_TEST})
@@ -33,11 +33,10 @@ else()
3333
endif()
3434
endif()
3535

36-
set(INSTALL_TEST_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
36+
set(INSTALL_TEST_SRC_DIR "${CMAKE_SOURCE_DIR}/../src")
3737

3838
enable_testing()
3939

40-
message(STATUS "Testing cmake usage for find_package(opentelemetry ...)")
4140
# -----------------------------------------------------------
4241
# CMake Usage tests for find_package(opentelemetry-cpp ...)
4342
#
@@ -52,45 +51,44 @@ add_test(
5251
NAME cmake-usage-no-components-test
5352
COMMAND
5453
${CMAKE_COMMAND} --log-level=DEBUG -S
55-
${CMAKE_SOURCE_DIR}/projects/cmake_usage_tests/no_components -B
54+
${CMAKE_SOURCE_DIR}/usage_tests/no_components -B
5655
build-cmake-usage-no-components-test
5756
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
5857

5958
add_test(
6059
NAME cmake-usage-unsorted-components-test
6160
COMMAND
6261
${CMAKE_COMMAND} --log-level=DEBUG -S
63-
${CMAKE_SOURCE_DIR}/projects/cmake_usage_tests/unsorted_components -B
62+
${CMAKE_SOURCE_DIR}/usage_tests/unsorted_components -B
6463
build-cmake-usage-unsorted-components-test
6564
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
6665

6766
add_test(
6867
NAME cmake-usage-missing-components-test
6968
COMMAND
7069
${CMAKE_COMMAND} --log-level=DEBUG -S
71-
${CMAKE_SOURCE_DIR}/projects/cmake_usage_tests/missing_components -B
70+
${CMAKE_SOURCE_DIR}/usage_tests/missing_components -B
7271
build-cmake-usage-missing-components-test
7372
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
7473

7574
add_test(
7675
NAME cmake-usage-unsupported-components-test
7776
COMMAND
7877
${CMAKE_COMMAND} --log-level=DEBUG -S
79-
${CMAKE_SOURCE_DIR}/projects/cmake_usage_tests/unsupported_components -B
78+
${CMAKE_SOURCE_DIR}/usage_tests/unsupported_components -B
8079
build-cmake-usage-unsupported-components-test
8180
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
8281

8382
# -----------------------------------------------------------
8483
# Test the full package install using legacy cmake build instructions
8584
# find_package(opentelemetry-cpp CONFIG REQUIRED)
86-
message(STATUS "Testing the full package install")
85+
8786
# Test cmake configuration
8887
add_test(
8988
NAME full-package-cmake-config-test
9089
COMMAND
91-
${CMAKE_COMMAND} --log-level=DEBUG -S
92-
${CMAKE_SOURCE_DIR}/projects/package_test -B build-full-package-test
93-
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
90+
${CMAKE_COMMAND} --log-level=DEBUG -S ${CMAKE_SOURCE_DIR}/package_test -B
91+
build-full-package-test -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
9492
-DINSTALL_TEST_SRC_DIR=${INSTALL_TEST_SRC_DIR})
9593

9694
# Build the full package test executable
@@ -106,13 +104,12 @@ add_test(NAME full-package-run-test
106104
# -----------------------------------------------------------
107105
# Loop over all the components to test
108106
foreach(component ${COMPONENTS_TO_TEST})
109-
message(STATUS "Testing the ${component} component install")
110107
# Test cmake configuration
111108
add_test(
112109
NAME component-${component}-cmake-config-test
113110
COMMAND
114111
${CMAKE_COMMAND} --log-level=DEBUG -S
115-
${CMAKE_SOURCE_DIR}/projects/component_tests/${component} -B
112+
${CMAKE_SOURCE_DIR}/component_tests/${component} -B
116113
build-${component}-test -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
117114
-DINSTALL_TEST_SRC_DIR=${INSTALL_TEST_SRC_DIR})
118115

0 commit comments

Comments
 (0)