filedb: Ensure rules are written
[src/cynagora.git] / CMakeLists.txt
1 ###########################################################################
2 # Copyright (C) 2018 "IoT.bzh"
3 #
4 # author: José Bollo <jose.bollo@iot.bzh>
5 #
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
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
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
19 cmake_minimum_required(VERSION 3.0)
20
21 project(cynagora
22         DESCRIPTION "Secured permission database for applications"
23         HOMEPAGE_URL "https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/cynagora.git;a=summary"
24         VERSION 2.0
25         LANGUAGES C
26 )
27
28 include(FindPkgConfig)
29 include(CheckIncludeFiles)
30 include(CheckLibraryExists)
31 include(GNUInstallDirs)
32 include(CTest)
33
34 if(NOT CMAKE_INSTALL_FULL_RUNSTATEDIR)
35         set(CMAKE_INSTALL_FULL_RUNSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run")
36 endif()
37
38 ###########################################################################
39 # possible settings
40
41 set(CYNAGORA_VERSION ${PROJECT_VERSION})
42 set(CYNAGORA_SOVERSION ${PROJECT_VERSION_MAJOR})
43
44 option(WITH_SYSTEMD       "should include systemd compatibility" ON)
45 option(WITH_CYNARA_COMPAT "produce artifacts for compatibility with cynara" OFF)
46
47 set(USER  cynagora CACHE STRING "user of the daemon")
48 set(GROUP cynagora CACHE STRING "group of the daemon")
49
50 set(DEFAULT_DB_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/cynagora"
51         CACHE PATH "directory path of the database")
52 set(DEFAULT_SOCKET_DIR "${CMAKE_INSTALL_FULL_RUNSTATEDIR}/cynagora"
53         CACHE PATH "directory path of the sockets")
54 set(DEFAULT_INIT_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/security/cynagora.initial")
55
56 ###########################################################################
57
58 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
59
60 add_compile_options(-Wall -Wextra -Wconversion)
61 add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
62 add_compile_options(-Werror=maybe-uninitialized)
63 add_compile_options(-Werror=implicit-function-declaration)
64 add_compile_options(-ffunction-sections -fdata-sections)
65 #add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.)
66
67 ###########################################################################
68
69 if(WITH_SYSTEMD)
70         PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
71         add_subdirectory(systemd)
72 endif()
73
74 add_subdirectory(src)
75 add_subdirectory(pkgconfig)
76
77 if(WITH_CYNARA_COMPAT)
78         add_subdirectory(compat)
79 endif()
80
81 get_filename_component(
82         DEFAULT_INIT_FILE_DIRECTORY
83         ${DEFAULT_INIT_FILE}
84         DIRECTORY
85 )
86 install(FILES
87         ${CMAKE_CURRENT_SOURCE_DIR}/cynagora.initial
88         DESTINATION
89         ${DEFAULT_INIT_FILE_DIRECTORY}
90 )