From 330777051ee8f2d5781e19cffa6674a99486f4c6 Mon Sep 17 00:00:00 2001 From: Ali Maredia Date: Wed, 30 Dec 2015 23:34:30 -0500 Subject: [PATCH] cmake: Babeltrace detection supported Babeltrace defaults to ON, Findbabeltrace.cmake & BABELTRACE variables in config-h.in.cmake added. Signed-off-by: Ali Maredia --- CMakeLists.txt | 9 +++++ cmake/modules/Findbabeltrace.cmake | 61 ++++++++++++++++++++++++++++++ src/include/config-h.in.cmake | 9 +++++ 3 files changed, 79 insertions(+) create mode 100644 cmake/modules/Findbabeltrace.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e37e03cba5f..27de8806ee5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,6 +253,15 @@ if(${WITH_LTTNG}) set(WITH_LTTNG ${LTTNG_FOUND}) endif(${WITH_LTTNG}) +#option for Babeltrace +option(HAVE_BABELTRACE "Babeltrace libraries are enabled" ON) +if(${HAVE_BABELTRACE}) + find_package(babeltrace REQUIRED) + set(WITH_BABELTRACE ${BABELTRACE_FOUND}) + set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND}) + set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND}) +endif(${HAVE_BABELTRACE}) + # Now create a useable config.h configure_file( ${PROJECT_SOURCE_DIR}/src/include/config-h.in.cmake diff --git a/cmake/modules/Findbabeltrace.cmake b/cmake/modules/Findbabeltrace.cmake new file mode 100644 index 00000000000..b72b62591eb --- /dev/null +++ b/cmake/modules/Findbabeltrace.cmake @@ -0,0 +1,61 @@ +# - Find Babeltrace +# This module accepts the following optional variables: +# BABELTRACE_PATH_HINT = A hint on BABELTRACE install path. +# +# This module defines the following variables: +# BABELTRACE_FOUND = Was Babeltrace found or not? +# BABELTRACE_EXECUTABLE = The path to lttng command +# BABELTRACE_LIBRARIES = The list of libraries to link to when using Babeltrace +# BABELTRACE_INCLUDE_DIR = The path to Babeltrace include directory +# +# On can set BABELTRACE_PATH_HINT before using find_package(Babeltrace) and the +# module with use the PATH as a hint to find Babeltrace. +# +# The hint can be given on the command line too: +# cmake -DBABELTRACE_PATH_HINT=/DATA/ERIC/Babeltrace /path/to/source + +if(BABELTRACE_PATH_HINT) + message(STATUS "FindBabeltrace: using PATH HINT: ${BABELTRACE_PATH_HINT}") +else() + set(BABELTRACE_PATH_HINT) +endif() + +#One can add his/her own builtin PATH. +#FILE(TO_CMAKE_PATH "/DATA/ERIC/Babeltrace" MYPATH) +#list(APPEND BABELTRACE_PATH_HINT ${MYPATH}) + +find_path(BABELTRACE_INCLUDE_DIR + NAMES babeltrace/babeltrace.h babeltrace/ctf/events.h + PATHS ${BABELTRACE_PATH_HINT} + PATH_SUFFIXES include + DOC "The Babeltrace include headers") + +find_path(BABELTRACE_LIBRARY_DIR + NAMES libbabeltrace.so + NAMES libbabeltrace-ctf.so + PATHS ${BABELTRACE_PATH_HINT} + PATH_SUFFIXES lib lib64 + DOC "The Babeltrace libraries") + +find_library(BABELTRACE NAMES babeltrace babeltrace-ctf PATHS ${BABELTRACE_LIBRARY_DIR}) + +set(BABELTRACE_LIBRARIES ${BABELTRACE}) + +message(STATUS "Looking for Babeltrace...") +set(BABELTRACE_NAMES "babeltrace;babeltrace-ctf") +# FIND_PROGRAM twice using NO_DEFAULT_PATH on first shot +find_program(BABELTRACE_EXECUTABLE + NAMES ${BABELTRACE_NAMES} + PATHS ${BABELTRACE_PATH_HINT}/bin /bin + NO_DEFAULT_PATH + DOC "The BABELTRACE command line tool") + +# handle the QUIETLY and REQUIRED arguments and set PRELUDE_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BABELTRACE + REQUIRED_VARS BABELTRACE_INCLUDE_DIR BABELTRACE_LIBRARY_DIR) +# VERSION FPHSA options not handled by CMake version < 2.8.2) +# VERSION_VAR) +mark_as_advanced(BABELTRACE_INCLUDE_DIR) +mark_as_advanced(BABELTRACE_LIBRARY_DIR) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index af68a403689..c82e8dcc1d4 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -244,6 +244,15 @@ /* Defined if LTTNG */ #cmakedefine WITH_LTTNG 1 +/* Defined if Babeltrace */ +#cmakedefine WITH_BABELTRACE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_BABELTRACE_BABELTRACE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_BABELTRACE_CTF_EVENTS_H 1 + /* Defined if you have librocksdb enabled */ #cmakedefine HAVE_LIBROCKSDB