diff --git a/CMakeLists.txt b/CMakeLists.txt index d6c99c99..37cccb68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,12 +59,12 @@ list(APPEND package_deps thrift) hunter_add_package(opentracing-cpp) # Not `${hunter_config}` because OpenTracing provides its own # OpenTracingConfig.cmake file -find_package(OpenTracing CONFIG REQUIRED) -list(APPEND LIBS OpenTracing::opentracing-static) +find_package(OpenTracing ${hunter_config} REQUIRED) +list(APPEND LIBS OpenTracing::opentracing) list(APPEND package_deps opentracing-cpp) hunter_add_package(nlohmann_json) -find_package(nlohmann_json CONFIG REQUIRED) +find_package(nlohmann_json ${hunter_config} REQUIRED) list(APPEND LIBS nlohmann_json) list(APPEND package_deps nlohmann_json) @@ -78,7 +78,7 @@ if(JAEGERTRACING_WITH_YAML_CPP) hunter_add_package(yaml-cpp) # Not `${hunter_config}` because yaml-cpp provides its own # yaml-cpp-config.cmake file - find_package(yaml-cpp CONFIG REQUIRED) + find_package(yaml-cpp ${hunter_config} REQUIRED) if(HUNTER_ENABLED) list(APPEND LIBS yaml-cpp::yaml-cpp) else() @@ -243,6 +243,10 @@ target_link_libraries(jaegertracing-static ${LIBS}) set_target_properties(jaegertracing-static PROPERTIES OUTPUT_NAME jaegertracing) +if (nlohmann_json_INCLUDE_NAME EQUAL "hson.hpp") + set(JAEGERTRACING_NLOHMANN_UNQUALIFIED_PATH 1) +endif() + configure_file( src/jaegertracing/Constants.h.in src/jaegertracing/Constants.h @@ -283,7 +287,7 @@ if(BUILD_TESTING) GTEST_HAS_TR1_TUPLE=0 GTEST_USE_OWN_TR1_TUPLE=0) target_link_libraries( - UnitTest testutils GTest::main jaegertracing-static ${LIBS}) + UnitTest testutils ${GTEST_MAIN_LIBRARY} jaegertracing-static ${LIBS}) add_test(NAME UnitTest COMMAND UnitTest) if(JAEGERTRACING_COVERAGE) setup_target_for_coverage(NAME UnitTestCoverage diff --git a/cmake/FindThrift.cmake b/cmake/FindThrift.cmake new file mode 100644 index 00000000..3ea47297 --- /dev/null +++ b/cmake/FindThrift.cmake @@ -0,0 +1,21 @@ +# Find Thrift library and headers +# +# Sets: +# +# THRIFT_FOUND +# THRIFT_INCLUDE_DIR +# THRIFT_LIBRARIES +# +# Cut down from https://github.com/facebookarchive/fblualib + +CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR) + +FIND_LIBRARY(THRIFT_LIBRARIES thrift) +FIND_PATH(THRIFT_INCLUDE_DIR "thrift/Thrift.h") + +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + Thrift + REQUIRED_ARGS + THRIFT_INCLUDE_DIR + THRIFT_LIBRARY + THRIFT_CPP2_LIBRARY) diff --git a/cmake/Findnlohmann_json.cmake b/cmake/Findnlohmann_json.cmake new file mode 100644 index 00000000..e577b09a --- /dev/null +++ b/cmake/Findnlohmann_json.cmake @@ -0,0 +1,37 @@ +# 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_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() + +# 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 DEFAULT_MSG nlohmann_json_INCLUDE_DIR nlohmann_json_INCLUDE_NAME) diff --git a/cmake/Findyaml-cpp.cmake b/cmake/Findyaml-cpp.cmake new file mode 100644 index 00000000..75028614 --- /dev/null +++ b/cmake/Findyaml-cpp.cmake @@ -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) diff --git a/src/jaegertracing/Constants.h.in b/src/jaegertracing/Constants.h.in index c5b90f55..15afa4bd 100644 --- a/src/jaegertracing/Constants.h.in +++ b/src/jaegertracing/Constants.h.in @@ -18,6 +18,7 @@ #define JAEGERTRACING_CONSTANTS_H #cmakedefine JAEGERTRACING_WITH_YAML_CPP +#cmakedefine JAEGERTRACING_NLOHMANN_UNQUALIFIED_PATH namespace jaegertracing { diff --git a/src/jaegertracing/baggage/RemoteRestrictionJSON.h b/src/jaegertracing/baggage/RemoteRestrictionJSON.h index ea62f00b..7f3d1ff1 100644 --- a/src/jaegertracing/baggage/RemoteRestrictionJSON.h +++ b/src/jaegertracing/baggage/RemoteRestrictionJSON.h @@ -18,10 +18,17 @@ #define JAEGERTRACING_BAGGAGE_REMOTERESTRICTIONJSON_H #include -#include #include #include +#include "jaegertracing/Constants.h" +/* nlohmann json changed locations (in 2.1.0?) */ +#ifdef JAEGERTRACING_NLOHMANN_UNQUALIFIED_PATH + #include +#else + #include +#endif + #include "jaegertracing/thrift-gen/BaggageRestrictionManager.h" #include "jaegertracing/thrift-gen/baggage_types.h" diff --git a/src/jaegertracing/testutils/CMakeLists.txt b/src/jaegertracing/testutils/CMakeLists.txt index 215630f6..257bd9c4 100644 --- a/src/jaegertracing/testutils/CMakeLists.txt +++ b/src/jaegertracing/testutils/CMakeLists.txt @@ -6,4 +6,9 @@ TUDPTransport.cpp) add_library(testutils ${SRC}) target_include_directories(testutils PUBLIC $) -target_link_libraries(testutils thrift::thrift_static) +if(HUNTER_ENABLED) + target_link_libraries(testutils thrift::thrift_static) +else() + target_link_libraries(testutils ${THRIFT_LIBRARIES}) +endif() +list(APPEND package_deps thrift)