From 6bfa81f938627dfae8829d8cd5b8b1fd5d28346c Mon Sep 17 00:00:00 2001 From: Grzegorz Nosek Date: Thu, 25 Mar 2021 17:53:13 +0100 Subject: [PATCH] Move libsinsp to a cmake module Signed-off-by: Grzegorz Nosek --- CMakeLists.txt | 2 +- cmake/modules/libsinsp.cmake | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 cmake/modules/libsinsp.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fbc750ba9c..4ca9d94966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ option(WITH_CHISEL "Include chisel implementation" OFF) option(CREATE_TEST_TARGETS "Enable make-targets for unit testing" ON) include(libscap) -add_subdirectory(userspace/libsinsp) +include(libsinsp) if(CREATE_TEST_TARGETS AND NOT WIN32) # Add command to run all unit tests at once via the make system. diff --git a/cmake/modules/libsinsp.cmake b/cmake/modules/libsinsp.cmake new file mode 100644 index 0000000000..82265bdd70 --- /dev/null +++ b/cmake/modules/libsinsp.cmake @@ -0,0 +1,38 @@ +if(NOT HAVE_LIBSINSP) +set(HAVE_LIBSINSP On) + +if(NOT LIBSINSP_DIR) + get_filename_component(LIBSINSP_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE) +endif() + +option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" ON) + +option(WITH_CHISEL "Include chisel implementation" OFF) + +include(ExternalProject) +include(libscap) +include(tbb) +include(jsoncpp) +include(cares) +include(b64) +include(jq) + +set(LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/libsinsp ${LIBSCAP_INCLUDE_DIRS} ${DRIVER_CONFIG_DIR}) +if(WITH_CHISEL) + list(APPEND LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/chisel) +endif() + +get_filename_component(TBB_ABSOLUTE_INCLUDE_DIR ${TBB_INCLUDE_DIR} ABSOLUTE) +list(APPEND LIBSINSP_INCLUDE_DIRS ${TBB_ABSOLUTE_INCLUDE_DIR}) +get_filename_component(JSONCPP_ABSOLUTE_INCLUDE_DIR ${JSONCPP_INCLUDE} ABSOLUTE) +list(APPEND LIBSINSP_INCLUDE_DIRS ${JSONCPP_ABSOLUTE_INCLUDE_DIR}) +get_filename_component(CARES_ABSOLUTE_INCLUDE_DIR ${CARES_INCLUDE} ABSOLUTE) +list(APPEND LIBSINSP_INCLUDE_DIRS ${CARES_ABSOLUTE_INCLUDE_DIR}) +get_filename_component(B64_ABSOLUTE_INCLUDE_DIR ${B64_INCLUDE} ABSOLUTE) +list(APPEND LIBSINSP_INCLUDE_DIRS ${B64_ABSOLUTE_INCLUDE_DIR}) +get_filename_component(JQ_ABSOLUTE_INCLUDE_DIR ${JQ_INCLUDE} ABSOLUTE) +list(APPEND LIBSINSP_INCLUDE_DIRS ${JQ_ABSOLUTE_INCLUDE_DIR}) + +add_subdirectory(${LIBSINSP_DIR}/userspace/libsinsp ${CMAKE_BINARY_DIR}/libsinsp) + +endif()