-
Notifications
You must be signed in to change notification settings - Fork 482
Support protobuf 3.22 or upper #2163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fbb68dd
5c013c0
7b5f955
f95fd57
f016a75
c94e488
0dc7575
8db4a61
0f0085a
1dcceaa
6fa4e95
93d347c
234ab40
8956193
5f3e6db
8a36378
2ecaf75
ace2e84
2e1af98
c562424
77f4ec1
1fa8631
d3db7c8
68aa11c
f63e145
0ba0fb2
f2e3009
53ef61b
85bea45
b903710
f783127
afed730
22e767c
ecdc611
43f5996
95fb02d
a947146
b24f299
052dfea
c73f9b8
7a2c75b
46caba6
5e08424
ef1f0be
bb90f44
edeed26
9bfce35
0d3b76f
67dc6ff
b8f2e5c
c996738
ec5f39e
fd9dc99
fdff03d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ project(opentelemetry-cpp) | |
# Mark variables as used so cmake doesn't complain about them | ||
mark_as_advanced(CMAKE_TOOLCHAIN_FILE) | ||
|
||
# Prefer cmake CONFIG to auto resolve dependencies. | ||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) | ||
ThomsonTan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Don't use customized cmake modules if vcpkg is used to resolve dependence. | ||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") | ||
|
@@ -125,6 +128,8 @@ endif() | |
option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets" | ||
${OPENTELEMETRY_INSTALL_default}) | ||
|
||
include("${PROJECT_SOURCE_DIR}/cmake/tools.cmake") | ||
|
||
if(NOT DEFINED CMAKE_CXX_STANDARD) | ||
if(WITH_STL) | ||
# Require at least C++17. C++20 is needed to avoid gsl::span | ||
|
@@ -340,9 +345,21 @@ if(WITH_PROMETHEUS) | |
endif() | ||
endif() | ||
|
||
if(WITH_ABSEIL) | ||
find_package(absl CONFIG REQUIRED) | ||
endif() | ||
|
||
if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP) | ||
set(protobuf_MODULE_COMPATIBLE ON) | ||
find_package(Protobuf) | ||
if(Protobuf_VERSION AND Protobuf_VERSION VERSION_GREATER_EQUAL "3.22.0") | ||
if(NOT WITH_ABSEIL) | ||
message( | ||
FATAL_ERROR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems with new protobuf, the main SDK will no longer buildable with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. protobuf has a internal reference to abseil and will use it when building without |
||
"Protobuf 3.22 or upper require abseil-cpp(Recommended version: 20230125 or upper)" | ||
) | ||
endif() | ||
endif() | ||
|
||
if(WITH_OTLP_GRPC) | ||
find_package(gRPC) | ||
endif() | ||
|
@@ -372,10 +389,14 @@ if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP) | |
) | ||
endif() | ||
endif() | ||
# Latest Protobuf uses mixed case instead of uppercase | ||
if(Protobuf_PROTOC_EXECUTABLE) | ||
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) | ||
endif() | ||
endif() | ||
# Latest Protobuf imported targets and without legacy module support | ||
if(TARGET protobuf::protoc) | ||
project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE | ||
protobuf::protoc) | ||
elseif(Protobuf_PROTOC_EXECUTABLE) | ||
# Some versions of FindProtobuf.cmake uses mixed case instead of uppercase | ||
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) | ||
endif() | ||
include(CMakeDependentOption) | ||
|
||
|
@@ -524,10 +545,14 @@ if(BUILD_TESTING) | |
set(GTEST_INCLUDE_DIRS | ||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include) | ||
set(GTEST_BOTH_LIBRARIES | ||
${CMAKE_BINARY_DIR}/lib/libgtest.a | ||
${CMAKE_BINARY_DIR}/lib/libgtest_main.a | ||
${CMAKE_BINARY_DIR}/lib/libgmock.a) | ||
if(TARGET gtest) | ||
set(GTEST_BOTH_LIBRARIES gtest gtest_main gmock) | ||
else() | ||
set(GTEST_BOTH_LIBRARIES | ||
${CMAKE_BINARY_DIR}/lib/libgtest.a | ||
${CMAKE_BINARY_DIR}/lib/libgtest_main.a | ||
${CMAKE_BINARY_DIR}/lib/libgmock.a) | ||
endif() | ||
elseif(WIN32) | ||
# Make sure we are always bootsrapped with vcpkg on Windows | ||
find_package(GTest) | ||
|
@@ -540,7 +565,17 @@ if(BUILD_TESTING) | |
# Prefer GTest installed by OS distro, brew or vcpkg package manager | ||
find_package(GTest REQUIRED) | ||
endif() | ||
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) | ||
if(NOT GTEST_BOTH_LIBRARIES) | ||
# New GTest package names | ||
if(TARGET GTest::gtest) | ||
set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main GTest::gmock) | ||
elseif(TARGET GTest::GTest) | ||
set(GTEST_BOTH_LIBRARIES GTest::GTest GTest::Main) | ||
endif() | ||
endif() | ||
if(GTEST_INCLUDE_DIRS) | ||
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) | ||
endif() | ||
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}") | ||
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}") | ||
enable_testing() | ||
|
Uh oh!
There was an error while loading. Please reload this page.