Skip to content

Commit cc4372d

Browse files
committed
set gRPC_PROTOBUF_PACKAGE_TYPE=CONFIG when installing and building grpc to ensure grpc finds protobuf with the CONFIG mode and the libprotobuf TYPE property is set
1 parent 19936ab commit cc4372d

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ if(WITH_OTLP_GRPC
359359
endif()
360360

361361
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/protobuf.cmake")
362+
362363
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/opentelemetry-proto.cmake")
363364
endif()
364365

@@ -584,10 +585,13 @@ if(opentelemetry-proto_VERSION)
584585
)
585586
endif()
586587
if(Protobuf_VERSION)
587-
message(STATUS "Protobuf: ${Protobuf_VERSION} (${Protobuf_PROVIDER})")
588+
message(
589+
STATUS
590+
"Protobuf: ${Protobuf_VERSION} (${Protobuf_PROVIDER} - ${protobuf_lib_type})"
591+
)
588592
endif()
589593
if(gRPC_VERSION)
590-
message(STATUS "gRPC: ${gRPC_VERSION} (${gRPC_PROVIDER})")
594+
message(STATUS "gRPC: ${gRPC_VERSION} (${gRPC_PROVIDER} - ${grpc_lib_type})")
591595
endif()
592596
if(CURL_VERSION)
593597
message(STATUS "CURL: ${CURL_VERSION} (${CURL_PROVIDER})")

cmake/grpc.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if(NOT gRPC_FOUND)
4141
set(gRPC_RE2_PROVIDER "module" CACHE STRING "" FORCE)
4242
set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)
4343
set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "" FORCE)
44+
set(gRPC_PROTOBUF_PACKAGE_TYPE "CONFIG" CACHE STRING "" FORCE)
4445
set(gRPC_ABSL_PROVIDER "module" CACHE STRING "" FORCE)
4546
set(gRPC_CARES_PROVIDER "module" CACHE STRING "" FORCE)
4647

@@ -56,14 +57,15 @@ if(NOT gRPC_FOUND)
5657
CXX_CLANG_TIDY "")
5758
endif()
5859
endforeach()
59-
endif()
6060

61-
if(TARGET grpc++ AND NOT TARGET gRPC::grpc++)
62-
add_library(gRPC::grpc++ ALIAS grpc++)
63-
endif()
61+
if(TARGET grpc++ AND NOT TARGET gRPC::grpc++)
62+
add_library(gRPC::grpc++ ALIAS grpc++)
63+
endif()
64+
65+
if(TARGET grpc_cpp_plugin AND NOT TARGET gRPC::grpc_cpp_plugin)
66+
add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin)
67+
endif()
6468

65-
if(TARGET grpc_cpp_plugin AND NOT TARGET gRPC::grpc_cpp_plugin)
66-
add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin)
6769
endif()
6870

6971
if(NOT TARGET gRPC::grpc++)

cmake/protobuf.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ else()
4949

5050
# Set the Protobuf_VERSION variable from the git tag.
5151
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" Protobuf_VERSION "${protobuf_GIT_TAG}")
52-
endif()
53-
endif()
5452

55-
if(TARGET libprotobuf)
56-
set_target_properties(libprotobuf PROPERTIES POSITION_INDEPENDENT_CODE ON CXX_CLANG_TIDY "" CXX_INCLUDE_WHAT_YOU_USE "")
53+
if(TARGET libprotobuf)
54+
set_target_properties(libprotobuf PROPERTIES POSITION_INDEPENDENT_CODE ON CXX_CLANG_TIDY "" CXX_INCLUDE_WHAT_YOU_USE "")
55+
endif()
56+
57+
endif()
5758
endif()
5859

5960
if(NOT TARGET protobuf::libprotobuf)

install/cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ if(grpc IN_LIST _THIRDPARTY_PACKAGE_LIST)
232232
"-DRE2_BUILD_TESTING=OFF"
233233
"-DgRPC_ZLIB_PROVIDER=package"
234234
"-DgRPC_PROTOBUF_PROVIDER=package"
235+
"-DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG"
235236
"-DgRPC_ABSL_PROVIDER=package")
236237

237238
add_dependencies(grpc-build zlib-install abseil-install protobuf-install)

0 commit comments

Comments
 (0)