Skip to content

Commit

Permalink
[BUILD] Enable building otel-cpp extensions from main repo (#1937)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Jun 28, 2023
1 parent d0452f8 commit efde010
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ if(NOT WITH_API_ONLY)
endif()
endif()

include(cmake/opentelemetry-build-external-component.cmake)

if(OPENTELEMETRY_INSTALL)
# Export cmake config and support find_packages(opentelemetry-cpp CONFIG)
# Write config file for find_packages(opentelemetry-cpp CONFIG)
Expand Down
30 changes: 30 additions & 0 deletions cmake/opentelemetry-build-external-component.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Enable building external components through otel-cpp build
# The config options are
# - OPENTELEMETRY_EXTERNAL_COMPONENT_PATH - Setting local path of the external
# component as env variable
# - OPENTELEMETRY_EXTERNAL_COMPONENT_URL Setting github-repo of external component
# as env variable


# Add custom vendor component from local path, or GitHub repo
if(DEFINED $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_PATH})
# Add custom component path to build tree and consolidate binary artifacts in
# current project binary output directory.
add_subdirectory($ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_PATH}
${PROJECT_BINARY_DIR}/external)
elseif(DEFINED $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_URL})
# This option requires CMake 3.11+: add standard remote repo to build tree.
include(FetchContent)
FetchContent_Declare(
external
GIT_REPOSITORY $ENV{OPENTELEMETRY_EXTERNAL_COMPONENT_URL}
GIT_TAG "main")
FetchContent_GetProperties(external)
if(NOT external_POPULATED)
FetchContent_Populate(external)
add_subdirectory(${external_SOURCE_DIR})
endif()
endif()

0 comments on commit efde010

Please sign in to comment.