1# Copyright 2024 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15if(TARGET opentelemetry-cpp::api) 16 # If opentelemetry is included already, skip including it. 17# OpenTelemetry does not work with "module" mode at present. 18# elseif(gRPC_OPENTELEMETRY_PROVIDER STREQUAL "module") 19# if(NOT OPENTELEMETRY_ROOT_DIR) 20# set(OPENTELEMETRY_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-cpp) 21# endif() 22# set(BUILD_TESTING OFF) 23# if(NOT gRPC_BUILD_TESTS) 24# set(WITH_API_ONLY ON) 25# endif() 26# set(WITH_ABSEIL ON) 27# include_directories(${OPENTELEMETRY_ROOT_DIR} "${OPENTELEMETRY_ROOT_DIR}/api/include") 28# add_subdirectory(${OPENTELEMETRY_ROOT_DIR} third_party/opentelemetry-cpp) 29# if(EXISTS "${OPENTELEMETRY_ROOT_DIR}/CMakeLists.txt") 30 # Unclear whether we should install OpenTelemetry along with gRPC 31 # if(gRPC_INSTALL AND _gRPC_INSTALL_SUPPORTED_FROM_MODULE) 32 # set(OPENTELEMETRY_INSTALL ON) 33 # endif() 34# else() 35# message(WARNING "gRPC_OPENTELEMETRY_PROVIDER is \"module\" but OPENTELEMETRY_ROOT_DIR is wrong") 36# endif() 37# if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE) 38# message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_OPENTELEMETRY_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.") 39# set(gRPC_INSTALL FALSE) 40# endif() 41elseif(gRPC_OPENTELEMETRY_PROVIDER STREQUAL "package") 42 find_package(opentelemetry-cpp CONFIG REQUIRED) 43endif() 44set(_gRPC_FIND_OPENTELEMETRY "if(NOT TARGET opentelemetry-cpp::opentelemetry_api)\n find_package(opentelemetry-cpp)\nendif()") 45