From de7e894ae2d738e084323f406b0ae553b4a4651b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Mon, 10 May 2021 10:20:40 +0800 Subject: [PATCH] build: prefer use cmake version of gRPC --- source/CMakeLists.txt | 8 +++++++- source/intercept/proto/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c6a8d9f4a..04014647e 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -27,7 +27,13 @@ find_package(nlohmann_json REQUIRED) find_package(fmt REQUIRED) find_package(spdlog REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(gRPC REQUIRED IMPORTED_TARGET protobuf grpc++) +find_package(gRPC) +if (gRPC_FOUND) + set(GRPC_TARGET gRPC::grpc++) +else () + pkg_check_modules(gRPC REQUIRED IMPORTED_TARGET protobuf grpc++) + set(GRPC_TARGET PkgConfig::gRPC) +endif() if (UNIX AND NOT APPLE) set(SUPPORT_PRELOAD 1) diff --git a/source/intercept/proto/CMakeLists.txt b/source/intercept/proto/CMakeLists.txt index e4fb8c157..86a209a57 100644 --- a/source/intercept/proto/CMakeLists.txt +++ b/source/intercept/proto/CMakeLists.txt @@ -62,4 +62,4 @@ target_sources(rpc_a INTERFACE $ ) -target_link_libraries(rpc_a PUBLIC PkgConfig::gRPC) +target_link_libraries(rpc_a PUBLIC ${GRPC_TARGET})