ceph/cmake/modules/BuildJaeger.cmake

89 lines
3.5 KiB
CMake
Raw Normal View History

# This module builds Jaeger after it's dependencies are installed and discovered
# opentracing: is built using cmake/modules/Buildopentracing.cmake
# Thrift: found using cmake/modules/Findthrift.cmake (not by default)
# yaml-cpp, nlhomann-json: are installed locally and then discovered using
# Find<package>.cmake
# Boost Libraries: uses ceph build boost cmake/modules/BuildBoost.cmake
include(BuildOpenTracing)
# will do all linking and path setting
function(set_library_properties_for_external_project _target _lib)
# Manually create the directory, it will be created as part of the build,
# but this runs in the configuration phase, and CMake generates an error if
# we add an include directory that does not exist yet.
set(_libfullname "${CMAKE_SHARED_LIBRARY_PREFIX}${_lib}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(_libpath "${CMAKE_BINARY_DIR}/external/lib/${_libfullname}")
set(_includepath "${CMAKE_BINARY_DIR}/external/include")
message(STATUS "Configuring ${_target} with ${_libpath}")
add_library(${_target} SHARED IMPORTED)
add_dependencies(${_target} ${_lib})
file(MAKE_DIRECTORY "${_includepath}")
set_target_properties(${_target} PROPERTIES
INTERFACE_LINK_LIBRARIES "${_libpath}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${_libpath}"
INTERFACE_INCLUDE_DIRECTORIES "${_includepath}")
endfunction()
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 "${CMAKE_BINARY_DIR}/external/jaegertracing")
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_FIND_ROOT_PATH=${CMAKE_BINARY_DIR}/external
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external
-DCMAKE_INSTALL_LIBDIR=${CMAKE_BINARY_DIR}/external/lib
-DBoost_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/boost/include
-DBOOST_ROOT=${CMAKE_BINARY_DIR}/boost
-Dthrift_HOME=${CMAKE_BINARY_DIR}/external
-DOpenTracing_HOME=${CMAKE_BINARY_DIR}/external)
# build these libraries along with jaeger
set(dependencies opentracing)
if(NOT WITH_SYSTEM_BOOST)
list(APPEND dependencies Boost)
endif()
include(BuildOpenTracing)
build_opentracing()
if(CMAKE_MAKE_PROGRAM MATCHES "make")
# try to inherit command line arguments passed by parent "make" job
set(make_cmd $(MAKE) jaegertracing)
else()
set(make_cmd ${CMAKE_COMMAND} --build <BINARY_DIR> --target jaegertracing)
endif()
cmake: change debian DESTDIR for installing jaeger deps debian uses debian/tmp as destination dir for installing build files, but since we are using common path($build_dir/external) available both for rpm and debian based dependency installation, it becomes far more complicated to maintain include/link path for these external projects. elaborating on it: path we are configuring for both rpm and debian installing including, and linking of external librarires: /build/ceph-17.0.0-5779-g928f9e55/obj-x86_64-linux-gnu/external/ debian appends DESTDIR to this path, and hence our predefined target artificats cannot find correct path for external libs, I tried adding ENV${DESTDIR} so that it could include correct external lib install path, but it still cannot find them: failed to link in case of: - install(DIRECTORY $ENV{DESTDIR}${CMAKE_BINARY_DIR}/external/include/jaegertracing - $ENV{DESTDIR}${CMAKE_BINARY_DIR}/external/include/opentracing - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - include_directories(SYSTEM ${CMAKE_INSTALL_INCLUDEDIR}/jaegertracing) - include_directories(SYSTEM ${CMAKE_INSTALL_INCLUDEDIR}/opentracing) -- Installing: /build/ceph-17.0.0-5790-g6bc03cbd/debian/tmp/build/ceph-17.0.0-5790-g6bc03cbd/obj-x86_64-linux-gnu/external/include/jaegertracing/Tracer.h cd /build/ceph-17.0.0-5790-g6bc03cbd/obj-x86_64-linux-gnu/src && /usr/bin/c++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -I/build/ceph-17.0.0-5790-g6bc03cbd/obj-x86_64-linux-gnu/src/include -I/build/ceph-17.0.0-5790-g6bc03cbd/src -isystem /build/ceph-17.0.0-5790-g6bc03cbd/obj-x86_64-linux-gnu/boost/include -isystem /build/ceph-17.0.0-5790-g6bc03cbd/obj-x86_64-linux-gnu/include -isystem /build/ceph-17.0.0-5790-g6bc03cbd/src/xxHash -isystem /build/ceph-17.0.0-5790-g6bc03cbd/src/rapidjson/include -isystem /build/ceph-17.0.0-5790-g6bc03cbd/src/include/jaegertracing -isystem /build/ceph-17.0.0-5790-g6bc03cbd/src/include/opentracing -g -O2 -fdebug-prefix-map=/build/ceph-17.0.0-5790-g6bc03cbd=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -U_FORTIFY_SOURCE -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fno-new-ttp-matching -fstack-protector-strong -fdiagnostics-color=auto -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -std=c++17 -o CMakeFiles/common-objs.dir/mds/mdstypes.cc.o -c /build/ceph-17.0.0-5790-g6bc03cbd/src/mds/mdstypes.cc In file included from /build/ceph-17.0.0-5790-g6bc03cbd/src/osd/OpRequest.h:21, from /build/ceph-17.0.0-5790-g6bc03cbd/src/osd/OpRequest.cc:3: /build/ceph-17.0.0-5790-g6bc03cbd/src/common/tracer.h:10:10: fatal error: jaegertracing/Tracer.h: No such file or directory Since the install path is in our build environment for these librarires, skipping DESTDIR looks to me hacky fix, but does the job. with empty destdir: -- Installing: /build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/external/include/jaegertracing/Tracer.h cd /build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/src/mon && /usr/bin/c++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -I/build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/src/include -I/build/ceph-17.0.0-5791-gb97b9640/src -isystem /build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/boost/include -isystem /build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/include -isystem /build/ceph-17.0.0-5791-gb97b9640/src/xxHash -isystem /build/ceph-17.0.0-5791-gb97b9640/src/rapidjson/include -isystem /build/ceph-17.0.0-5791-gb97b9640/obj-x86_64-linux-gnu/external/include -isystem /build/ceph-17.0.0-5791-gb97b9640/src/rocksdb/include -g -O2 -fdebug-prefix-map=/build/ceph-17.0.0-5791-gb97b9640=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -U_FORTIFY_SOURCE -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fno-new-ttp-matching -fstack-protector-strong -fdiagnostics-color=auto -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -std=c++17 -o CMakeFiles/mon.dir/MgrMonitor.cc.o -c /build/ceph-17.0.0-5791-gb97b9640/src/mon/MgrMonitor.cc Signed-off-by: Deepika Upadhyay <dupadhya@redhat.com>
2021-07-21 16:06:33 +00:00
set(install_cmd DESTDIR= ${CMAKE_MAKE_PROGRAM} install)
include(ExternalProject)
ExternalProject_Add(jaegertracing
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}
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/external/lib/libjaegertracing.so
)
set_library_properties_for_external_project(opentracing::libopentracing
opentracing)
set_library_properties_for_external_project(jaegertracing::libjaegertracing
jaegertracing)
endfunction()