ceph/cmake/modules/BuildJaeger.cmake
Deepika Upadhyay 4b69d3a184 jaeger, build/op: add jaeger and it's dependencies as submodules
* This commit introduces Jaegertracing library as package libjaeger,
  pickwhich would be consumed by other ceph pacakges such as ceph-common0

* adds the following dependencies, which would be build from source
  using ExternalProjectHelper.cmake +IncludeJaeger.cmake +
  Build<package>.cmake scripts:

  jaegertracing: v0.6.0 [added as a submodule]
  opentracing: v1.6.0 [added as a submodule]
  thrift: 0.13.0 [added as a submodule]
  yaml-cpp: 0.6.0
  json(optional)

* updates Boost to be installed instead of being build only, because
  jaegertracing them during their build process.

* ceph.spec.in: introduces a default enabled jaeger packaging option,
  which could be disabled using --without-jaeger flag during rpmbuild

* note: libjaeger package if enabled will be a dependency on ceph-common, ceph-mon, rgw_common and transitively will be a dependency for modules that have them as  a dependency.

Signed-off-by: Deepika Upadhyay <dupadhya@redhat.com>
2020-12-11 07:55:46 +00:00

66 lines
2.6 KiB
CMake

# This module builds Jaeger after it's dependencies are installed and discovered
# opentracing: is built using cmake/modules/Buildopentracing.cmake
# Thrift: build using cmake/modules/Buildthrift.cmake
# yaml-cpp, nlhomann-json: are installed locally and then discovered using
# Find<package>.cmake
# Boost Libraries used for building thrift are build and provided by
# cmake/modules/BuildBoost.cmake
function(build_jaeger)
set(Jaeger_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/jaegertracing/jaeger-client-cpp")
set(Jaeger_INSTALL_DIR "${CMAKE_BINARY_DIR}/external")
set(Jaeger_BINARY_DIR "${Jaeger_INSTALL_DIR}/Jaeger")
file(MAKE_DIRECTORY "${Jaeger_INSTALL_DIR}")
set(Jaeger_CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DBUILD_SHARED_LIBS=ON
-DHUNTER_ENABLED=OFF
-DBUILD_TESTING=OFF
-DJAEGERTRACING_BUILD_EXAMPLES=OFF
-DCMAKE_PREFIX_PATH="${CMAKE_BINARY_DIR}/external;${CMAKE_BINARY_DIR}/boost"
-DCMAKE_INSTALL_RPATH=${CMAKE_BINARY_DIR}/external
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
-DOpenTracing_DIR=${CMAKE_SOURCE_DIR}/src/jaegertracing/opentracing-cpp
-Dnlohmann_json_DIR=/usr/lib
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/boost\;${CMAKE_BINARY_DIR}/boost/include\;${CMAKE_BINARY_DIR}/external
-DCMAKE_FIND_ROOT_PATH=${CMAKE_BINARY_DIR}/boost\;${CMAKE_BINARY_DIR}/boost/include\;${CMAKE_BINARY_DIR}/external
-DCMAKE_INSTALL_LIBDIR=${CMAKE_BINARY_DIR}/external/lib
-Dthrift_HOME=${CMAKE_BINARY_DIR}/external
-DOpenTracing_HOME=${CMAKE_BINARY_DIR}/external)
set(dependencies opentracing thrift)
include(BuildOpenTracing)
build_opentracing()
include(Buildthrift)
build_thrift()
if(NOT yaml-cpp_FOUND)
include(Buildyaml-cpp)
build_yamlcpp()
add_library(yaml-cpp::yaml-cpp SHARED IMPORTED)
add_dependencies(yaml-cpp::yaml-cpp yaml-cpp)
set_library_properties_for_external_project(yaml-cpp::yaml-cpp yaml-cpp)
list(APPEND dependencies "yaml-cpp")
endif()
if(CMAKE_MAKE_PROGRAM MATCHES "make")
# try to inherit command line arguments passed by parent "make" job
set(make_cmd $(MAKE))
else()
set(make_cmd ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> --target Jaeger)
endif()
set(install_cmd $(MAKE) install DESTDIR=)
include(ExternalProject)
ExternalProject_Add(Jaeger
SOURCE_DIR ${Jaeger_SOURCE_DIR}
UPDATE_COMMAND ""
INSTALL_DIR "external"
PREFIX ${Jaeger_INSTALL_DIR}
CMAKE_ARGS ${Jaeger_CMAKE_ARGS}
BINARY_DIR ${Jaeger_BINARY_DIR}
BUILD_COMMAND ${make_cmd}
INSTALL_COMMAND ${install_cmd}
DEPENDS "${dependencies}"
)
endfunction()