2
2
#
3
3
# Copyright (C) 2023 The Falco Authors.
4
4
#
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
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6
+ # in compliance with the License. You may obtain a copy of the License at
7
7
#
8
8
# http://www.apache.org/licenses/LICENSE-2.0
9
9
#
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.
10
+ # Unless required by applicable law or agreed to in writing, software distributed under the License
11
+ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
+ # or implied. See the License for the specific language governing permissions and limitations under
13
+ # the License.
13
14
#
14
15
cmake_minimum_required (VERSION 3.5.1)
15
16
@@ -18,62 +19,82 @@ project(falco)
18
19
option (USE_BUNDLED_DEPS "Bundle hard to find dependencies into the Falco binary" ON )
19
20
option (USE_DYNAMIC_LIBELF "Dynamically link libelf" ON )
20
21
option (BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags" OFF )
21
- option (MINIMAL_BUILD "Build a minimal version of Falco, containing only the engine and basic input/output (EXPERIMENTAL)" OFF )
22
+ option (
23
+ MINIMAL_BUILD
24
+ "Build a minimal version of Falco, containing only the engine and basic input/output (EXPERIMENTAL)"
25
+ OFF
26
+ )
22
27
option (MUSL_OPTIMIZED_BUILD "Enable if you want a musl optimized build" OFF )
23
28
option (BUILD_FALCO_UNIT_TESTS "Build falco unit tests" OFF )
24
29
option (USE_ASAN "Build with AddressSanitizer" OFF )
25
30
option (USE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF )
26
31
option (UBSAN_HALT_ON_ERROR "Halt on error when building with UBSan" ON )
27
32
28
33
if (WIN32 )
29
- if (POLICY CMP0091)
30
- # Needed for CMAKE_MSVC_RUNTIME_LIBRARY
31
- # https://cmake.org/cmake/help/latest/policy/CMP0091.html
32
- cmake_policy (SET CMP0091 NEW)
33
- endif ()
34
+ if (POLICY CMP0091)
35
+ # Needed for CMAKE_MSVC_RUNTIME_LIBRARY
36
+ # https://cmake.org/cmake/help/latest/policy/CMP0091.html
37
+ cmake_policy (SET CMP0091 NEW)
38
+ endif ()
34
39
set (CPACK_GENERATOR "NSIS" ) # this needs NSIS installed, and available
35
- elseif (APPLE )
40
+ elseif (APPLE )
36
41
set (CPACK_GENERATOR "DragNDrop" )
37
42
elseif (EMSCRIPTEN)
38
- set (USE_BUNDLED_DEPS ON CACHE BOOL "" FORCE)
39
- set (BUILD_DRIVER OFF CACHE BOOL "" FORCE)
40
- set (ENABLE_DKMS OFF CACHE BOOL "" FORCE)
41
- set (BUILD_BPF OFF CACHE BOOL "" FORCE)
42
- set (CPACK_GENERATOR TGZ CACHE BOOL "" FORCE)
43
+ set (USE_BUNDLED_DEPS
44
+ ON
45
+ CACHE BOOL "" FORCE
46
+ )
47
+ set (BUILD_DRIVER
48
+ OFF
49
+ CACHE BOOL "" FORCE
50
+ )
51
+ set (ENABLE_DKMS
52
+ OFF
53
+ CACHE BOOL "" FORCE
54
+ )
55
+ set (BUILD_BPF
56
+ OFF
57
+ CACHE BOOL "" FORCE
58
+ )
59
+ set (CPACK_GENERATOR
60
+ TGZ
61
+ CACHE BOOL "" FORCE
62
+ )
43
63
endif ()
44
64
45
65
# gVisor is currently only supported on Linux x86_64
46
- if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
47
- option (BUILD_FALCO_GVISOR "Build gVisor support for Falco" ON )
48
- if (BUILD_FALCO_GVISOR)
49
- add_definitions (-DHAS_GVISOR)
50
- endif ()
66
+ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
67
+ AND CMAKE_SYSTEM_NAME MATCHES "Linux"
68
+ AND NOT MINIMAL_BUILD
69
+ )
70
+ option (BUILD_FALCO_GVISOR "Build gVisor support for Falco" ON )
71
+ if (BUILD_FALCO_GVISOR)
72
+ add_definitions (-DHAS_GVISOR)
73
+ endif ()
51
74
endif ()
52
75
53
76
# Modern BPF is not supported on not Linux systems and in MINIMAL_BUILD
54
77
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
55
- option (BUILD_FALCO_MODERN_BPF "Build modern BPF support for Falco" ON )
56
- if (BUILD_FALCO_MODERN_BPF)
57
- add_definitions (-DHAS_MODERN_BPF)
58
- endif ()
78
+ option (BUILD_FALCO_MODERN_BPF "Build modern BPF support for Falco" ON )
79
+ if (BUILD_FALCO_MODERN_BPF)
80
+ add_definitions (-DHAS_MODERN_BPF)
81
+ endif ()
59
82
endif ()
60
83
61
84
# We shouldn't need to set this, see https://gitlab.kitware.com/cmake/cmake/-/issues/16419
62
85
option (EP_UPDATE_DISCONNECTED "ExternalProject update disconnected" OFF )
63
- if (${EP_UPDATE_DISCONNECTED} )
64
- set_property (
65
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
66
- PROPERTY EP_UPDATE_DISCONNECTED TRUE )
86
+ if (${EP_UPDATE_DISCONNECTED} )
87
+ set_property (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY EP_UPDATE_DISCONNECTED TRUE )
67
88
endif ()
68
89
69
- # Elapsed time
70
- # set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") # TODO(fntlnz, leodido): add a flag to enable this
90
+ # Elapsed time set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") #
91
+ # TODO(fntlnz, leodido): add a flag to enable this
71
92
72
93
# Make flag for parallel processing
73
94
include (ProcessorCount)
74
- processorcount (PROCESSOR_COUNT)
95
+ ProcessorCount (PROCESSOR_COUNT)
75
96
if (NOT PROCESSOR_COUNT EQUAL 0)
76
- set (PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT} )
97
+ set (PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT} )
77
98
endif ()
78
99
79
100
# Custom CMake modules
@@ -83,14 +104,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
83
104
include (GNUInstallDirs)
84
105
85
106
if (NOT DEFINED FALCO_ETC_DIR)
86
- set (FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR} /falco" )
107
+ set (FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR} /falco" )
87
108
endif ()
88
109
89
110
# This will be used to print the architecture for which Falco is compiled.
90
- if (EMSCRIPTEN)
91
- set (FALCO_TARGET_ARCH "wasm" )
111
+ if (EMSCRIPTEN)
112
+ set (FALCO_TARGET_ARCH "wasm" )
92
113
else ()
93
- set (FALCO_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
114
+ set (FALCO_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
94
115
endif ()
95
116
96
117
include (CompilerFlags)
@@ -100,19 +121,20 @@ set(DRIVER_NAME "falco")
100
121
set (DRIVER_DEVICE_NAME "falco" )
101
122
set (DRIVERS_REPO "https://download.falco.org/driver" )
102
123
103
- # If no path is provided, try to search the BPF probe in: `home/.falco/falco-bpf.o`
104
- # This is the same fallback that we had in the libraries: `SCAP_PROBE_BPF_FILEPATH`.
124
+ # If no path is provided, try to search the BPF probe in: `home/.falco/falco-bpf.o` This is the same
125
+ # fallback that we had in the libraries: `SCAP_PROBE_BPF_FILEPATH`.
105
126
set (FALCO_PROBE_BPF_FILEPATH ".${DRIVER_NAME} /${DRIVER_NAME} -bpf.o" )
106
127
add_definitions (-DFALCO_PROBE_BPF_FILEPATH="${FALCO_PROBE_BPF_FILEPATH} " )
107
128
108
129
if (NOT DEFINED FALCO_COMPONENT_NAME)
109
- set (FALCO_COMPONENT_NAME "${CMAKE_PROJECT_NAME} " )
130
+ set (FALCO_COMPONENT_NAME "${CMAKE_PROJECT_NAME} " )
110
131
endif ()
111
132
112
133
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
113
- set (CMAKE_INSTALL_PREFIX
114
- /usr
115
- CACHE PATH "Default install path" FORCE)
134
+ set (CMAKE_INSTALL_PREFIX
135
+ /usr
136
+ CACHE PATH "Default install path" FORCE
137
+ )
116
138
endif ()
117
139
118
140
set (CMD_MAKE make)
@@ -131,61 +153,93 @@ include(njson)
131
153
# yaml-cpp
132
154
include (yaml-cpp)
133
155
134
- if (NOT WIN32 AND NOT APPLE AND NOT MINIMAL_BUILD AND NOT EMSCRIPTEN)
135
- # OpenSSL
136
- include (openssl)
156
+ if (NOT WIN32
157
+ AND NOT APPLE
158
+ AND NOT MINIMAL_BUILD
159
+ AND NOT EMSCRIPTEN
160
+ )
161
+ # OpenSSL
162
+ include (openssl)
137
163
138
- # libcurl
139
- include (curl)
164
+ # libcurl
165
+ include (curl)
140
166
141
- # todo(jasondellaluce,rohith-raju): support webserver for non-linux builds too
142
- # cpp-httlib
143
- include (cpp-httplib)
167
+ # todo(jasondellaluce,rohith-raju): support webserver for non-linux builds too cpp-httlib
168
+ include (cpp-httplib)
144
169
endif ()
145
170
146
171
include (cxxopts)
147
172
148
173
# One TBB
149
- if (NOT EMSCRIPTEN)
150
- include (tbb)
174
+ if (NOT EMSCRIPTEN)
175
+ include (tbb)
151
176
endif ()
152
177
153
178
include (zlib)
154
179
include (valijson)
155
- if (NOT MINIMAL_BUILD)
156
- if (NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN)
157
- include (cares)
158
- include (protobuf)
159
- # gRPC
160
- include (grpc)
161
- endif ()
180
+ if (NOT MINIMAL_BUILD)
181
+ if (NOT WIN32
182
+ AND NOT APPLE
183
+ AND NOT EMSCRIPTEN
184
+ )
185
+ include (cares)
186
+ include (protobuf)
187
+ # gRPC
188
+ include (grpc)
189
+ endif ()
162
190
endif ()
163
191
164
192
# Installation
165
193
if (WIN32 )
166
- set (FALCO_INSTALL_CONF_FILE "%PROGRAMFILES%/${PACKAGE_NAME} -${FALCO_VERSION} /etc/falco/falco.yaml" )
167
- install (FILES falco.yaml DESTINATION etc/falco/ COMPONENT "${FALCO_COMPONENT_NAME} " )
168
- install (DIRECTORY DESTINATION etc/falco/config.d COMPONENT "${FALCO_COMPONENT_NAME} " )
194
+ set (FALCO_INSTALL_CONF_FILE
195
+ "%PROGRAMFILES%/${PACKAGE_NAME} -${FALCO_VERSION} /etc/falco/falco.yaml"
196
+ )
197
+ install (
198
+ FILES falco.yaml
199
+ DESTINATION etc/falco/
200
+ COMPONENT "${FALCO_COMPONENT_NAME} "
201
+ )
202
+ install (
203
+ DIRECTORY
204
+ DESTINATION etc/falco/config.d
205
+ COMPONENT "${FALCO_COMPONENT_NAME} "
206
+ )
169
207
elseif (APPLE )
170
208
set (FALCO_INSTALL_CONF_FILE "/etc/falco/falco.yaml" )
171
- install (FILES falco.yaml DESTINATION etc/falco/ COMPONENT "${FALCO_COMPONENT_NAME} " )
172
- install (DIRECTORY DESTINATION etc/falco/config.d COMPONENT "${FALCO_COMPONENT_NAME} " )
209
+ install (
210
+ FILES falco.yaml
211
+ DESTINATION etc/falco/
212
+ COMPONENT "${FALCO_COMPONENT_NAME} "
213
+ )
214
+ install (
215
+ DIRECTORY
216
+ DESTINATION etc/falco/config.d
217
+ COMPONENT "${FALCO_COMPONENT_NAME} "
218
+ )
173
219
else ()
174
220
set (FALCO_INSTALL_CONF_FILE "/etc/falco/falco.yaml" )
175
- install (FILES falco.yaml DESTINATION "${FALCO_ETC_DIR} " COMPONENT "${FALCO_COMPONENT_NAME} " )
176
- install (DIRECTORY DESTINATION "${FALCO_ETC_DIR} /config.d" COMPONENT "${FALCO_COMPONENT_NAME} " )
221
+ install (
222
+ FILES falco.yaml
223
+ DESTINATION "${FALCO_ETC_DIR} "
224
+ COMPONENT "${FALCO_COMPONENT_NAME} "
225
+ )
226
+ install (
227
+ DIRECTORY
228
+ DESTINATION "${FALCO_ETC_DIR} /config.d"
229
+ COMPONENT "${FALCO_COMPONENT_NAME} "
230
+ )
177
231
endif ()
178
232
179
233
if (NOT MINIMAL_BUILD)
180
- # Coverage
181
- include (Coverage)
234
+ # Coverage
235
+ include (Coverage)
182
236
endif ()
183
237
184
238
# Rules
185
239
include (rules)
186
240
187
- # Clang format
188
- # add_custom_target(format COMMAND clang-format --style=file -i $<TARGET_PROPERTY:falco,SOURCES> COMMENT "Formatting ..." VERBATIM)
241
+ # Clang format add_custom_target(format COMMAND clang-format --style=file -i
242
+ # $<TARGET_PROPERTY:falco,SOURCES> COMMENT "Formatting ..." VERBATIM)
189
243
190
244
# Static analysis
191
245
include (static -analysis)
@@ -199,13 +253,17 @@ add_subdirectory(scripts)
199
253
add_subdirectory (userspace/engine)
200
254
add_subdirectory (userspace/falco)
201
255
202
- if (NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN AND NOT MUSL_OPTIMIZED_BUILD)
203
- include (falcoctl)
256
+ if (NOT WIN32
257
+ AND NOT APPLE
258
+ AND NOT EMSCRIPTEN
259
+ AND NOT MUSL_OPTIMIZED_BUILD
260
+ )
261
+ include (falcoctl)
204
262
endif ()
205
263
206
264
# Packages configuration
207
265
include (CPackConfig)
208
266
209
267
if (BUILD_FALCO_UNIT_TESTS)
210
- add_subdirectory (unit_tests)
268
+ add_subdirectory (unit_tests)
211
269
endif ()
0 commit comments