|
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 | # |
5 | | -# The dependency on opentelemetry-proto can be provided different ways. By order |
| 5 | +# The dependency on opentelemetry-proto can be provided by order |
6 | 6 | # of decreasing priority, options are: |
7 | 7 | # |
8 | | -# 1 - Use a provided package |
| 8 | +# 1 - Fetch from local source directory defined by the OTELCPP_PROTO_PATH variable |
9 | 9 | # |
10 | | -# This is useful to build opentelemetry-cpp as part of a super project. |
| 10 | +# 2 - Fetch from the opentelemetry-proto git submodule (opentelemetry-cpp/third_party/opentelemetry-proto) |
11 | 11 | # |
12 | | -# The super project provides the path to the opentelemetry-proto source code |
13 | | -# using variable ${OTELCPP_PROTO_PATH} |
14 | | -# |
15 | | -# 2 - Search for a opentelemetry-proto git submodule |
16 | | -# |
17 | | -# When git submodule is used, the opentelemetry-proto code is located in: |
18 | | -# third_party/opentelemetry-proto |
19 | | -# |
20 | | -# 3 - Download opentelemetry-proto from github |
21 | | -# |
22 | | -# Code from the required version is used, unless a specific release tag is |
23 | | -# provided in variable ${opentelemetry-proto} |
| 12 | +# 3 - Fetch from github using the git tag set in opentelemetry-cpp/third_party_release |
24 | 13 | # |
25 | 14 |
|
| 15 | +set(OPENTELEMETRY_PROTO_SUBMODULE "${opentelemetry-cpp_SOURCE_DIR}/third_party/opentelemetry-proto") |
| 16 | + |
26 | 17 | if(OTELCPP_PROTO_PATH) |
27 | 18 | if(NOT EXISTS |
28 | 19 | "${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") |
29 | 20 | message( |
30 | 21 | FATAL_ERROR |
31 | 22 | "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository") |
32 | 23 | endif() |
33 | | - message(STATUS "opentelemetry-proto dependency satisfied by: external path") |
34 | | - set(PROTO_PATH ${OTELCPP_PROTO_PATH}) |
35 | | - set(needs_proto_download FALSE) |
| 24 | + message(STATUS "fetching opentelemetry-proto from OTELCPP_PROTO_PATH=${OTELCPP_PROTO_PATH}") |
| 25 | + FetchContent_Declare( |
| 26 | + opentelemetry-proto |
| 27 | + SOURCE_DIR ${OTELCPP_PROTO_PATH} |
| 28 | + ) |
| 29 | + set(opentelemetry-proto_PROVIDER "fetch_source") |
| 30 | + # If the opentelemetry-proto directory is a general directory then we don't have a good way to determine the version. Set it as unknown. |
| 31 | + set(opentelemetry-proto_VERSION "unknown") |
| 32 | +elseif(EXISTS ${OPENTELEMETRY_PROTO_SUBMODULE}/.git) |
| 33 | + message(STATUS "fetching opentelemetry-proto from git submodule") |
| 34 | + FetchContent_Declare( |
| 35 | + opentelemetry-proto |
| 36 | + SOURCE_DIR ${OPENTELEMETRY_PROTO_SUBMODULE} |
| 37 | + ) |
| 38 | + set(opentelemetry-proto_PROVIDER "fetch_source") |
| 39 | + string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" opentelemetry-proto_VERSION "${opentelemetry-proto_GIT_TAG}") |
36 | 40 | else() |
37 | | - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git) |
38 | | - message(STATUS "opentelemetry-proto dependency satisfied by: git submodule") |
39 | | - set(PROTO_PATH |
40 | | - "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto") |
41 | | - set(needs_proto_download FALSE) |
42 | | - else() |
43 | | - message( |
44 | | - STATUS "opentelemetry-proto dependency satisfied by: github download") |
45 | | - if("${opentelemetry-proto}" STREQUAL "") |
46 | | - file(READ "${CMAKE_CURRENT_LIST_DIR}/../third_party_release" |
47 | | - OTELCPP_THIRD_PARTY_RELEASE_CONTENT) |
48 | | - if(OTELCPP_THIRD_PARTY_RELEASE_CONTENT MATCHES |
49 | | - "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") |
50 | | - set(opentelemetry-proto "${CMAKE_MATCH_1}") |
51 | | - else() |
52 | | - set(opentelemetry-proto "v1.7.0") |
53 | | - endif() |
54 | | - unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) |
55 | | - endif() |
56 | | - include(ExternalProject) |
57 | | - ExternalProject_Add( |
| 41 | + FetchContent_Declare( |
58 | 42 | opentelemetry-proto |
59 | 43 | GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-proto.git |
60 | | - GIT_TAG "${opentelemetry-proto_GIT_TAG}" |
61 | | - UPDATE_COMMAND "" |
62 | | - BUILD_COMMAND "" |
63 | | - INSTALL_COMMAND "" |
64 | | - CONFIGURE_COMMAND "" |
65 | | - TEST_AFTER_INSTALL 0 |
66 | | - DOWNLOAD_NO_PROGRESS 1 |
67 | | - LOG_CONFIGURE 1 |
68 | | - LOG_BUILD 1 |
69 | | - LOG_INSTALL 1) |
70 | | - ExternalProject_Get_Property(opentelemetry-proto INSTALL_DIR) |
71 | | - set(PROTO_PATH "${INSTALL_DIR}/src/opentelemetry-proto") |
72 | | - set(needs_proto_download TRUE) |
73 | | - endif() |
| 44 | + GIT_TAG "${opentelemetry-proto_GIT_TAG}") |
| 45 | + set(opentelemetry-proto_PROVIDER "fetch_repository") |
| 46 | + string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" opentelemetry-proto_VERSION "${opentelemetry-proto_GIT_TAG}") |
74 | 47 | endif() |
75 | 48 |
|
| 49 | +FetchContent_MakeAvailable(opentelemetry-proto) |
| 50 | + |
| 51 | +set(PROTO_PATH "${opentelemetry-proto_SOURCE_DIR}") |
| 52 | + |
76 | 53 | set(COMMON_PROTO "${PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") |
77 | 54 | set(RESOURCE_PROTO |
78 | 55 | "${PROTO_PATH}/opentelemetry/proto/resource/v1/resource.proto") |
@@ -387,9 +364,6 @@ if(WITH_OTLP_GRPC) |
387 | 364 | endif() |
388 | 365 | endif() |
389 | 366 |
|
390 | | -if(needs_proto_download) |
391 | | - add_dependencies(opentelemetry_proto opentelemetry-proto) |
392 | | -endif() |
393 | 367 | set_target_properties(opentelemetry_proto PROPERTIES EXPORT_NAME proto) |
394 | 368 | patch_protobuf_targets(opentelemetry_proto) |
395 | 369 |
|
|
0 commit comments