#1879·sysdig

No system package for njson

Author: dadavCreated Jun 11, 2022Updated Apr 19, 2023
Labelspinnedfeature-request

Hello ppl. from the internet,

I'm running archlinux with kernel 5.18.3-arch1-1 and couldn't build sysdig with my system libraries because there is no system package for njson. Using USE_BUNDLED_DEPS=ON also doesn't work because of some GSASL ERROR, see here: https://github.com/falcosecurity/falco/issues/2040

I used the following commands

bash
mkdir build
cd build
cmake .. -DBUILD_BPF=ON -DUSE_BUNDLED_DEPS=OFF
make -j12 sysdig

To make this thing work, I need to modify the cmake/modules/nlohmann-json.cmake file to basically exclude this library from the USE_BUNDLED_DEPS=OFF option...like this:

bash

if(NOT USE_BUNDLED_DEPS)
  find_path(NJSON_INCLUDE_DIR NAMES nlohmann/json.hpp)
  if(NJSON_INCLUDE_DIR)
    message(STATUS "Found njson: include: ${NJSON_INCLUDE_DIR}")
  else()
    message(FATAL_ERROR "Couldn't find system njson")
  endif()
else()
  set(NJSON_SRC "${PROJECT_BINARY_DIR}/njson-prefix/src/njson")
  message(STATUS "Using bundled nlohmann-json in '${NJSON_SRC}'")
  set(NJSON_INCLUDE_DIR "${NJSON_SRC}/single_include")
  ExternalProject_Add(
    njson
    URL "https://github.com/nlohmann/json/archive/v3.3.0.tar.gz"
    URL_HASH "SHA256=2fd1d207b4669a7843296c41d3b6ac5b23d00dec48dba507ba051d14564aa801"
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND "")
endif()

to

bash
  set(NJSON_SRC "${PROJECT_BINARY_DIR}/njson-prefix/src/njson")
  message(STATUS "Using bundled nlohmann-json in '${NJSON_SRC}'")
  set(NJSON_INCLUDE_DIR "${NJSON_SRC}/single_include")
  ExternalProject_Add(
    njson
    URL "https://github.com/nlohmann/json/archive/v3.3.0.tar.gz"
    URL_HASH "SHA256=2fd1d207b4669a7843296c41d3b6ac5b23d00dec48dba507ba051d14564aa801"
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND "")

Proposal

Add a cmake option to exclude njson from the USE_BUNDLED_DEPS=OFF effects.

What do you think?