diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake')
-rw-r--r-- | src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake b/src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake new file mode 100644 index 000000000..18b23f322 --- /dev/null +++ b/src/arrow/cpp/cmake_modules/FindgRPCAlt.cmake @@ -0,0 +1,76 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(find_package_args) +if(gRPCAlt_FIND_VERSION) + list(APPEND find_package_args ${gRPCAlt_FIND_VERSION}) +endif() +if(gRPCAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(gRPC ${find_package_args}) +if(gRPC_FOUND) + set(gRPCAlt_FOUND TRUE) + return() +endif() + +find_package(PkgConfig QUIET) +pkg_check_modules(GRPCPP_PC grpc++) +if(GRPCPP_PC_FOUND) + set(gRPCAlt_VERSION "${GRPCPP_PC_VERSION}") + set(GRPCPP_INCLUDE_DIRECTORIES ${GRPCPP_PC_INCLUDEDIR}) + if(ARROW_GRPC_USE_SHARED) + set(GRPCPP_LINK_LIBRARIES ${GRPCPP_PC_LINK_LIBRARIES}) + set(GRPCPP_LINK_OPTIONS ${GRPCPP_PC_LDFLAGS_OTHER}) + set(GRPCPP_COMPILE_OPTIONS ${GRPCPP_PC_CFLAGS_OTHER}) + else() + set(GRPCPP_LINK_LIBRARIES) + foreach(GRPCPP_LIBRARY_NAME ${GRPCPP_PC_STATIC_LIBRARIES}) + find_library(GRPCPP_LIBRARY_${GRPCPP_LIBRARY_NAME} + NAMES "${CMAKE_STATIC_LIBRARY_PREFIX}${GRPCPP_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" + HINTS ${GRPCPP_PC_STATIC_LIBRARY_DIRS}) + list(APPEND GRPCPP_LINK_LIBRARIES "${GRPCPP_LIBRARY_${GRPCPP_LIBRARY_NAME}}") + endforeach() + set(GRPCPP_LINK_OPTIONS ${GRPCPP_PC_STATIC_LDFLAGS_OTHER}) + set(GRPCPP_COMPILE_OPTIONS ${GRPCPP_PC_STATIC_CFLAGS_OTHER}) + endif() + list(GET GRPCPP_LINK_LIBRARIES 0 GRPCPP_IMPORTED_LOCATION) + list(REMOVE_AT GRPCPP_LINK_LIBRARIES 0) + find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin + HINTS ${GRPCPP_PC_PREFIX} + NO_DEFAULT_PATH + PATH_SUFFIXES "bin") + set(gRPCAlt_FIND_PACKAGE_ARGS gRPCAlt REQUIRED_VARS GRPCPP_IMPORTED_LOCATION + GRPC_CPP_PLUGIN) + if(gRPCAlt_VERSION) + list(APPEND gRPCAlt_FIND_PACKAGE_ARGS VERSION_VAR gRPCAlt_VERSION) + endif() + find_package_handle_standard_args(${gRPCAlt_FIND_PACKAGE_ARGS}) +else() + set(gRPCAlt_FOUND FALSE) +endif() + +if(gRPCAlt_FOUND) + add_library(gRPC::grpc++ UNKNOWN IMPORTED) + set_target_properties(gRPC::grpc++ + PROPERTIES IMPORTED_LOCATION "${GRPCPP_IMPORTED_LOCATION}" + INTERFACE_COMPILE_OPTIONS "${GRPCPP_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES + "${GRPCPP_INCLUDE_DIRECTORIES}" + INTERFACE_LINK_LIBRARIES "${GRPCPP_LINK_LIBRARIES}" + INTERFACE_LINK_OPTIONS "${GRPCPP_LINK_OPTIONS}") + + add_executable(gRPC::grpc_cpp_plugin IMPORTED) + set_target_properties(gRPC::grpc_cpp_plugin PROPERTIES IMPORTED_LOCATION + ${GRPC_CPP_PLUGIN}) +endif() |