Skip to content

Commit efde010

Browse files
authored
[BUILD] Enable building otel-cpp extensions from main repo (open-telemetry#1937)
1 parent d0452f8 commit efde010

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,8 @@ if(NOT WITH_API_ONLY)
628628
endif()
629629
endif()
630630

631+
include(cmake/opentelemetry-build-external-component.cmake)
632+
631633
if(OPENTELEMETRY_INSTALL)
632634
# Export cmake config and support find_packages(opentelemetry-cpp CONFIG)
633635
# Write config file for find_packages(opentelemetry-cpp CONFIG)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Enable building external components through otel-cpp build
5+
# The config options are
6+
# - OPENTELEMETRY_EXTERNAL_COMPONENT_PATH - Setting local path of the external
7+
# component as env variable
8+
# - OPENTELEMETRY_EXTERNAL_COMPONENT_URL Setting github-repo of external component
9+
# as env variable
10+
11+
12+
# Add custom vendor component from local path, or GitHub repo
13+
if(DEFINED $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_PATH})
14+
# Add custom component path to build tree and consolidate binary artifacts in
15+
# current project binary output directory.
16+
add_subdirectory($ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_PATH}
17+
${PROJECT_BINARY_DIR}/external)
18+
elseif(DEFINED $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_URL})
19+
# This option requires CMake 3.11+: add standard remote repo to build tree.
20+
include(FetchContent)
21+
FetchContent_Declare(
22+
external
23+
GIT_REPOSITORY $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_URL}
24+
GIT_TAG "main")
25+
FetchContent_GetProperties(external)
26+
if(NOT external_POPULATED)
27+
FetchContent_Populate(external)
28+
add_subdirectory(${external_SOURCE_DIR})
29+
endif()
30+
endif()

0 commit comments

Comments
 (0)