Skip to content

Commit 78ed533

Browse files
committed
fix(cmake/modules): use yaml from falcosecurity until next libs release
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent 9d4f2da commit 78ed533

File tree

1 file changed

+19
-80
lines changed

1 file changed

+19
-80
lines changed

cmake/modules/yaml-cpp.cmake

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,26 @@
1+
# SPDX-License-Identifier: Apache-2.0
12
#
2-
# Copyright (C) 2013-2022 Draios Inc dba Sysdig.
3+
# Copyright (C) 2023 The Falco Authors.
34
#
4-
# This file is part of sysdig .
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
57
#
6-
# Licensed under the Apache License, Version 2.0 (the "License");
7-
# you may not use this file except in compliance with the License.
8-
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
99
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
10+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
11+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
1113
#
12-
# Unless required by applicable law or agreed to in writing, software
13-
# distributed under the License is distributed on an "AS IS" BASIS,
14-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
# See the License for the specific language governing permissions and
16-
# limitations under the License.
17-
#
18-
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIB)
19-
if(NOT USE_BUNDLED_DEPS)
20-
find_path(YAMLCPP_INCLUDE_DIR NAMES yaml-cpp/yaml.h)
21-
find_library(YAMLCPP_LIB NAMES yaml-cpp)
22-
if(YAMLCPP_INCLUDE_DIR AND YAMLCPP_LIB)
23-
message(STATUS "Found yamlcpp: include: ${YAMLCPP_INCLUDE_DIR}, lib: ${YAMLCPP_LIB}")
24-
else()
25-
message(FATAL_ERROR "Couldn't find system yamlcpp")
26-
endif()
14+
15+
option(USE_BUNDLED_YAMLCPP "Enable building of the bundled yamlcpp" ${USE_BUNDLED_DEPS})
16+
17+
if(USE_BUNDLED_YAMLCPP)
18+
include(FetchContent)
19+
FetchContent_Declare(yamlcpp
20+
URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz
21+
URL_HASH SHA256=fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16
22+
)
23+
FetchContent_MakeAvailable(yamlcpp)
2724
else()
28-
set(YAMLCPP_SRC "${PROJECT_BINARY_DIR}/yaml-cpp-prefix/src/yaml-cpp")
29-
message(STATUS "Using bundled yaml-cpp in '${YAMLCPP_SRC}'")
30-
set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC}/include")
31-
if(NOT WIN32)
32-
set(YAMLCPP_LIB "${YAMLCPP_SRC}/libyaml-cpp.a")
33-
ExternalProject_Add(
34-
yaml-cpp
35-
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
36-
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
37-
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
38-
CMAKE_ARGS
39-
-DCMAKE_BUILD_TYPE=Release
40-
-DYAML_MSVC_SHARED_RT=Off
41-
-DYAML_BUILD_SHARED_LIBS=Off
42-
-DYAML_CPP_BUILD_TESTS=Off
43-
-DYAML_CPP_BUILD_TOOLS=OFF
44-
-DYAML_CPP_BUILD_CONTRIB=OFF
45-
-DCMAKE_DEBUG_POSTFIX=''
46-
BUILD_IN_SOURCE 1
47-
INSTALL_COMMAND "")
48-
else()
49-
set(YAMLCPP_LIB "${YAMLCPP_SRC}/${CMAKE_BUILD_TYPE}/yaml-cpp.lib")
50-
# see: https://cmake.org/cmake/help/latest/policy/CMP0091.html
51-
if(CMAKE_VERSION VERSION_LESS 3.15.0)
52-
ExternalProject_Add(
53-
yaml-cpp
54-
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
55-
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
56-
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
57-
CMAKE_ARGS
58-
-DCMAKE_BUILD_TYPE=Release
59-
-DYAML_MSVC_SHARED_RT=Off
60-
-DYAML_BUILD_SHARED_LIBS=Off
61-
-DYAML_CPP_BUILD_TESTS=Off
62-
-DYAML_CPP_BUILD_TOOLS=OFF
63-
-DYAML_CPP_BUILD_CONTRIB=OFF
64-
-DCMAKE_DEBUG_POSTFIX=''
65-
BUILD_IN_SOURCE 1
66-
INSTALL_COMMAND "")
67-
else()
68-
ExternalProject_Add(
69-
yaml-cpp
70-
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
71-
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
72-
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
73-
CMAKE_ARGS
74-
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW
75-
-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}
76-
-DCMAKE_BUILD_TYPE=Release
77-
-DYAML_MSVC_SHARED_RT=Off
78-
-DYAML_BUILD_SHARED_LIBS=Off
79-
-DYAML_CPP_BUILD_TESTS=Off
80-
-DYAML_CPP_BUILD_TOOLS=OFF
81-
-DYAML_CPP_BUILD_CONTRIB=OFF
82-
-DCMAKE_DEBUG_POSTFIX=''
83-
BUILD_IN_SOURCE 1
84-
INSTALL_COMMAND "")
85-
endif()
86-
endif()
25+
find_package(yaml-cpp CONFIG REQUIRED)
8726
endif()

0 commit comments

Comments
 (0)