forked from jaegertracing/jaeger-client-cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support building with local dependencies (no Hunter)
Add support for finding jaeger-cpp's dependencies via the normal local CMake package discovery mechanism of Find modules. Improves jaegertracing#38 Offline builds This introduces support for building with cmake -DHUNTER_ENABLED=0 Limitations: - Requires a locally installed Thrift 0.9.2 or 0.9.3 EXACTLY, not newer or older. These versions are not widely packaged so a local install is necessary. (jaegertracing#45) - Requires nlohmann json 2.1.0 or newer, which is not widely packaged in Linux distros. Install a local copy. (jaegertracing#47) Signed-off-by: Craig Ringer <[email protected]>
- Loading branch information
Showing
7 changed files
with
158 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Find jsoncpp | ||
# | ||
# Find the nlohmann json header | ||
# | ||
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH | ||
# | ||
# This module defines | ||
# | ||
# nlohmann_json_INCLUDE_DIR, where to find header, etc. | ||
# | ||
# nlohmann_json_FOUND, If false, do not try to use jsoncpp. | ||
# | ||
# nlohmann_json_LIBRARIES, empty since no linkage is required, this | ||
# is a header-only library. | ||
# | ||
# nlohmann_json_INCLUDE_NAME, the actual header name. You only have | ||
# to use this if you want to support 2.0.x which installs | ||
# a top-level json.hpp instead of nlohmann/json.hpp | ||
# | ||
|
||
# only look in default directories | ||
set(nlohmann_json_INCLUDE_NAME "nlohmann/json.hpp") | ||
find_path( | ||
nlohmann_json_INCLUDE_DIR | ||
NAMES "${nlohmann_json_INCLUDE_NAME}" | ||
DOC "nlohmann json include dir" | ||
) | ||
|
||
if (NOT nlohmann_json_INCLUDE_DIR) | ||
set(nlohmann_json_INCLUDE_NAME "json.hpp") | ||
find_path( | ||
nlohmann_json_INCLUDE_DIR | ||
NAMES "${nlohmann_json_INCLUDE_NAME}" | ||
) | ||
endif() | ||
|
||
set(nlohmann_json_INCLUDE_NAME ${nlohmann_json_INCLUDE_NAME} CACHE STRING "nlohmann header file name") | ||
|
||
set(nlohmann_json_LIBRARIES NOTFOUND CACHE STRING "no library is required by nlohmann_json") | ||
|
||
# Version detection. Unfortunately the header doesn't expose a proper version | ||
# define. | ||
if (nlohmann_json_INCLUDE_DIR AND nlohmann_json_INCLUDE_NAME) | ||
file(READ "${nlohmann_json_INCLUDE_DIR}/${nlohmann_json_INCLUDE_NAME}" NL_HDR_TXT LIMIT 1000) | ||
if (NL_HDR_TXT MATCHES "version ([0-9]+\.[0-9]+\.[0-9]+)") | ||
set(nlohmann_json_VERSION "${CMAKE_MATCH_1}") | ||
endif() | ||
endif() | ||
|
||
set(nlohmann_json_VERSION "${nlohmann_json_VERSION}" CACHE STRING "nlohmann header version") | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set nlohmann_json_FOUND to TRUE | ||
# if all listed variables are TRUE, hide their existence from configuration view | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args( | ||
nlohmann_json | ||
REQUIRED_VARS nlohmann_json_INCLUDE_DIR nlohmann_json_INCLUDE_NAME | ||
VERSION_VAR nlohmann_json_VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,38 @@ | ||
# 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>) | ||
# Find Thrift library and headers | ||
# | ||
# Sets: | ||
# | ||
# thrift_FOUND | ||
# thrift_INCLUDE_DIR | ||
# thrift_LIBRARIES | ||
# thrift_VERSION | ||
# | ||
# Component libraries not currently detected separately. | ||
# | ||
# Initial work was done by Cloudera https://github.com/cloudera/Impala | ||
# 2014 - modified by snikulov | ||
# Cut down from https://github.com/facebookarchive/fblualib | ||
|
||
# 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 | ||
) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR) | ||
|
||
# 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_LIBRARY(thrift_LIBRARY thrift) | ||
FIND_LIBRARY(thrift_LIBRARY_Z thriftz) | ||
FIND_LIBRARY(thrift_LIBRARY_NB thriftnb) | ||
FIND_LIBRARY(thrift_LIBRARY_C_GLIB thrift_c_glib) | ||
|
||
find_program(THRIFT_COMPILER | ||
NAMES | ||
thrift | ||
HINTS | ||
${THRIFT_HOME} | ||
ENV THRIFT_HOME | ||
/usr/local | ||
/opt/local | ||
PATH_SUFFIXES | ||
bin bin64 | ||
) | ||
SET(thrift_LIBRARIES ${thrift_LIBRARY} CACHE STRING "main thrift library") | ||
|
||
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}) | ||
MARK_AS_ADVANCED(thrift_LIBRARY thrift_LIBRARY_Z thrift_LIBRARY_NB thrift_LIBRARY_C_GLIB) | ||
|
||
# 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}") | ||
FIND_PATH(thrift_INCLUDE_DIR "thrift/Thrift.h") | ||
|
||
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 () | ||
FILE(READ "${thrift_INCLUDE_DIR}/thrift/config.h" thrift_CONFIG_H) | ||
IF (thrift_CONFIG_H MATCHES "#define VERSION \"([0-9]+\\.[0-9]+\\.[0-9]+)\"") | ||
SET(thrift_VERSION "${CMAKE_MATCH_1}") | ||
ENDIF() | ||
|
||
SET(thrift_VERSION "${thrift_VERSION}" CACHE STRING "thrift library version") | ||
|
||
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) | ||
find_package_handle_standard_args( | ||
thrift | ||
REQUIRED_VARS thrift_INCLUDE_DIR thrift_LIBRARIES | ||
VERSION_VAR thrift_VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Find the yaml-cpp header and libraries | ||
# | ||
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH | ||
# | ||
# This module defines | ||
# yaml-cpp_INCLUDE_DIR, where to find header, etc. | ||
# yaml-cpp_LIBRARIES, libraries to link to use yaml-cpp | ||
# yaml-cpp_FOUND, If false, do not try to use yaml-cpp. | ||
# | ||
|
||
# only look in default directories | ||
find_path( | ||
yaml-cpp_INCLUDE_DIR | ||
NAMES yaml-cpp/yaml.h | ||
DOC "yaml-cpp include dir" | ||
) | ||
|
||
find_library(yaml-cpp_LIBRARIES | ||
NAMES yaml-cpp | ||
PATH_SUFFIXES lib lib64) | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set yaml-cpp_FOUND to TRUE | ||
# if all listed variables are TRUE, hide their existence from configuration view | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(yaml-cpp DEFAULT_MSG yaml-cpp_LIBRARIES yaml-cpp_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters