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 <kefu.chai@scylladb.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
47
cmake/FindThrift.cmake
Normal file
47
cmake/FindThrift.cmake
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user