1#   BAREOS® - Backup Archiving REcovery Open Sourced
2#
3#   Copyright (C) 2017-2020 Bareos GmbH & Co. KG
4#
5#   This program is Free Software; you can redistribute it and/or
6#   modify it under the terms of version three of the GNU Affero General Public
7#   License as published by the Free Software Foundation and included
8#   in the file LICENSE.
9#
10#   This program is distributed in the hope that it will be useful, but
11#   WITHOUT ANY WARRANTY; without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13#   Affero General Public License for more details.
14#
15#   You should have received a copy of the GNU Affero General Public License
16#   along with this program; if not, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18#   02110-1301, USA.
19
20# check if variables are set via cmdline else set them to default values
21
22# configure variables
23#
24# strings - directories
25
26# prefix
27if(NOT DEFINED prefix)
28  set(prefix ${CMAKE_DEFAULT_PREFIX})
29endif()
30
31if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
32  set(HAVE_EXTENDED_ACL 1)
33endif()
34
35if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
36
37  # libdir
38  if(NOT DEFINED libdir)
39    set(libdir ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME})
40  endif()
41
42  # includedir
43  if(NOT DEFINED includedir)
44    set(includedir ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME})
45  endif()
46
47  # bindir
48  if(NOT DEFINED bindir)
49    set(bindir ${CMAKE_INSTALL_BINDIR})
50    message(STATUS "set bindir to default ${bindir}")
51  endif()
52
53  # sbindir
54  if(NOT DEFINED sbindir)
55    set(sbindir ${CMAKE_INSTALL_SBINDIR})
56    message(STATUS "set sbindir to default ${sbindir}")
57  endif()
58
59  # sysconfdir
60  if(NOT DEFINED sysconfdir)
61    set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
62  endif()
63  set(SYSCONFDIR "\"${sysconfdir}\"")
64
65  # confdir
66  if(NOT DEFINED confdir)
67    set(confdir "${sysconfdir}/${CMAKE_PROJECT_NAME}")
68  endif()
69
70  # configtemplatedir
71  if(NOT DEFINED configtemplatedir)
72    set(configtemplatedir "lib/${CMAKE_PROJECT_NAME}/defaultconfigs")
73  endif()
74
75  # mandir
76  if(NOT DEFINED mandir)
77    set(mandir ${CMAKE_INSTALL_MANDIR})
78  endif()
79
80  # docdir
81  if(NOT DEFINED docdir)
82    set(docdir default_for_docdir)
83  endif()
84
85  # htmldir
86  if(NOT DEFINED htmldir)
87    set(htmldir default_for_htmldir)
88  endif()
89
90  # archivedir
91  if(NOT DEFINED archivedir)
92    set(
93      archivedir
94      "/${CMAKE_INSTALL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}/storage"
95    )
96  endif()
97
98  # backenddir
99  if(NOT DEFINED backenddir)
100    set(backenddir ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/backends)
101  endif()
102
103  # scriptdir
104  if(NOT DEFINED scriptdir)
105    set(scriptdir "lib/${CMAKE_PROJECT_NAME}/scripts")
106  endif()
107
108  # workingdir
109  if(NOT DEFINED workingdir)
110    set(workingdir "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}")
111  endif()
112  set(working_dir "${workingdir}")
113
114  # plugindir
115  if(NOT DEFINED plugindir)
116    set(plugindir ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
117  endif()
118
119  # piddir
120  if(NOT DEFINED piddir)
121    set(piddir ${workingdir})
122  endif()
123
124  # bsrdir
125  if(NOT DEFINED bsrdir)
126    set(bsrdir ${workingdir})
127  endif()
128
129  # logdir
130  if(NOT DEFINED logdir)
131    set(logdir "${CMAKE_INSTALL_LOCALSTATEDIR}/log/${CMAKE_PROJECT_NAME}")
132  endif()
133
134  # datarootdir
135  if(NOT DEFINED datarootdir)
136    set(datarootdir "${CMAKE_INSTALL_DATAROOTDIR}")
137  endif()
138
139  # subsysdir
140  if(NOT DEFINED subsysdir)
141    set(subsysdir "${workingdir}")
142  endif()
143
144else() # IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
145
146  # libdir
147  if(NOT DEFINED libdir)
148    set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME})
149  endif()
150
151  # includedir
152  if(NOT DEFINED includedir)
153    set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CMAKE_PROJECT_NAME})
154  endif()
155
156  # bindir
157  if(NOT DEFINED bindir)
158    set(bindir ${CMAKE_INSTALL_FULL_BINDIR})
159    message(STATUS "set bindir to default ${bindir}")
160  endif()
161
162  # sbindir
163  if(NOT DEFINED sbindir)
164    set(sbindir ${CMAKE_INSTALL_FULL_SBINDIR})
165    message(STATUS "set sbindir to default ${sbindir}")
166  endif()
167
168  # sysconfdir
169  if(NOT DEFINED sysconfdir)
170    set(sysconfdir ${CMAKE_INSTALL_FULL_SYSCONFDIR})
171  endif()
172  set(SYSCONFDIR "\"${sysconfdir}\"")
173
174  # confdir
175  if(NOT DEFINED confdir)
176    set(confdir "${sysconfdir}/${CMAKE_PROJECT_NAME}")
177  endif()
178
179  # configtemplatedir
180  if(NOT DEFINED configtemplatedir)
181    set(configtemplatedir "${confdir}")
182  endif()
183
184  # mandir
185  if(NOT DEFINED mandir)
186    set(mandir ${CMAKE_INSTALL_FULL_MANDIR})
187  endif()
188
189  # docdir
190  if(NOT DEFINED docdir)
191    set(docdir default_for_docdir)
192  endif()
193
194  # htmldir
195  if(NOT DEFINED htmldir)
196    set(htmldir default_for_htmldir)
197  endif()
198
199  # archivedir
200  if(NOT DEFINED archivedir)
201    set(
202      archivedir
203      "/${CMAKE_INSTALL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}/storage"
204    )
205  endif()
206
207  # backenddir
208  if(NOT DEFINED backenddir)
209    set(backenddir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/backends)
210  endif()
211
212  # scriptdir
213  if(NOT DEFINED scriptdir)
214    set(scriptdir "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/scripts")
215  endif()
216
217  # workingdir
218  if(NOT DEFINED workingdir)
219    set(workingdir "/${CMAKE_INSTALL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}")
220  endif()
221  set(working_dir "${workingdir}")
222
223  # plugindir
224  if(NOT DEFINED plugindir)
225    set(plugindir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
226  endif()
227
228  # piddir
229  if(NOT DEFINED piddir)
230    set(piddir ${workingdir})
231  endif()
232
233  # bsrdir
234  if(NOT DEFINED bsrdir)
235    set(bsrdir ${workingdir})
236  endif()
237
238  # logdir
239  if(NOT DEFINED logdir)
240    set(logdir "${CMAKE_INSTALL_LOCALSTATEDIR}/log/${CMAKE_PROJECT_NAME}")
241  endif()
242
243  # datarootdir
244  if(NOT DEFINED datarootdir)
245    set(datarootdir "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
246  endif()
247
248  # subsysdir
249  if(NOT DEFINED subsysdir)
250    set(subsysdir "${workingdir}")
251  endif()
252
253endif() # IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
254
255# db_name
256if(NOT DEFINED db_name)
257  set(db_name "bareos")
258endif()
259
260# db_user
261if(NOT DEFINED db_user)
262  set(db_user "bareos")
263endif()
264
265# db_password
266if(NOT DEFINED db_password)
267  set(db_password "")
268endif()
269
270# dir-user
271if(NOT DEFINED dir-user)
272  set(dir-user "")
273endif()
274set(dir_user "${dir-user}")
275
276# dir-group
277if(NOT DEFINED dir-group)
278  set(dir-group "")
279endif()
280set(dir_group ${dir-group})
281
282# sd-user
283if(NOT DEFINED sd-user)
284  set(sd-user "")
285endif()
286set(sd_user ${sd-user})
287
288# sd-group
289if(NOT DEFINED sd-group)
290  set(sd-group "")
291endif()
292set(sd_group ${sd-group})
293
294# fd-user
295if(NOT DEFINED fd-user)
296  set(fd-user "")
297endif()
298set(fd_user ${fd-user})
299
300# fd-group
301if(NOT DEFINED fd-group)
302  set(fd-group "")
303endif()
304set(fd_group ${fd-group})
305
306# dir-password
307if(NOT DEFINED dir-password)
308  set(dir-password "bareos")
309endif()
310set(dir_password ${dir-password})
311
312# fd-password
313if(NOT DEFINED fd-password)
314  set(fd-password "")
315endif()
316set(fd_password ${fd-password})
317
318# sd-password
319if(NOT DEFINED sd-password)
320  set(sd-password "")
321endif()
322set(sd_password ${sd-password})
323
324# mon-dir-password
325if(NOT DEFINED mon-dir-password)
326  set(mon-dir-password "")
327endif()
328set(mon_dir_password ${mon-dir-password})
329
330# mon-fd-password
331if(NOT DEFINED mon-fd-password)
332  set(mon-fd-password "")
333endif()
334set(mon_fd_password ${mon-fd-password})
335
336# mon-sd-password
337if(NOT DEFINED mon-sd-password)
338  set(mon-sd-password "")
339endif()
340set(mon_sd_password ${mon-sd-password})
341
342# basename
343if(NOT DEFINED basename)
344  set(basename localhost)
345endif()
346
347# hostname
348if(NOT DEFINED hostname)
349  set(hostname localhost)
350endif()
351
352# ##############################################################################
353# rights
354# ##############################################################################
355# sbin-perm
356if(NOT DEFINED sbin-perm)
357  set(sbin-perm 755)
358endif()
359
360# ##############################################################################
361# bool
362# ##############################################################################
363# python
364if(NOT DEFINED python)
365  set(python ON)
366endif()
367
368# lockmgr
369if(NOT DEFINED lockmgr)
370  set(lockmgr OFF)
371  set(LOCKMGR 0)
372endif()
373
374# readline
375if(NOT DEFINED readline)
376  set(readline ON)
377endif()
378
379# batch-insert
380if((NOT DEFINED batch-insert) OR (${batch-insert}))
381  set(batch-insert ON)
382  set(HAVE_POSTGRESQL_BATCH_FILE_INSERT 1)
383  set(USE_BATCH_FILE_INSERT 1)
384endif()
385
386# dynamic-cats-backends
387option(dynamic-cats-backends "enable dynamic catalog backends" ON)
388if(dynamic-cats-backends)
389  set(HAVE_DYNAMIC_CATS_BACKENDS 1)
390else()
391  set(HAVE_DYNAMIC_CATS_BACKENDS 0)
392endif()
393
394# dynamic-storage-backends
395if(NOT DEFINED dynamic-storage-backends)
396  set(dynamic-storage-backends ON)
397  set(HAVE_DYNAMIC_SD_BACKENDS 1)
398else()
399  if(${dynamic-storage-backends})
400    set(HAVE_DYNAMIC_SD_BACKENDS 1)
401  else()
402    set(HAVE_DYNAMIC_SD_BACKENDS 0)
403  endif()
404endif()
405
406# scsi-crypto
407if(NOT DEFINED scsi-crypto)
408  set(scsi-crypto OFF)
409endif()
410
411# lmdb
412if(NOT DEFINED lmdb)
413  set(lmdb ON)
414endif()
415
416# ndmp
417if(NOT DEFINED ndmp)
418  set(ndmp ON)
419endif()
420
421# ipv6
422if((NOT DEFINED ipv6) OR (${ipv6}))
423  set(ipv6 ON)
424  set(HAVE_IPV6 1)
425endif()
426
427# acl
428if(NOT DEFINED acl)
429  set(acl ON)
430endif()
431
432# xattr
433if(NOT DEFINED xattr)
434  set(xattr ON)
435endif()
436
437# build_ndmjob
438if(NOT DEFINED build_ndmjob)
439  set(build_ndmjob OFF)
440endif()
441
442# bat
443if(NOT DEFINED bat)
444  set(bat OFF)
445endif()
446
447# traymonitor
448if(NOT DEFINED traymonitor)
449  set(HAVE_TRAYMONITOR 0)
450endif()
451
452# client-only
453if(NOT DEFINED client-only)
454  set(client-only OFF)
455  set(build_client_only OFF)
456else()
457  set(client-only ON)
458  set(build_client_only ON)
459endif()
460
461# postgresql
462if(NOT DEFINED postgresql)
463  set(postgresql OFF)
464endif()
465
466# mysql
467if(NOT DEFINED mysql)
468  set(mysql OFF)
469endif()
470
471# sqlite3
472if(NOT DEFINED sqlite3)
473  set(sqlite3 OFF)
474endif()
475
476if(NOT sqlite3)
477  if(NOT mysql)
478    if(NOT postgresql)
479      if(NOT client-only)
480        message(
481          FATAL_ERROR
482            "No database backend was chosen, please choose at least one from \n"
483            " - postgresql (-Dpostgresql=yes)\n"
484            " - mysqli     (-Dmysql=yes)     \n"
485            " - sqlite3    (-Dsqlite3=yes)   \n"
486            " or select client only build     (-Dclient-only=yes)   \n"
487        )
488      endif()
489    endif()
490  endif()
491endif()
492
493if(NOT mysql)
494  set(MYSQL_INCLUDE_DIR "")
495endif()
496
497if(NOT postgresql)
498  set(PostgreSQL_INCLUDE_DIR "")
499endif()
500
501if(NOT Readline_LIBRARY)
502  set(Readline_LIBRARY "")
503endif()
504
505if(NOT LIBZ_FOUND)
506  set(ZLIB_LIBRARY "")
507endif()
508
509set(db_backends "")
510
511if(NOT client-only)
512  if(${sqlite3})
513    set(HAVE_SQLITE3 1)
514    list(APPEND db_backends sqlite3)
515  endif()
516
517  if(${postgresql})
518    set(HAVE_POSTGRESQL 1)
519    list(APPEND db_backends postgresql)
520  endif()
521
522  if(${mysql})
523    set(HAVE_MYSQL 1)
524    list(APPEND db_backends mysql)
525  endif()
526
527  # set first entry as default db backend
528  list(GET db_backends 0 default_db_backend)
529  get_directory_property(hasParent PARENT_DIRECTORY)
530  if(hasParent)
531    set(DEFAULT_DB_TYPE ${default_db_backend} PARENT_SCOPE)
532  endif()
533  set(DEFAULT_DB_TYPE ${default_db_backend})
534endif()
535
536# tcp-wrappers
537if(NOT DEFINED tcp-wrappers)
538  set(tcp-wrappers OFF)
539endif()
540
541# systemd
542if(NOT DEFINED systemd)
543  set(systemd OFF)
544endif()
545
546# includes
547if(NOT DEFINED includes)
548  set(includes ON)
549endif()
550
551# openssl
552if(NOT DEFINED openssl)
553  set(openssl ON)
554endif()
555
556# ports
557if(NOT DEFINED dir_port)
558  set(dir_port "9101")
559endif()
560
561if(NOT DEFINED fd_port)
562  set(fd_port "9102")
563endif()
564
565if(NOT DEFINED sd_port)
566  set(sd_port "9103")
567endif()
568
569if(DEFINED baseport)
570  math(EXPR dir_port "${baseport}+0")
571  math(EXPR fd_port "${baseport}+1")
572  math(EXPR sd_port "${baseport}+2")
573endif()
574
575if(NOT DEFINED job_email)
576  set(job_email "root")
577endif()
578
579if(NOT DEFINED dump_email)
580  set(dump_email "root")
581endif()
582
583if(NOT DEFINED smtp_host)
584  set(smtp_host "localhost")
585endif()
586
587if(DEFINED traymonitor)
588  set(HAVE_TRAYMONITOR 1)
589endif()
590
591if(DEFINED test-plugin)
592  set(HAVE_TEST_PLUGIN 1)
593endif()
594
595if(NOT DEFINED developer)
596  set(developer OFF)
597endif()
598
599if(DEFINED dynamic-debian-package-list)
600  set(GENERATE_DEBIAN_CONTROL ON)
601else()
602  set(GENERATE_DEBIAN_CONTROL OFF)
603endif()
604
605if(NOT DEFINED coverage)
606  set(coverage OFF)
607endif()
608
609# do not destroy bareos-config-lib.sh
610set(DB_NAME "@DB_NAME@")
611set(DB_USER "@DB_USER@")
612set(DB_PASS "@DB_PASS@")
613set(DB_VERSION "@DB_VERSION@")
614
615if(${CMAKE_COMPILER_IS_GNUCC})
616  set(HAVE_GCC 1)
617endif()
618
619set(lld "\"lld\"")
620set(llu "\"llu\"")
621
622set(HAVE_MYSQL_THREAD_SAFE 1)
623set(HAVE_POSIX_SIGNALS 1)
624set(HAVE_SHA2 1)
625set(HAVE_PQISTHREADSAFE 1)
626set(HAVE_PQ_COPY 1)
627
628set(PROTOTYPES 1)
629set(RETSIGTYPE void)
630set(SETPGRP_VOID 1)
631set(SSTDC_HEADERS 1)
632
633set(_LARGEFILE_SOURCE 1)
634set(_LARGE_FILES 1)
635set(_FILE_OFFSET_BITS 64)
636set(HAVE_COMPRESS_BOUND 1)
637set(STDC_HEADERS 1)
638set(HAVE_SQLITE3_THREADSAFE 1)
639set(FSTYPE_MNTENT 1)
640
641set(PACKAGE_BUGREPORT "\"\"")
642set(PACKAGE_NAME "\"${CMAKE_PROJECT_NAME}\"")
643set(PACKAGE_STRING "\"${CMAKE_PROJECT_NAME} ${BAREOS_NUMERIC_VERSION}\"")
644set(PACKAGE_TARNAME "\"\"")
645set(PACKAGE_URL "\"\"")
646set(PACKAGE_VERSION "\"${BAREOS_NUMERIC_VERSION}\"")
647
648if(nls)
649  SET(ENABLE_NLS 1)
650else()
651  SET(ENABLE_NLS 0)
652endif()
653
654if(HAVE_WIN32)
655
656  if(NOT DEFINED WINDOWS_VERSION)
657    set(WINDOWS_VERSION 0x600)
658  endif()
659
660  if(NOT DEFINED WINDOWS_BITS)
661    set(WINDOWS_BITS 64)
662  endif()
663
664endif()
665
666if(DEFINED do-static-code-checks)
667  set(DO_STATIC_CODE_CHECKS ${do-static-code-checks})
668else()
669  set(DO_STATIC_CODE_CHECKS OFF)
670endif()
671