build: use SYSDIG_SOURCE_DIR into falco CMakeLists.txt files

Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
Leonardo Di Donato 2019-12-18 15:52:18 +00:00 committed by Leo Di Donato
parent ce112d7238
commit d6e246a26a
2 changed files with 72 additions and 78 deletions

View File

@ -14,10 +14,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if(NOT SYSDIG_DIR)
set(SYSDIG_DIR "${PROJECT_SOURCE_DIR}/../sysdig")
endif()
set(FALCO_ENGINE_SOURCE_FILES set(FALCO_ENGINE_SOURCE_FILES
rules.cpp rules.cpp
falco_common.cpp falco_common.cpp
@ -29,15 +25,16 @@ set(FALCO_ENGINE_SOURCE_FILES
formats.cpp) formats.cpp)
add_library(falco_engine STATIC ${FALCO_ENGINE_SOURCE_FILES}) add_library(falco_engine STATIC ${FALCO_ENGINE_SOURCE_FILES})
add_dependencies(falco_engine njson lyaml lpeg)
target_include_directories(falco_engine PUBLIC target_include_directories(falco_engine PUBLIC
"${LUAJIT_INCLUDE}" "${LUAJIT_INCLUDE}"
"${NJSON_INCLUDE}" "${NJSON_INCLUDE}"
"${CURL_INCLUDE_DIR}" "${CURL_INCLUDE_DIR}"
"${TBB_INCLUDE_DIR}" "${TBB_INCLUDE_DIR}"
"${SYSDIG_DIR}/userspace/libsinsp/third-party/jsoncpp" "${SYSDIG_SOURCE_DIR}/userspace/libsinsp/third-party/jsoncpp"
"${SYSDIG_DIR}/userspace/libscap" "${SYSDIG_SOURCE_DIR}/userspace/libscap"
"${SYSDIG_DIR}/userspace/libsinsp" "${SYSDIG_SOURCE_DIR}/userspace/libsinsp"
"${PROJECT_BINARY_DIR}/userspace/engine" "${PROJECT_BINARY_DIR}/userspace/engine"
) )

View File

@ -1,45 +1,40 @@
# #
# Copyright (C) 2019 The Falco Authors. # Copyright (C) 2019 The Falco Authors.
# #
# # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# Licensed under the Apache License, Version 2.0 (the "License"); # the License. You may obtain a copy of the License at
# 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 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# distributed under the License is distributed on an "AS IS" BASIS, # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # specific language governing permissions and limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
# #
if(NOT SYSDIG_DIR)
set(SYSDIG_DIR "${PROJECT_SOURCE_DIR}/../sysdig")
endif()
configure_file("${SYSDIG_DIR}/userspace/sysdig/config_sysdig.h.in" config_sysdig.h) configure_file("${SYSDIG_SOURCE_DIR}/userspace/sysdig/config_sysdig.h.in" config_sysdig.h)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output.grpc.pb.cc add_custom_command(
${CMAKE_CURRENT_BINARY_DIR}/output.grpc.pb.h OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/output.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/output.grpc.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/output.grpc.pb.h
${CMAKE_CURRENT_BINARY_DIR}/output.pb.h ${CMAKE_CURRENT_BINARY_DIR}/output.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/output.pb.h
${CMAKE_CURRENT_BINARY_DIR}/schema.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/schema.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/schema.pb.h
${CMAKE_CURRENT_BINARY_DIR}/schema.pb.h
COMMENT "Generate gRPC code" COMMENT "Generate gRPC code"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/output.proto DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/output.proto
COMMAND ${PROTOC} -I ${CMAKE_CURRENT_SOURCE_DIR} --cpp_out=. ${CMAKE_CURRENT_SOURCE_DIR}/output.proto ${CMAKE_CURRENT_SOURCE_DIR}/schema.proto COMMAND ${PROTOC} -I ${CMAKE_CURRENT_SOURCE_DIR} --cpp_out=. ${CMAKE_CURRENT_SOURCE_DIR}/output.proto
COMMAND ${PROTOC} -I ${CMAKE_CURRENT_SOURCE_DIR} --grpc_out=. --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} ${CMAKE_CURRENT_SOURCE_DIR}/output.proto ${CMAKE_CURRENT_SOURCE_DIR}/schema.proto
COMMAND ${PROTOC} -I ${CMAKE_CURRENT_SOURCE_DIR} --grpc_out=. --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
${CMAKE_CURRENT_SOURCE_DIR}/output.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(falco add_executable(
falco
configuration.cpp configuration.cpp
logger.cpp logger.cpp
falco_outputs.cpp falco_outputs.cpp
event_drops.cpp event_drops.cpp
statsfilewriter.cpp statsfilewriter.cpp
falco.cpp falco.cpp
"${SYSDIG_DIR}/userspace/sysdig/fields_info.cpp" "${SYSDIG_SOURCE_DIR}/userspace/sysdig/fields_info.cpp"
webserver.cpp webserver.cpp
grpc_context.cpp grpc_context.cpp
grpc_server_impl.cpp grpc_server_impl.cpp
@ -49,8 +44,10 @@ add_executable(falco
${CMAKE_CURRENT_BINARY_DIR}/output.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/output.pb.cc
${CMAKE_CURRENT_BINARY_DIR}/schema.pb.cc) ${CMAKE_CURRENT_BINARY_DIR}/schema.pb.cc)
target_include_directories(falco PUBLIC target_include_directories(
"${SYSDIG_DIR}/userspace/sysdig" falco
PUBLIC
"${SYSDIG_SOURCE_DIR}/userspace/sysdig"
"${PROJECT_SOURCE_DIR}/userspace/engine" "${PROJECT_SOURCE_DIR}/userspace/engine"
"${PROJECT_BINARY_DIR}/userspace/falco" "${PROJECT_BINARY_DIR}/userspace/falco"
"${PROJECT_BINARY_DIR}/driver/src" "${PROJECT_BINARY_DIR}/driver/src"
@ -61,10 +58,9 @@ target_include_directories(falco PUBLIC
"${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${DRAIOS_DEPENDENCIES_DIR}/yaml-${DRAIOS_YAML_VERSION}/target/include") "${DRAIOS_DEPENDENCIES_DIR}/yaml-${DRAIOS_YAML_VERSION}/target/include")
target_link_libraries(falco falco_engine sinsp) target_link_libraries(falco falco_engine sinsp)
target_link_libraries(falco target_link_libraries(
falco
"${GRPCPP_LIB}" "${GRPCPP_LIB}"
"${GRPC_LIB}" "${GRPC_LIB}"
"${PROTOBUF_LIB}" "${PROTOBUF_LIB}"
@ -74,18 +70,19 @@ target_link_libraries(falco
configure_file(config_falco.h.in config_falco.h) configure_file(config_falco.h.in config_falco.h)
add_custom_command(TARGET falco add_custom_command(
TARGET falco
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/verify_engine_fields.sh ${CMAKE_SOURCE_DIR} ${OPENSSL_BINARY} COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/verify_engine_fields.sh ${CMAKE_SOURCE_DIR} ${OPENSSL_BINARY}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Comparing engine fields checksum in falco_engine.h to actual fields" COMMENT "Comparing engine fields checksum in falco_engine.h to actual fields")
)
# add_custom_target(verify_engine_fields # add_custom_target(verify_engine_fields DEPENDS verify_engine_fields.sh falco_engine.h)
# DEPENDS verify_engine_fields.sh falco_engine.h)
# add_dependencies(verify_engine_fields falco) # add_dependencies(verify_engine_fields falco)
install(TARGETS falco DESTINATION ${FALCO_BIN_DIR}) install(TARGETS falco DESTINATION ${FALCO_BIN_DIR})
install(DIRECTORY lua install(
DIRECTORY lua
DESTINATION ${FALCO_SHARE_DIR} DESTINATION ${FALCO_SHARE_DIR}
FILES_MATCHING PATTERN *.lua) FILES_MATCHING
PATTERN *.lua)