11# Copyright The OpenTelemetry Authors
22# SPDX-License-Identifier: Apache-2.0
33
4- cmake_minimum_required (VERSION 3.10)
5-
6- # See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by
7- # certain version of zlib which CURL depends on.
8- if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12" )
9- cmake_policy (SET CMP0074 NEW)
10- endif ()
11-
12- # Allow to use normal variable for option()
13- if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13" )
14- cmake_policy (SET CMP0077 NEW)
15- endif ()
16-
17- # Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible
18- if (POLICY CMP0091)
19- cmake_policy (SET CMP0091 NEW)
20- endif ()
4+ cmake_minimum_required (VERSION 3.14)
215
226if (POLICY CMP0092)
237 # https://cmake.org/cmake/help/latest/policy/CMP0092.html#policy:CMP0092 Make
@@ -36,8 +20,10 @@ project(opentelemetry-cpp)
3620# Mark variables as used so cmake doesn't complain about them
3721mark_as_advanced (CMAKE_TOOLCHAIN_FILE)
3822
39- # Prefer cmake CONFIG to auto resolve dependencies. This is important to
40- # properly find protobuf versions 3.22.0 and above
23+ # Note: CMAKE_FIND_PACKAGE_PREFER_CONFIG requires cmake 3.15
24+ # Prefer cmake CONFIG to auto resolve dependencies.
25+ # This is important to properly find protobuf versions
26+ # 3.22.0 and above due to the abseil-cpp dependency.
4127set (CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE )
4228
4329# Don't use customized cmake modules if vcpkg is used to resolve dependence.
@@ -420,9 +406,18 @@ if(WITH_OTLP_GRPC
420406 OR WITH_OTLP_HTTP
421407 OR WITH_OTLP_FILE)
422408
423- find_package (Protobuf)
424- # Protobuf 3.22 or upper require abseil-cpp, we can find it in
425- # opentelemetry-cpp-config.cmake
409+ # Note: remove once cmake 3.14 is no longer supported
410+ # including the CMakeFindDependencyMacro is required with cmake 3.14
411+ # due to an issue with the gRPCConfig.cmake file.
412+ include (CMakeFindDependencyMacro)
413+
414+ # Protobuf 3.22 and up requires abseil-cpp. This is found using the
415+ # CONFIG search mode. In cmake 3.14 we must manually
416+ # try config mode first then fall back to MODULE mode
417+ find_package (Protobuf CONFIG)
418+ if (NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
419+ find_package (Protobuf MODULE)
420+ endif ()
426421
427422 if (WITH_OTLP_GRPC)
428423 find_package (gRPC CONFIG)
@@ -441,7 +436,7 @@ if(WITH_OTLP_GRPC
441436 endif ()
442437
443438 if (NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
444- find_package (Protobuf REQUIRED)
439+ find_package (Protobuf CONFIG REQUIRED)
445440 endif ()
446441 if (NOT gRPC_FOUND AND WITH_OTLP_GRPC)
447442 find_package (gRPC CONFIG)
@@ -800,10 +795,10 @@ if(gRPC_FOUND)
800795 message (STATUS "gRPC: ${gRPC_VERSION} " )
801796endif ()
802797if (CURL_FOUND)
803- message (STATUS "CURL: ${CURL_VERSION } " )
798+ message (STATUS "CURL: ${CURL_VERSION_STRING } " )
804799endif ()
805800if (ZLIB_FOUND)
806- message (STATUS "ZLIB: ${ZLIB_VERSION } " )
801+ message (STATUS "ZLIB: ${ZLIB_VERSION_STRING } " )
807802endif ()
808803if (USE_NLOHMANN_JSON)
809804 message (STATUS "nlohmann-json: ${nlohmann_json_VERSION} " )
0 commit comments