Skip to content

Commit b46ca96

Browse files
authored
[Build] Bring your own dependency: opentelemetry-proto (#1730)
1 parent b89f981 commit b46ca96

File tree

3 files changed

+64
-21
lines changed

3 files changed

+64
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Increment the:
1919
[#1727](https://github.com/open-telemetry/opentelemetry-cpp/pull/1727)
2020
* [METRICS SDK] - Remove old metrics from Github CI
2121
[#1733](https://github.com/open-telemetry/opentelemetry-cpp/pull/1733)
22+
* [BUILD] Add CMake OTELCPP_PROTO_PATH [#1730](https://github.com/open-telemetry/opentelemetry-cpp/pull/1730)
2223

2324
## [1.7.0] 2022-10-28
2425

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF)
168168

169169
option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF)
170170

171+
set(OTELCPP_PROTO_PATH
172+
""
173+
CACHE PATH "Path to opentelemetry-proto")
174+
171175
if(WIN32)
172176
if(BUILD_TESTING)
173177
if(MSVC)

cmake/opentelemetry-proto.cmake

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,65 @@
1-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)
2-
set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
#
5+
# The dependency on opentelemetry-proto can be provided different ways.
6+
# By order of decreasing priority, options are:
7+
#
8+
# 1 - Use a provided package
9+
#
10+
# This is useful to build opentelemetry-cpp as part of a super project.
11+
#
12+
# The super project provides the path to the opentelemetry-proto
13+
# source code using variable ${OTELCPP_PROTO_PATH}
14+
#
15+
# 2 - Search for a opentelemetry-proto git submodule
16+
#
17+
# When git submodule is used,
18+
# the opentelemetry-proto code is located in:
19+
# third_party/opentelemetry-proto
20+
#
21+
# 3 - Download opentelemetry-proto from github
22+
#
23+
# Code from the required version is used,
24+
# unless a specific release tag is provided
25+
# in variable ${opentelemetry-proto}
26+
#
27+
28+
if(OTELCPP_PROTO_PATH)
29+
if(NOT EXISTS(${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto))
30+
message(FATAL_ERROR "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository")
31+
endif()
32+
message(STATUS "opentelemetry-proto dependency satisfied by: external path")
33+
set(PROTO_PATH ${OTELCPP_PROTO_PATH})
334
set(needs_proto_download FALSE)
435
else()
5-
if("${opentelemetry-proto}" STREQUAL "")
6-
set(opentelemetry-proto "v0.19.0")
36+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)
37+
message(STATUS "opentelemetry-proto dependency satisfied by: git submodule")
38+
set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")
39+
set(needs_proto_download FALSE)
40+
else()
41+
message(STATUS "opentelemetry-proto dependency satisfied by: github download")
42+
if("${opentelemetry-proto}" STREQUAL "")
43+
set(opentelemetry-proto "v0.19.0")
44+
endif()
45+
include(ExternalProject)
46+
ExternalProject_Add(
47+
opentelemetry-proto
48+
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-proto.git
49+
GIT_TAG "${opentelemetry-proto}"
50+
UPDATE_COMMAND ""
51+
BUILD_COMMAND ""
52+
INSTALL_COMMAND ""
53+
CONFIGURE_COMMAND ""
54+
TEST_AFTER_INSTALL 0
55+
DOWNLOAD_NO_PROGRESS 1
56+
LOG_CONFIGURE 1
57+
LOG_BUILD 1
58+
LOG_INSTALL 1)
59+
ExternalProject_Get_Property(opentelemetry-proto INSTALL_DIR)
60+
set(PROTO_PATH "${INSTALL_DIR}/src/opentelemetry-proto")
61+
set(needs_proto_download TRUE)
762
endif()
8-
include(ExternalProject)
9-
ExternalProject_Add(
10-
opentelemetry-proto
11-
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-proto.git
12-
GIT_TAG "${opentelemetry-proto}"
13-
UPDATE_COMMAND ""
14-
BUILD_COMMAND ""
15-
INSTALL_COMMAND ""
16-
CONFIGURE_COMMAND ""
17-
TEST_AFTER_INSTALL 0
18-
DOWNLOAD_NO_PROGRESS 1
19-
LOG_CONFIGURE 1
20-
LOG_BUILD 1
21-
LOG_INSTALL 1)
22-
ExternalProject_Get_Property(opentelemetry-proto INSTALL_DIR)
23-
set(PROTO_PATH "${INSTALL_DIR}/src/opentelemetry-proto")
24-
set(needs_proto_download TRUE)
2563
endif()
2664

2765
include(${PROJECT_SOURCE_DIR}/cmake/proto-options-patch.cmake)

0 commit comments

Comments
 (0)