mirror of https://github.com/qt/qtgrpc.git
Check required dependencies for gRPC before adding WrapgRPC library
Check required dependencies for gRPC, which are linked as INTERFACE_LINK_LIBRARIES which results in error when trying to use gRPC library. Fixes: QTBUG-109372 Pick-to: 6.5 Change-Id: Ib1adb7f9aff3041c50fabaa47bf269081342a639 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
b5662a170f
commit
cb1bf672a1
|
|
@ -17,11 +17,13 @@ if(TARGET Threads::Threads)
|
||||||
qt_internal_disable_find_package_global_promotion(Threads::Threads)
|
qt_internal_disable_find_package_global_promotion(Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save ${CMAKE_FIND_PACKAGE_PREFER_CONFIG})
|
if(NOT TARGET gRPC::grpc++)
|
||||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
|
set(__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save ${CMAKE_FIND_PACKAGE_PREFER_CONFIG})
|
||||||
find_package(gRPC ${__WrapgRPC_find_package_args})
|
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
|
||||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save})
|
find_package(gRPC ${__WrapgRPC_find_package_args})
|
||||||
unset(__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save)
|
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save})
|
||||||
|
unset(__WrapgRPC_CMAKE_FIND_PACKAGE_PREFER_CONFIG_save)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(TARGET gRPC::grpc_cpp_plugin)
|
if(TARGET gRPC::grpc_cpp_plugin)
|
||||||
qt_internal_disable_find_package_global_promotion(gRPC::grpc_cpp_plugin)
|
qt_internal_disable_find_package_global_promotion(gRPC::grpc_cpp_plugin)
|
||||||
|
|
@ -58,20 +60,38 @@ function(WrapgRPC_ensure_grpc_lib libname)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
if(NOT TARGET gRPC::grpc OR NOT TARGET gRPC::grpc++)
|
if(NOT TARGET gRPC::grpc++)
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
if(PkgConfig_FOUND)
|
if(PkgConfig_FOUND)
|
||||||
WrapgRPC_ensure_grpc_lib(grpc)
|
|
||||||
WrapgRPC_ensure_grpc_lib(grpc++)
|
WrapgRPC_ensure_grpc_lib(grpc++)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
unset(WrapgRPC_ensure_grpc_lib)
|
unset(WrapgRPC_ensure_grpc_lib)
|
||||||
|
|
||||||
if(TARGET gRPC::grpc
|
if(TARGET gRPC::grpc++ AND TARGET gRPC::grpc)
|
||||||
AND TARGET gRPC::grpc++)
|
## Check all required target dependencies for gRPC
|
||||||
|
## the gRPCConfig.cmake assumes that they are available in the system
|
||||||
|
## and links them as INTERFACE_LINK_LIBRARIES,
|
||||||
|
## which can result in error:
|
||||||
|
## The link interface of target "gRPC::grpc" contains: <missing library>
|
||||||
|
set(__all_dependencies_found TRUE)
|
||||||
|
get_target_property(__all_dependencies_required gRPC::grpc INTERFACE_LINK_LIBRARIES)
|
||||||
|
foreach(__grpc_dep ${__all_dependencies_required})
|
||||||
|
if(NOT ${__grpc_dep} MATCHES ".*::.*")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
if(NOT TARGET ${__grpc_dep})
|
||||||
|
message(WARNING "gRPC was found, but the ${__grpc_dep} dependency is missing.")
|
||||||
|
set(__all_dependencies_found FALSE)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(NOT __all_dependencies_found)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(WrapgRPC::WrapLibgRPC INTERFACE IMPORTED)
|
add_library(WrapgRPC::WrapLibgRPC INTERFACE IMPORTED)
|
||||||
target_link_libraries(WrapgRPC::WrapLibgRPC INTERFACE gRPC::grpc gRPC::grpc++)
|
target_link_libraries(WrapgRPC::WrapLibgRPC INTERFACE gRPC::grpc++)
|
||||||
get_target_property(Grpc_INCLUDE_PATH gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(Grpc_INCLUDE_PATH gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
set_property(GLOBAL PROPERTY WrapgRPC_INCLUDE_PATH "${Grpc_INCLUDE_PATH}")
|
set_property(GLOBAL PROPERTY WrapgRPC_INCLUDE_PATH "${Grpc_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Copyright (C) 2022 The Qt Company Ltd.
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
if(NOT TARGET testserver)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
qt6_add_protobuf(tst_grpc_client_qtgrpc_gen
|
qt6_add_protobuf(tst_grpc_client_qtgrpc_gen
|
||||||
OUTPUT_DIRECTORY
|
OUTPUT_DIRECTORY
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated"
|
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
# Copyright (C) 2022 The Qt Company Ltd.
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
find_package(WrapgRPCPlugin REQUIRED)
|
find_package(WrapgRPCPlugin)
|
||||||
find_package(WrapProtobuf REQUIRED)
|
find_package(WrapProtobuf)
|
||||||
find_package(WrapgRPC REQUIRED)
|
find_package(WrapgRPC)
|
||||||
|
|
||||||
|
if(NOT WrapgRPCPlugin_Found OR NOT WrapProtobuf_Found OR NOT WrapgRPC_Found)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(proto_files "${CMAKE_CURRENT_LIST_DIR}/../proto/testservice.proto")
|
set(proto_files "${CMAKE_CURRENT_LIST_DIR}/../proto/testservice.proto")
|
||||||
set(out_dir ${CMAKE_CURRENT_BINARY_DIR})
|
set(out_dir ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Copyright (C) 2022 The Qt Company Ltd.
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
if(NOT TARGET securetestserver)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
qt6_add_protobuf(tst_grpc_ssl_client_qtgrpc_gen
|
qt6_add_protobuf(tst_grpc_ssl_client_qtgrpc_gen
|
||||||
OUTPUT_DIRECTORY
|
OUTPUT_DIRECTORY
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated"
|
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue