File: CMakeLists.txt

package info (click to toggle)
falcosecurity-libs 0.1.1dev%2Bgit20220316.e5c53d64-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,732 kB
  • sloc: cpp: 55,770; ansic: 37,330; makefile: 74; sh: 13
file content (295 lines) | stat: -rw-r--r-- 6,724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#
# Copyright (C) 2021 The Falco Authors.
#
# 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
#
# 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.
#
include_directories(./)
include_directories(../../common)
include_directories(${LIBSCAP_INCLUDE_DIR})
include_directories(../async)
include_directories(./include)

option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" ON)

include(ExternalProject)

if(NOT WIN32 AND NOT APPLE)
	include(b64)
endif()

include(jsoncpp)
if(WITH_CHISEL)
	include_directories(../chisel)
	include(luajit)
endif()

if(NOT MINIMAL_BUILD)
	include(cares)
endif()

if(NOT WIN32 AND NOT APPLE)
	if(NOT MINIMAL_BUILD)
		include(grpc)
		include(protobuf)
		include(openssl)
		include(curl)
	endif() # NOT MINIMAL_BUILD
	include(jq)
	include_directories("${CMAKE_CURRENT_BINARY_DIR}")
endif()

if(NOT WIN32)
	include(tbb)
endif()

set(SINSP_SOURCES
	container.cpp
	container_engine/container_engine_base.cpp
	container_engine/static_container.cpp
	container_info.cpp
	cyclewriter.cpp
	event.cpp
	eventformatter.cpp
	dns_manager.cpp
	dumper.cpp
	fdinfo.cpp
	filter.cpp
	fields_info.cpp
	filterchecks.cpp
	filter_check_list.cpp
	gen_filter.cpp
	http_parser.c
	http_reason.cpp
	ifinfo.cpp
	json_query.cpp
	json_error_log.cpp
	memmem.cpp
	tracers.cpp
	internal_metrics.cpp
	"${JSONCPP_LIB_SRC}"
	logger.cpp
	parsers.cpp
	plugin.cpp
	prefix_search.cpp
	protodecoder.cpp
	threadinfo.cpp
	tuples.cpp
	sinsp.cpp
	stats.cpp
	table.cpp
	token_bucket.cpp
	stopwatch.cpp
	uri_parser.c
	uri.cpp
	user_event_logger.cpp
	utils.cpp
	user_event.cpp
	value_parser.cpp
	viewinfo.cpp
)

if(WITH_CHISEL)
	list(APPEND SINSP_SOURCES
		../chisel/chisel_api.cpp
		../chisel/chisel_fields_info.cpp
		../chisel/chisel_utils.cpp
		../chisel/chisel.cpp
		../chisel/lua_parser_api.cpp
		../chisel/lua_parser.cpp)
endif()

if(NOT MINIMAL_BUILD)
	list(APPEND SINSP_SOURCES
		addrinfo.cpp
		sinsp_auth.cpp
		k8s.cpp
		k8s_api_error.cpp
		k8s_api_handler.cpp
		k8s_component.cpp
		k8s_daemonset_handler.cpp
		k8s_deployment_handler.cpp
		k8s_dispatcher.cpp
		k8s_event_data.cpp
		k8s_event_handler.cpp
		k8s_handler.cpp
		k8s_namespace_handler.cpp
		k8s_net.cpp
		k8s_node_handler.cpp
		k8s_pod_handler.cpp
		k8s_replicationcontroller_handler.cpp
		k8s_replicaset_handler.cpp
		k8s_service_handler.cpp
		k8s_state.cpp
		marathon_component.cpp
		marathon_http.cpp
		mesos_auth.cpp
		mesos.cpp
		mesos_collector.cpp
		mesos_component.cpp
		mesos_http.cpp
		mesos_state.cpp
		sinsp_curl.cpp
		container_engine/docker/async_source.cpp
		container_engine/docker/base.cpp)
	if(WIN32)
	list(APPEND SINSP_SOURCES
		container_engine/docker/connection_win.cpp
		container_engine/docker/docker_win.cpp)
	else()
	list(APPEND SINSP_SOURCES
		container_engine/docker/docker_linux.cpp
		container_engine/docker/connection_linux.cpp
		container_engine/docker/podman.cpp
		container_engine/libvirt_lxc.cpp
		container_engine/lxc.cpp
		container_engine/mesos.cpp
		container_engine/rkt.cpp
		container_engine/bpm.cpp
		procfs_utils.cpp
		runc.cpp)
	endif()

	if(NOT WIN32 AND NOT APPLE)
		list(APPEND SINSP_SOURCES
			cgroup_limits.cpp
			cri.cpp
			container_engine/cri.cpp
			${CMAKE_CURRENT_BINARY_DIR}/cri.grpc.pb.cc
			${CMAKE_CURRENT_BINARY_DIR}/cri.pb.cc
			grpc_channel_registry.cpp
		)
	endif()
endif()

add_library(sinsp SHARED ${SINSP_SOURCES})
set_target_properties(sinsp PROPERTIES
    VERSION ${FALCOSECURITY_LIBS_VERSION}
    SOVERSION ${FALCOSECURITY_LIBS_VERSION}
)
install (TARGETS sinsp LIBRARY)


set(SINSP_LIBRARIES
	scap
	-lcurl
	"${JSONCPP_LIB}"
	"${CARES_LIB}")

if(WITH_CHISEL AND USE_BUNDLED_LUAJIT)
	add_dependencies(sinsp luajit)
endif()

if(NOT WIN32)
	list(APPEND SINSP_LIBRARIES "${TBB_LIB}")

	if(USE_BUNDLED_OPENSSL AND NOT MINIMAL_BUILD)
		add_dependencies(sinsp openssl)
	endif() # USE_BUNDLED_OPENSSL
	if(USE_BUNDLED_CURL AND NOT MINIMAL_BUILD)
		add_dependencies(sinsp curl)
	endif() # USE_BUNDLED_CURL
	if(USE_BUNDLED_TBB)
		add_dependencies(sinsp tbb)
	endif() # USE_BUNDLED_TBB


	if(NOT APPLE)
		if(NOT MINIMAL_BUILD)
			include(protobuf)
			include(cares)
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cri.proto ${CMAKE_CURRENT_BINARY_DIR}/cri.proto COPYONLY)
			add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cri.grpc.pb.cc
						${CMAKE_CURRENT_BINARY_DIR}/cri.grpc.pb.h
						${CMAKE_CURRENT_BINARY_DIR}/cri.pb.cc
						${CMAKE_CURRENT_BINARY_DIR}/cri.pb.h
					COMMENT "Generate CRI grpc code"
					DEPENDS
					COMMAND ${PROTOC} -I ${CMAKE_CURRENT_BINARY_DIR} --cpp_out=. ${CMAKE_CURRENT_BINARY_DIR}/cri.proto
					COMMAND ${PROTOC} -I ${CMAKE_CURRENT_BINARY_DIR} --grpc_out=. --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} ${CMAKE_CURRENT_BINARY_DIR}/cri.proto
					WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

			if(USE_BUNDLED_GRPC)
				add_dependencies(sinsp grpc)
				list(APPEND SINSP_LIBRARIES "${GRPC_LIBRARIES}")
			endif() # USE_BUNDLED_GRPC

			list(APPEND SINSP_LIBRARIES
				"${GRPCPP_LIB}"
				"${GRPC_LIB}"
				"${GPR_LIB}"
				"${PROTOBUF_LIB}"
				"${CARES_LIB}"
				"${JQ_LIB}"
				"${B64_LIB}")

			if(NOT MUSL_OPTIMIZED_BUILD)
				list(APPEND SINSP_LIBRARIES
				rt
				anl)
			endif()

		else()
			list(APPEND SINSP_LIBRARIES
				"${JQ_LIB}"
				"${B64_LIB}"
				rt)
		endif() # NOT MINIMAL_BUILD
		# when JQ is compiled statically, it will
		# also compile a static object for oniguruma we need to link
		if(ONIGURUMA_LIB)
			list(APPEND SINSP_LIBRARIES
			"${ONIGURUMA_LIB}")
			add_dependencies(sinsp jq)
		endif()

		if(USE_BUNDLED_B64)
			add_dependencies(sinsp b64)
		endif()
	endif() # NOT APPLE

	list(APPEND SINSP_LIBRARIES
        	"${OPENSSL_LIBRARIES}")

	if(WITH_CHISEL)
		list(APPEND SINSP_LIBRARIES
			"${LUAJIT_LIB}")
	endif()

	list(APPEND SINSP_LIBRARIES
		dl
		pthread)
else()
	if(WITH_CHISEL)
		list(APPEND SINSP_LIBRARIES
			"${LUAJIT_LIB}")
	endif()
endif() # NOT WIN32


target_link_libraries(sinsp ${SINSP_LIBRARIES})

option(CREATE_TEST_TARGETS "Enable make-targets for unit testing" ON)

if(CREATE_TEST_TARGETS AND NOT WIN32)
		# Add unit test directories
		add_subdirectory(test)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    option(BUILD_LIBSINSP_EXAMPLES "Build libsinsp examples" ON)

    if (BUILD_LIBSINSP_EXAMPLES)
        add_subdirectory(examples)
    endif()
endif()