forked from greenbone/gsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
236 lines (186 loc) · 7.19 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
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
# Copyright (C) 2009-2018 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cmake_minimum_required (VERSION 3.0)
message ("-- Configuring Greenbone Security Assistant...")
# VERSION: Set patch version for stable releases, e.g. "9.0.0",
# unset patch version for prereleases, e.g. "9.0"
project (greenbone-security-assistant
VERSION 20.04
LANGUAGES C)
if (POLICY CMP0005)
cmake_policy (SET CMP0005 NEW)
endif (POLICY CMP0005)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
endif (NOT CMAKE_BUILD_TYPE)
## Retrieve git revision (at configure time)
include (GetGit)
if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
if (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
if (GIT_FOUND)
Git_GET_REVISION(${CMAKE_SOURCE_DIR} ProjectRevision)
set (GIT_REVISION "~git-${ProjectRevision}")
else (GIT_FOUND)
set (GIT_REVISION "~git")
endif (GIT_FOUND)
endif (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
endif (NOT CMAKE_BUILD_TYPE MATCHES "Release")
# set if this is in prerelease status, starting at 0 before first beta release,
# unset if this is a stable release series.
set (PROJECT_BETA_RELEASE 0)
if (GIT_REVISION)
set (PROJECT_VERSION_GIT "${GIT_REVISION}")
else (GIT_REVISION)
set (PROJECT_VERSION_GIT "")
endif (GIT_REVISION)
string(LENGTH ${PROJECT_VERSION_MINOR} PROJECT_VERSION_MINOR_LENGTH)
if (PROJECT_VERSION_MINOR_LENGTH LESS 2)
set (PROJECT_VERSION_MINOR_STRING "0${PROJECT_VERSION_MINOR}")
else ()
set (PROJECT_VERSION_MINOR_STRING "${PROJECT_VERSION_MINOR}")
endif ()
# If PROJECT_BETA_RELEASE is set to "0", the version string will be set to:
# "major.minor+alpha"
# If PROJECT_BETA_RELEASE is set otherwise, the version string will be set to:
# "major.minor+beta${PROJECT_BETA_RELEASE}"
# If PROJECT_BETA_RELEASE is NOT set, the version string will be set to:
# "major.minor.patch"
if (DEFINED PROJECT_BETA_RELEASE AND NOT PROJECT_BETA_RELEASE STREQUAL "")
if (PROJECT_BETA_RELEASE STREQUAL "0")
set (PROJECT_VERSION_SUFFIX "+alpha")
else (PROJECT_BETA_RELEASE STREQUAL "0")
set (PROJECT_VERSION_SUFFIX "+beta${PROJECT_BETA_RELEASE}")
endif (PROJECT_BETA_RELEASE STREQUAL "0")
elseif (DEFINED PROJECT_VERSION_PATCH AND NOT PROJECT_VERSION_PATCH STREQUAL "")
set (PROJECT_VERSION_SUFFIX ".${PROJECT_VERSION_PATCH}")
endif (DEFINED PROJECT_BETA_RELEASE AND NOT PROJECT_BETA_RELEASE STREQUAL "")
set (PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR_STRING}${PROJECT_VERSION_SUFFIX}${PROJECT_VERSION_GIT}")
message (STATUS "Building version ${PROJECT_VERSION_STRING}")
set (GSAD_VERSION "${PROJECT_VERSION_STRING}")
message (STATUS "Building GSA version ${PROJECT_VERSION_STRING}")
configure_file (VERSION.in VERSION)
## make format
message (STATUS "Looking for clang-format...")
find_program (CLANG_FORMAT clang-format)
if (CLANG_FORMAT)
message (STATUS "Looking for clang-format... ${CLANG_FORMAT}")
add_custom_target(format COMMAND ${CLANG_FORMAT} "-i" "./gsad/src/*.c"
"./gsad/src/*.h" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
else (CLANG_FORMAT)
message (STATUS "clang-format not found...")
endif (CLANG_FORMAT)
## CPack configuration
set (CPACK_CMAKE_GENERATOR "Unix Makefiles")
set (CPACK_GENERATOR "TGZ")
set (CPACK_INSTALL_CMAKE_PROJECTS ".;greenbone-security-assistant;ALL;/")
set (CPACK_MODULE_PATH "")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/README.md")
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_TOPLEVEL_TAG "")
set (CPACK_SYSTEM_NAME "")
set (CPACK_TOPLEVEL_TAG "")
set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION_STRING}${PROJECT_VERSION_GIT}")
set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_PACKAGE_VENDOR "Greenbone Networks")
set (CPACK_SOURCE_IGNORE_FILES
"${CMAKE_BINARY_DIR}"
"/.git/"
"swp$"
)
include (CPack)
## Variables
if (NOT SYSCONFDIR)
set (SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
endif (NOT SYSCONFDIR)
if (NOT EXEC_PREFIX)
set (EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif (NOT EXEC_PREFIX)
if (NOT BINDIR)
set (BINDIR "${EXEC_PREFIX}/bin")
endif (NOT BINDIR)
if (NOT SBINDIR)
set (SBINDIR "${EXEC_PREFIX}/sbin")
endif (NOT SBINDIR)
if (NOT LIBDIR)
set (LIBDIR "${EXEC_PREFIX}/lib")
endif (NOT LIBDIR)
if (NOT LOCALSTATEDIR)
set (LOCALSTATEDIR "${CMAKE_INSTALL_PREFIX}/var")
endif (NOT LOCALSTATEDIR)
if (NOT INCLUDEDIR)
set (INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
endif (NOT INCLUDEDIR)
if (NOT DATADIR)
set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
endif (NOT DATADIR)
if (NOT GSAD_PID_DIR)
set (GSAD_PID_DIR "${LOCALSTATEDIR}/run")
endif (NOT GSAD_PID_DIR)
if (NOT GVM_STATE_DIR)
set (GVM_STATE_DIR "${LOCALSTATEDIR}/lib/gvm")
else (NOT GVM_STATE_DIR)
set (GVM_STATE_DIR "${GVM_STATE_DIR}")
endif (NOT GVM_STATE_DIR)
if (NOT GVM_LOG_DIR)
set (GVM_LOG_DIR "${LOCALSTATEDIR}/log/gvm")
else (NOT GVM_LOG_DIR)
set (GVM_LOG_DIR "${GVM_LOG_DIR}")
endif (NOT GVM_LOG_DIR)
set (GSAD_DATA_DIR "${DATADIR}/gvm/gsad")
set (GSAD_LOCALE_SUBDIR "locale")
set (GSAD_LOCALE_DIR "${GSAD_DATA_DIR}/${GSAD_LOCALE_SUBDIR}")
set (GSAD_CHROOT_LOCALE_DIR "/${GSAD_LOCALE_SUBDIR}")
# TODO: Eventually use own certificates
if (NOT GVM_SERVER_CERTIFICATE)
set (GVM_SERVER_CERTIFICATE "${GVM_STATE_DIR}/CA/servercert.pem")
else (NOT GVM_SERVER_CERTIFICATE)
set (GVM_SERVER_CERTIFICATE "${GVM_SERVER_CERTIFICATE}")
endif (NOT GVM_SERVER_CERTIFICATE)
if (NOT GVM_SERVER_KEY)
set (GVM_SERVER_KEY "${GVM_STATE_DIR}/private/CA/serverkey.pem")
else (NOT GVM_SERVER_KEY)
set (GVM_SERVER_KEY "${GVM_SERVER_KEY}")
endif (NOT GVM_SERVER_KEY)
if (NOT GVM_CA_CERTIFICATE)
set (GVM_CA_CERTIFICATE "${GVM_STATE_DIR}/CA/cacert.pem")
else (NOT GVM_CA_CERTIFICATE)
set (GVM_CA_CERTIFICATE "${GVM_CA_CERTIFICATE}")
endif (NOT GVM_CA_CERTIFICATE)
set (GSAD_CONFIG_DIR "${SYSCONFDIR}/gvm/")
if (NOT GVM_RUN_DIR)
set (GVM_RUN_DIR "${LOCALSTATEDIR}/run")
endif (NOT GVM_RUN_DIR)
message ("-- Install prefix: ${CMAKE_INSTALL_PREFIX}")
if (SKIP_SRC)
# ng has no documentation to build so skip if src should not be build
set (SKIP_GSA ON)
set (SKIP_GSAD ON)
endif (SKIP_SRC)
if (NOT SKIP_GSA)
add_subdirectory (gsa)
endif (NOT SKIP_GSA)
if (NOT SKIP_GSAD)
add_subdirectory (gsad)
endif (NOT SKIP_GSAD)
## Documentation
add_subdirectory (gsad/doc)
# vim: set ts=2 sw=2 tw=80: