diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake')
-rw-r--r-- | src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake b/src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake new file mode 100644 index 000000000..77c36ed97 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/cmake/Findthrift.cmake @@ -0,0 +1,93 @@ +# https://github.com/snikulov/cmake-modules/blob/master/FindThrift.cmake + +# - Find Thrift (a cross platform RPC lib/tool) +# This module defines +# thrift_VERSION_STRING, version string of ant if found +# thrift_LIBRARIES, libraries to link +# thrift_INCLUDE_DIR, where to find thrift headers +# thrift_COMPILER, thrift compiler executable +# thrift_FOUND, If false, do not try to use ant +# Function +# thrift_gen_cpp(<path to thrift file> <output variable with file list>) +# +# Initial work was done by Cloudera https://github.com/cloudera/Impala +# 2014 - modified by snikulov + +# prefer the thrift version supplied in thrift_HOME (cmake -Dthrift_HOME then environment) +find_path(thrift_INCLUDE_DIR + NAMES + thrift/Thrift.h + HINTS + ${thrift_HOME} + ENV thrift_HOME + /usr/local + /opt/local + PATH_SUFFIXES + include +) + +# prefer the thrift version supplied in thrift_HOME +find_library(thrift_LIBRARIES + NAMES + thrift libthrift + HINTS + ${thrift_HOME} + ENV thrift_HOME + /usr/local + /opt/local + PATH_SUFFIXES + lib lib64 +) + +find_program(thrift_COMPILER + NAMES + thrift + HINTS + ${thrift_HOME} + ENV thrift_HOME + /usr/local + /opt/local + PATH_SUFFIXES + bin bin64 +) + +if (thrift_COMPILER) + exec_program(${thrift_COMPILER} + ARGS -version OUTPUT_VARIABLE __thrift_OUT RETURN_VALUE thrift_RETURN) + string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+-[a-z]+$" thrift_VERSION_STRING ${__thrift_OUT}) + + # define utility function to generate cpp files + function(thrift_gen_cpp thrift_file thrift_CPP_FILES_LIST thrift_GEN_INCLUDE_DIR) + set(_res) + set(_res_inc_path) + if(EXISTS ${thrift_file}) + get_filename_component(_target_dir ${thrift_file} NAME_WE) + message("thrif_gen_cpp: ${thrift_file}") + + if(NOT EXISTS ${CMAKE_BINARY_DIR}/${_target_dir}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${_target_dir}) + endif() + exec_program(${thrift_COMPILER} + ARGS -o "${CMAKE_BINARY_DIR}/${_target_dir}" --gen cpp ${thrift_file} + OUTPUT_VARIABLE __thrift_OUT + RETURN_VALUE thrift_RETURN) + file(GLOB_RECURSE __result_src "${CMAKE_BINARY_DIR}/${_target_dir}/*.cpp") + file(GLOB_RECURSE __result_hdr "${CMAKE_BINARY_DIR}/${_target_dir}/*.h") + list(APPEND _res ${__result_src}) + list(APPEND _res ${__result_hdr}) + if(__result_hdr) + list(GET __result_hdr 0 _res_inc_path) + get_filename_component(_res_inc_path ${_res_inc_path} DIRECTORY) + endif() + else() + message("thrift_gen_cpp: file ${thrift_file} does not exists") + endif() + set(${thrift_CPP_FILES_LIST} "${_res}" PARENT_SCOPE) + set(${thrift_GEN_INCLUDE_DIR} "${_res_inc_path}" PARENT_SCOPE) + endfunction() +endif () + + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(thrift DEFAULT_MSG thrift_LIBRARIES thrift_INCLUDE_DIR thrift_COMPILER) +mark_as_advanced(thrift_LIBRARIES thrift_INCLUDE_DIR thrift_COMPILER thrift_VERSION_STRING) |