diff --git a/cmake/modules/njson.cmake b/cmake/modules/njson.cmake index b3828f94..c83d48f2 100644 --- a/cmake/modules/njson.cmake +++ b/cmake/modules/njson.cmake @@ -12,29 +12,15 @@ # specific language governing permissions and limitations under the License. # -# -# njson (https://github.com/nlohmann/json) -# - option(USE_BUNDLED_NLOHMANN_JSON "Enable building of the bundled nlohmann-json" ${USE_BUNDLED_DEPS}) -if(nlohmann_json_INCLUDE_DIRS) - # we already have nlohmnann-json -elseif(NOT USE_BUNDLED_NLOHMANN_JSON) - find_package(nlohmann_json CONFIG REQUIRED) - get_target_property(nlohmann_json_INCLUDE_DIRS nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) -else() - set(nlohmann_json_INCLUDE_DIRS "${PROJECT_BINARY_DIR}/njson-prefix/include") - - message(STATUS "Using bundled nlohmann-json in ${nlohmann_json_INCLUDE_DIRS}") - - ExternalProject_Add(njson - URL "https://github.com/nlohmann/json/archive/v3.3.0.tar.gz" - URL_HASH "SHA256=2fd1d207b4669a7843296c41d3b6ac5b23d00dec48dba507ba051d14564aa801" - CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/njson-prefix -DJSON_BuildTests=OFF -DBUILD_TESTING=OFF +if(USE_BUNDLED_NLOHMANN_JSON) + include(FetchContent) + FetchContent_Declare(nlohmann_json + URL https://github.com/nlohmann/json/archive/v3.11.3.tar.gz + URL_HASH SHA256=0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406 ) -endif() - -if(NOT TARGET njson) - add_custom_target(njson) + FetchContent_MakeAvailable(nlohmann_json) +else() + find_package(nlohmann_json CONFIG REQUIRED) endif() diff --git a/userspace/engine/CMakeLists.txt b/userspace/engine/CMakeLists.txt index 372c4d90..1db0fe9d 100644 --- a/userspace/engine/CMakeLists.txt +++ b/userspace/engine/CMakeLists.txt @@ -33,12 +33,11 @@ if (EMSCRIPTEN) target_compile_options(falco_engine PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0") endif() -add_dependencies(falco_engine yamlcpp njson) +add_dependencies(falco_engine yamlcpp) target_include_directories(falco_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - ${nlohmann_json_INCLUDE_DIRS} ${TBB_INCLUDE_DIR} ${YAMLCPP_INCLUDE_DIR} ) @@ -46,5 +45,5 @@ PUBLIC target_link_libraries(falco_engine PUBLIC sinsp - ${YAMLCPP_LIB} + nlohmann_json::nlohmann_json )