forked from Samsung/cynara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
172 lines (140 loc) · 5.27 KB
/
CMakeLists.txt
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
# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
#
# 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.
#
# @file CMakeLists.txt
# @author Lukasz Wojciechowski <[email protected]>
# @author Radoslaw Bartosiak <[email protected]>
#
############################# Check minimum CMake version #####################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
PROJECT("cynara")
set(CYNARA_VERSION 0.8.0)
############################# cmake packages ##################################
INCLUDE(FindPkgConfig)
INCLUDE(CheckCXXCompilerFlag)
########################## search for packages ################################
PKG_CHECK_MODULES(SYSTEMD_DEP
QUIET
libsystemd-daemon
libsystemd-journal
)
IF (SYSTEMD_DEP_FOUND)
SET(BUILD_WITH_SYSTEMD ON)
ENDIF (SYSTEMD_DEP_FOUND)
######################## directory configuration ############################
SET(LIB_DIR
"${CMAKE_INSTALL_PREFIX}/lib"
CACHE PATH
"Object code libraries directory")
SET(BIN_DIR
"${CMAKE_INSTALL_PREFIX}/bin"
CACHE PATH
"User executables directory")
SET(SBIN_DIR
"${CMAKE_INSTALL_PREFIX}/sbin"
CACHE PATH
"System admin executables directory")
SET(SYS_CONFIG_DIR
"${CMAKE_INSTALL_PREFIX}/etc"
CACHE PATH
"Read-only single-machine data directory")
SET(INCLUDE_DIR
"${CMAKE_INSTALL_PREFIX}/include"
CACHE PATH
"Header files directory")
SET(LOCAL_STATE_DIR
"${CMAKE_INSTALL_PREFIX}/var"
CACHE PATH
"Modifiable single-machine data directory")
SET(DATA_ROOT_DIR
"${CMAKE_INSTALL_PREFIX}/share"
CACHE PATH
"Read-only architecture-independent data root directory")
SET(SYSTEMD_UNIT_DIR
"${CMAKE_INSTALL_PREFIX}/lib/systemd/system"
CACHE PATH
"Systemd system unit file directory")
SET(SOCKET_DIR
"${CMAKE_INSTALL_PREFIX}/tmp"
CACHE PATH
"Running system information directory")
ADD_DEFINITIONS("-DLIB_DIR=\"${LIB_DIR}\"")
ADD_DEFINITIONS("-DBIN_DIR=\"${BIN_DIR}\"")
ADD_DEFINITIONS("-DSBIN_DIR=\"${SBIN_DIR}\"")
ADD_DEFINITIONS("-DSYS_CONFIG_DIR=\"${SYS_CONFIG_DIR}\"")
ADD_DEFINITIONS("-DINCLUDE_DIR=\"${INCLUDE_DIR}\"")
ADD_DEFINITIONS("-DLOCAL_STATE_DIR=\"${LOCAL_STATE_DIR}\"")
ADD_DEFINITIONS("-DDATA_ROOT_DIR=\"${DATA_ROOT_DIR}\"")
ADD_DEFINITIONS("-DSYSTEMD_UNIT_DIR=\"${SYSTEMD_UNIT_DIR}\"")
ADD_DEFINITIONS("-DSOCKET_DIR=\"${SOCKET_DIR}\"")
############################# compiler flags ##################################
SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -g -pg")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g")
SET(CMAKE_CXX_FLAGS_CCOV "-O2 -g --coverage")
# Check for C++11 support and enable proper compilation flags
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSE()
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
IF(COMPILER_SUPPORTS_CXX0X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE()
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
ENDIF()
ENDIF()
# Set compiler warning flags
ADD_DEFINITIONS("-Werror") # Make all warnings into errors.
ADD_DEFINITIONS("-Wall") # Generate all warnings
ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
# Don't export symbols by default
ADD_DEFINITIONS("-fvisibility=hidden")
# Export version of cynara
ADD_DEFINITIONS("-DCYNARA_VERSION=\"${CYNARA_VERSION}\"")
IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
IF (BUILD_WITH_SYSTEMD)
ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD")
ENDIF (BUILD_WITH_SYSTEMD)
IF (CYNARA_NO_LOGS)
ADD_DEFINITIONS("-DCYNARA_NO_LOGS")
ENDIF (CYNARA_NO_LOGS)
SET(TARGET_CYNARA "cynara")
SET(TARGET_LIB_CYNARA "cynara-client")
SET(TARGET_LIB_CYNARA_ASYNC "cynara-client-async")
SET(TARGET_LIB_CYNARA_COMMON "cynara-client-commons")
SET(TARGET_LIB_CYNARA_ADMIN "cynara-admin")
SET(TARGET_LIB_CYNARA_AGENT "cynara-agent")
SET(TARGET_CYNARA_COMMON "cynara-commons")
SET(TARGET_CYNARA_TESTS "cynara-tests")
SET(TARGET_LIB_CREDS_COMMONS "cynara-creds-commons")
SET(TARGET_LIB_CREDS_DBUS "cynara-creds-dbus")
SET(TARGET_LIB_CREDS_GDBUS "cynara-creds-gdbus")
SET(TARGET_LIB_CREDS_SOCKET "cynara-creds-socket")
SET(TARGET_LIB_SESSION "cynara-session")
SET(TARGET_LIB_CYNARA_STORAGE "cynara-storage")
SET(TARGET_CYAD "cyad")
SET(TARGET_CHSGEN "cynara-db-chsgen")
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(pkgconfig)
ADD_SUBDIRECTORY(conf)
IF (BUILD_WITH_SYSTEMD)
ADD_SUBDIRECTORY(systemd)
ENDIF (BUILD_WITH_SYSTEMD)
ADD_SUBDIRECTORY(migration)
IF (BUILD_TESTS)
ADD_SUBDIRECTORY(test)
ENDIF (BUILD_TESTS)