Skip to content

Commit

Permalink
fix(cmake/modules): use yaml-cpp from falcosecurity until next libs r…
Browse files Browse the repository at this point in the history
…elease

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Jul 18, 2024
1 parent 9d4f2da commit 3290b06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 86 deletions.
99 changes: 19 additions & 80 deletions cmake/modules/yaml-cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,87 +1,26 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2013-2022 Draios Inc dba Sysdig.
# Copyright (C) 2023 The Falco Authors.
#
# This file is part of sysdig .
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIB)
if(NOT USE_BUNDLED_DEPS)
find_path(YAMLCPP_INCLUDE_DIR NAMES yaml-cpp/yaml.h)
find_library(YAMLCPP_LIB NAMES yaml-cpp)
if(YAMLCPP_INCLUDE_DIR AND YAMLCPP_LIB)
message(STATUS "Found yamlcpp: include: ${YAMLCPP_INCLUDE_DIR}, lib: ${YAMLCPP_LIB}")
else()
message(FATAL_ERROR "Couldn't find system yamlcpp")
endif()

option(USE_BUNDLED_YAMLCPP "Enable building of the bundled yamlcpp" ${USE_BUNDLED_DEPS})

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}/yaml-cpp-prefix/src/yaml-cpp")
message(STATUS "Using bundled yaml-cpp in '${YAMLCPP_SRC}'")
set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC}/include")
if(NOT WIN32)
set(YAMLCPP_LIB "${YAMLCPP_SRC}/libyaml-cpp.a")
ExternalProject_Add(
yaml-cpp
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 "")
else()
set(YAMLCPP_LIB "${YAMLCPP_SRC}/${CMAKE_BUILD_TYPE}/yaml-cpp.lib")
# see: https://cmake.org/cmake/help/latest/policy/CMP0091.html
if(CMAKE_VERSION VERSION_LESS 3.15.0)
ExternalProject_Add(
yaml-cpp
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 "")
else()
ExternalProject_Add(
yaml-cpp
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_POLICY_DEFAULT_CMP0091:STRING=NEW
-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}
-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()
endif()
find_package(yaml-cpp CONFIG REQUIRED)
endif()
10 changes: 4 additions & 6 deletions userspace/sysdig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ endif()
target_include_directories(
sysdig
PUBLIC
"${YAMLCPP_INCLUDE_DIR}"
"${NJSON_INCLUDE_DIR}"
"${LUAJIT_INCLUDE}"
../chisel
Expand All @@ -97,7 +96,6 @@ target_include_directories(
target_include_directories(
csysdig
PUBLIC
"${YAMLCPP_INCLUDE_DIR}"
"${NJSON_INCLUDE_DIR}"
"${LUAJIT_INCLUDE}"
../chisel
Expand All @@ -110,7 +108,7 @@ if(NOT WIN32)
target_link_libraries(sysdig
sinsp
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")
yaml-cpp)

if(USE_BUNDLED_NCURSES)
add_dependencies(csysdig ncurses)
Expand All @@ -120,7 +118,7 @@ if(NOT WIN32)
sinsp
"${LUAJIT_LIB}"
"${CURSES_LIBRARIES}"
"${YAMLCPP_LIB}")
yaml-cpp)

add_subdirectory(man)

Expand All @@ -142,12 +140,12 @@ else()
target_link_libraries(sysdig
sinsp
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")
yaml-cpp)

target_link_libraries(csysdig
sinsp
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")
yaml-cpp)

target_link_libraries(sysdig odbc32.lib odbccp32.lib Netapi32.lib Iphlpapi.lib)

Expand Down

0 comments on commit 3290b06

Please sign in to comment.