build: include GNUInstallDirs module

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:09:18 +00:00 committed by Leo Di Donato
parent 494edafdb1
commit 572ac46d85
2 changed files with 45 additions and 42 deletions

View File

@ -15,24 +15,24 @@ cmake_minimum_required(VERSION 3.5.1)
project(falco) project(falco)
option(USE_BUNDLED_DEPS "Bundle hard to find dependencies into the Falco binary" OFF) option(USE_BUNDLED_DEPS "Bundle hard to find dependencies into the Falco binary" OFF)
option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags" OFF)
option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" OFF)
# Make flag for parallel processing
include(ProcessorCount) include(ProcessorCount)
processorcount(PROCESSOR_COUNT) processorcount(PROCESSOR_COUNT)
if(NOT PROCESSOR_COUNT EQUAL 0) if(NOT PROCESSOR_COUNT EQUAL 0)
set(PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT}) set(PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT})
endif() endif()
# if(NOT SYSDIG_DIR) get_filename_component(SYSDIG_DIR "${PROJECT_SOURCE_DIR}/../sysdig" REALPATH) endif()
# Custom CMake modules # Custom CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${SYSDIG_DIR}/cmake/modules")
option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags") # GNU standard installation directories' definitions
option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" OFF) include(GNUInstallDirs)
if(NOT DEFINED FALCO_ETC_DIR) if(NOT DEFINED FALCO_ETC_DIR)
set(FALCO_ETC_DIR "/etc/falco") set(FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falco")
endif() endif()
if(NOT DRAIOS_DEBUG_FLAGS) if(NOT DRAIOS_DEBUG_FLAGS)
@ -65,7 +65,6 @@ set(CMAKE_CXX_FLAGS_DEBUG "${DRAIOS_DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG")
add_definitions(-DPLATFORM_NAME="${CMAKE_SYSTEM_NAME}")
add_definitions(-DK8S_DISABLE_THREAD) add_definitions(-DK8S_DISABLE_THREAD)
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DHAS_CAPTURE) add_definitions(-DHAS_CAPTURE)

View File

@ -1,21 +1,21 @@
# #
# 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
# the License. You may obtain a copy of the License at
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # http://www.apache.org/licenses/LICENSE-2.0
# 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
# Unless required by applicable law or agreed to in writing, software # specific language governing permissions and limitations under the License.
# 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.
# #
# GNU standard installation directories' definitions
include(GNUInstallDirs)
if(NOT DEFINED FALCO_ETC_DIR) if(NOT DEFINED FALCO_ETC_DIR)
set(FALCO_ETC_DIR "/etc/falco") set(FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falco")
endif() endif()
if(NOT DEFINED FALCO_RULES_DEST_FILENAME) if(NOT DEFINED FALCO_RULES_DEST_FILENAME)
@ -26,35 +26,39 @@ if(NOT DEFINED FALCO_RULES_DEST_FILENAME)
endif() endif()
if(DEFINED FALCO_COMPONENT) if(DEFINED FALCO_COMPONENT)
install(FILES falco_rules.yaml install(
COMPONENT "${FALCO_COMPONENT}" FILES falco_rules.yaml
DESTINATION "${FALCO_ETC_DIR}" COMPONENT "${FALCO_COMPONENT}"
RENAME "${FALCO_RULES_DEST_FILENAME}") DESTINATION "${FALCO_ETC_DIR}"
RENAME "${FALCO_RULES_DEST_FILENAME}")
install(FILES falco_rules.local.yaml install(
COMPONENT "${FALCO_COMPONENT}" FILES falco_rules.local.yaml
DESTINATION "${FALCO_ETC_DIR}" COMPONENT "${FALCO_COMPONENT}"
RENAME "${FALCO_LOCAL_RULES_DEST_FILENAME}") DESTINATION "${FALCO_ETC_DIR}"
RENAME "${FALCO_LOCAL_RULES_DEST_FILENAME}")
# Intentionally *not* installing application_rules.yaml. Not needed # Intentionally *not* installing application_rules.yaml. Not needed when falco is embedded in other projects.
# when falco is embedded in other projects.
else() else()
install(FILES falco_rules.yaml install(
DESTINATION "${FALCO_ETC_DIR}" FILES falco_rules.yaml
RENAME "${FALCO_RULES_DEST_FILENAME}") DESTINATION "${FALCO_ETC_DIR}"
RENAME "${FALCO_RULES_DEST_FILENAME}")
install(FILES falco_rules.local.yaml install(
DESTINATION "${FALCO_ETC_DIR}" FILES falco_rules.local.yaml
RENAME "${FALCO_LOCAL_RULES_DEST_FILENAME}") DESTINATION "${FALCO_ETC_DIR}"
RENAME "${FALCO_LOCAL_RULES_DEST_FILENAME}")
install(FILES k8s_audit_rules.yaml install(
DESTINATION "${FALCO_ETC_DIR}" FILES k8s_audit_rules.yaml
RENAME "${FALCO_K8S_AUDIT_RULES_DEST_FILENAME}") DESTINATION "${FALCO_ETC_DIR}"
RENAME "${FALCO_K8S_AUDIT_RULES_DEST_FILENAME}")
install(FILES application_rules.yaml install(
DESTINATION "/etc/falco/rules.available" FILES application_rules.yaml
RENAME "${FALCO_APP_RULES_DEST_FILENAME}") DESTINATION "/etc/falco/rules.available"
RENAME "${FALCO_APP_RULES_DEST_FILENAME}")
install(DIRECTORY DESTINATION "/etc/falco/rules.d") install(DIRECTORY DESTINATION "/etc/falco/rules.d")
endif() endif()