From 607858db5109d025afbb985d2b8f1a0722f34793 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 25 Feb 2023 10:27:12 +0800 Subject: [PATCH] build: cmake: find Thrift before using it we should find Thrift library before using it. in this change, FindThrift.cmake is added to find Thrift library. Signed-off-by: Kefu Chai --- CMakeLists.txt | 3 ++- cmake/FindThrift.cmake | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 cmake/FindThrift.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fe9be83884..04eef75140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ find_package(ZLIB REQUIRED) find_package(ICU COMPONENTS uc i18n REQUIRED) find_package(absl REQUIRED) find_package(libdeflate REQUIRED) +find_package(Thrift REQUIRED) find_package(xxHash REQUIRED) set(scylla_gen_build_dir "${CMAKE_BINARY_DIR}/gen") @@ -326,10 +327,10 @@ target_link_libraries(scylla PRIVATE ZLIB::ZLIB ICU::uc systemd + Thrift::thrift zstd snappy ${LUA_LIBRARIES} - thrift crypt xxHash::xxhash) diff --git a/cmake/FindThrift.cmake b/cmake/FindThrift.cmake new file mode 100644 index 0000000000..e3bda48b4c --- /dev/null +++ b/cmake/FindThrift.cmake @@ -0,0 +1,47 @@ +# +# Copyright 2023-present ScyllaDB +# + +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +find_package(PkgConfig REQUIRED) + +pkg_check_modules(PC_thrift QUIET thrift) + +find_library(thrift_LIBRARY + NAMES thrift + HINTS + ${PC_thrift_LIBDIR} + ${PC_thrift_LIBRARY_DIRS}) + +find_path(thrift_INCLUDE_DIR + NAMES thrift/Thrift.h + HINTS + ${PC_thrift_INCLUDEDIR} + ${PC_thrift_INCLUDE_DIRS}) + +mark_as_advanced( + thrift_LIBRARY + thrift_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Thrift + REQUIRED_VARS + thrift_LIBRARY + thrift_INCLUDE_DIR + VERSION_VAR PC_thrift_VERSION) + +if(Thrift_FOUND) + set(thrift_LIBRARIES ${thrift_LIBRARY}) + set(thrift_INCLUDE_DIRS ${thrift_INCLUDE_DIR}) + if(NOT(TARGET Thrift::thrift)) + add_library(Thrift::thrift UNKNOWN IMPORTED) + + set_target_properties(Thrift::thrift + PROPERTIES + IMPORTED_LOCATION ${thrift_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${thrift_INCLUDE_DIRS}) + endif() +endif()