mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-25 04:11:59 +00:00
refactor: Use FetchContent for integrating bundled yaml-cpp lib
Signed-off-by: Federico Aponte <federico.aponte@sysdig.com>
This commit is contained in:
@@ -12,45 +12,15 @@
|
||||
# specific language governing permissions and limitations under the License.
|
||||
#
|
||||
|
||||
#
|
||||
# yamlcpp (https://github.com/jbeder/yaml-cpp)
|
||||
#
|
||||
|
||||
option(USE_BUNDLED_YAMLCPP "Enable building of the bundled yamlcpp" ${USE_BUNDLED_DEPS})
|
||||
|
||||
if(YAMLCPP_INCLUDE_DIR)
|
||||
# we already have yamlcpp
|
||||
elseif(NOT USE_BUNDLED_YAMLCPP)
|
||||
find_path(YAMLCPP_INCLUDE_DIR NAMES yaml-cpp/yaml.h)
|
||||
find_library(YAMLCPP_LIB NAMES yaml-cpp)
|
||||
|
||||
if(YAMLCPP_INCLUDE_DIR)
|
||||
message(STATUS "Found yamlcpp: include: ${YAMLCPP_INCLUDE_DIR}")
|
||||
else()
|
||||
message(FATAL_ERROR "Couldn't find system yamlcpp")
|
||||
endif()
|
||||
if(USE_BUNDLED_YAMLCPP)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(yamlcpp
|
||||
URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz
|
||||
URL_HASH SHA256=fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16
|
||||
)
|
||||
FetchContent_MakeAvailable(yamlcpp)
|
||||
else()
|
||||
set(YAMLCPP_SRC "${PROJECT_BINARY_DIR}/yamlcpp-prefix/src/yamlcpp")
|
||||
set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC}/include")
|
||||
|
||||
message(STATUS "Using bundled yaml-cpp in '${YAMLCPP_SRC}'")
|
||||
|
||||
if(NOT WIN32)
|
||||
set(YAMLCPP_LIB "${YAMLCPP_SRC}/libyaml-cpp.a")
|
||||
else()
|
||||
set(YAMLCPP_LIB "${YAMLCPP_SRC}/${CMAKE_BUILD_TYPE}/yaml-cpp.lib")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(
|
||||
yamlcpp
|
||||
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
|
||||
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
|
||||
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
|
||||
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DYAML_MSVC_SHARED_RT=Off -DYAML_BUILD_SHARED_LIBS=Off -DYAML_CPP_BUILD_TESTS=Off -DYAML_CPP_BUILD_TOOLS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DCMAKE_DEBUG_POSTFIX=''
|
||||
BUILD_IN_SOURCE 1
|
||||
INSTALL_COMMAND "")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET yamlcpp)
|
||||
add_custom_target(yamlcpp)
|
||||
find_package(yaml-cpp CONFIG REQUIRED)
|
||||
endif()
|
||||
|
@@ -33,17 +33,15 @@ if (EMSCRIPTEN)
|
||||
target_compile_options(falco_engine PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
||||
endif()
|
||||
|
||||
add_dependencies(falco_engine yamlcpp)
|
||||
|
||||
target_include_directories(falco_engine
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${TBB_INCLUDE_DIR}
|
||||
${YAMLCPP_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(falco_engine
|
||||
PUBLIC
|
||||
sinsp
|
||||
nlohmann_json::nlohmann_json
|
||||
yaml-cpp
|
||||
)
|
||||
|
@@ -14,8 +14,7 @@
|
||||
|
||||
configure_file(config_falco.h.in config_falco.h)
|
||||
|
||||
set(
|
||||
FALCO_SOURCES
|
||||
add_library(falco_application STATIC
|
||||
app/app.cpp
|
||||
app/options.cpp
|
||||
app/restart_handler.cpp
|
||||
@@ -62,16 +61,12 @@ set(
|
||||
set(
|
||||
FALCO_INCLUDE_DIRECTORIES
|
||||
"${PROJECT_SOURCE_DIR}/userspace/engine"
|
||||
"${PROJECT_BINARY_DIR}/userspace/falco"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${PROJECT_BINARY_DIR}/driver/src"
|
||||
"${CXXOPTS_INCLUDE_DIR}"
|
||||
"${YAMLCPP_INCLUDE_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
list(APPEND FALCO_INCLUDE_DIRECTORIES "${FALCO_EXTRA_INCLUDE_DIRS}")
|
||||
|
||||
set(
|
||||
FALCO_DEPENDENCIES
|
||||
cxxopts
|
||||
@@ -81,22 +76,20 @@ set(
|
||||
FALCO_LIBRARIES
|
||||
falco_engine
|
||||
sinsp
|
||||
"${YAMLCPP_LIB}"
|
||||
yaml-cpp
|
||||
)
|
||||
|
||||
list(APPEND FALCO_DEPENDENCIES yamlcpp)
|
||||
|
||||
if(NOT WIN32)
|
||||
list(
|
||||
APPEND FALCO_SOURCES
|
||||
outputs_program.cpp
|
||||
outputs_syslog.cpp
|
||||
)
|
||||
target_sources(falco_application
|
||||
PRIVATE
|
||||
outputs_program.cpp
|
||||
outputs_syslog.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
|
||||
list(
|
||||
APPEND FALCO_SOURCES
|
||||
target_sources(falco_application
|
||||
PRIVATE
|
||||
outputs_grpc.cpp
|
||||
outputs_http.cpp
|
||||
webserver.cpp
|
||||
@@ -136,15 +129,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
|
||||
"${PROTOBUF_LIB}"
|
||||
"${CARES_LIB}"
|
||||
"${OPENSSL_LIBRARIES}"
|
||||
"${YAMLCPP_LIB}"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
falco_application STATIC
|
||||
${FALCO_SOURCES}
|
||||
)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
target_compile_options(falco_application PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
||||
endif()
|
||||
|
@@ -16,14 +16,15 @@ limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
#define CPPHTTPLIB_ZLIB_SUPPORT
|
||||
#include <httplib.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <libsinsp/sinsp.h>
|
||||
#include "configuration.h"
|
||||
|
||||
#include <libsinsp/sinsp.h>
|
||||
|
||||
#include <httplib.h>
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
class falco_webserver
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user