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  # archivedir
86  if(NOT DEFINED archivedir)
87    if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
88      # windows install scripts replace the string "/var/lib/bareos/storage"
89      set(archivedir "/var/lib/${CMAKE_PROJECT_NAME}/storage")
90    else()
91      set(archivedir
92          "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}/storage"
93      )
94    endif()
95  endif()
96
97  # backenddir
98  if(NOT DEFINED backenddir)
99    set(backenddir ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/backends)
100  endif()
101
102  # scriptdir
103  if(NOT DEFINED scriptdir)
104    set(scriptdir "lib/${CMAKE_PROJECT_NAME}/scripts")
105  endif()
106
107  # workingdir
108  if(NOT DEFINED workingdir)
109    set(workingdir
110        "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}"
111    )
112  endif()
113  set(working_dir "${workingdir}")
114
115  # plugindir
116  if(NOT DEFINED plugindir)
117    set(plugindir ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
118  endif()
119
120  # piddir
121  if(NOT DEFINED piddir)
122    set(piddir ${workingdir})
123  endif()
124
125  # bsrdir
126  if(NOT DEFINED bsrdir)
127    set(bsrdir ${workingdir})
128  endif()
129
130  # logdir
131  if(NOT DEFINED logdir)
132    set(logdir "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/${CMAKE_PROJECT_NAME}")
133  endif()
134
135  # datarootdir
136  if(NOT DEFINED datarootdir)
137    set(datarootdir "${CMAKE_INSTALL_DATAROOTDIR}")
138  endif()
139
140  # subsysdir
141  if(NOT DEFINED subsysdir)
142    set(subsysdir "${workingdir}")
143  endif()
144
145else() # IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
146
147  # libdir
148  if(NOT DEFINED libdir)
149    set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME})
150  endif()
151
152  # includedir
153  if(NOT DEFINED includedir)
154    set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CMAKE_PROJECT_NAME})
155  endif()
156
157  # bindir
158  if(NOT DEFINED bindir)
159    set(bindir ${CMAKE_INSTALL_FULL_BINDIR})
160    message(STATUS "set bindir to default ${bindir}")
161  endif()
162
163  # sbindir
164  if(NOT DEFINED sbindir)
165    set(sbindir ${CMAKE_INSTALL_FULL_SBINDIR})
166    message(STATUS "set sbindir to default ${sbindir}")
167  endif()
168
169  # sysconfdir
170  if(NOT DEFINED sysconfdir)
171    set(sysconfdir ${CMAKE_INSTALL_FULL_SYSCONFDIR})
172  endif()
173  set(SYSCONFDIR "\"${sysconfdir}\"")
174
175  # confdir
176  if(NOT DEFINED confdir)
177    set(confdir "${sysconfdir}/${CMAKE_PROJECT_NAME}")
178  endif()
179
180  # configtemplatedir
181  if(NOT DEFINED configtemplatedir)
182    set(configtemplatedir "${confdir}")
183  endif()
184
185  # mandir
186  if(NOT DEFINED mandir)
187    set(mandir ${CMAKE_INSTALL_FULL_MANDIR})
188  endif()
189
190  # docdir
191  if(NOT DEFINED docdir)
192    set(docdir default_for_docdir)
193  endif()
194
195  # archivedir
196  if(NOT DEFINED archivedir)
197    set(archivedir
198        "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}/storage"
199    )
200  endif()
201
202  # backenddir
203  if(NOT DEFINED backenddir)
204    set(backenddir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/backends)
205  endif()
206
207  # scriptdir
208  if(NOT DEFINED scriptdir)
209    set(scriptdir "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/scripts")
210  endif()
211
212  # workingdir
213  if(NOT DEFINED workingdir)
214    set(workingdir
215        "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${CMAKE_PROJECT_NAME}"
216    )
217  endif()
218  set(working_dir "${workingdir}")
219
220  # plugindir
221  if(NOT DEFINED plugindir)
222    set(plugindir ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
223  endif()
224
225  # piddir
226  if(NOT DEFINED piddir)
227    set(piddir ${workingdir})
228  endif()
229
230  # bsrdir
231  if(NOT DEFINED bsrdir)
232    set(bsrdir ${workingdir})
233  endif()
234
235  # logdir
236  if(NOT DEFINED logdir)
237    set(logdir "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/${CMAKE_PROJECT_NAME}")
238  endif()
239
240  # datarootdir
241  if(NOT DEFINED datarootdir)
242    set(datarootdir "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
243  endif()
244
245  # subsysdir
246  if(NOT DEFINED subsysdir)
247    set(subsysdir "${workingdir}")
248  endif()
249
250endif() # IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
251
252# db_name
253if(NOT DEFINED db_name)
254  set(db_name "bareos")
255endif()
256
257# db_user
258if(NOT DEFINED db_user)
259  set(db_user "bareos")
260endif()
261
262# db_password
263if(NOT DEFINED db_password)
264  set(db_password "")
265endif()
266
267# dir-user
268if(NOT DEFINED dir-user)
269  set(dir-user "")
270endif()
271set(dir_user "${dir-user}")
272
273# dir-group
274if(NOT DEFINED dir-group)
275  set(dir-group "")
276endif()
277set(dir_group ${dir-group})
278
279# sd-user
280if(NOT DEFINED sd-user)
281  set(sd-user "")
282endif()
283set(sd_user ${sd-user})
284
285# sd-group
286if(NOT DEFINED sd-group)
287  set(sd-group "")
288endif()
289set(sd_group ${sd-group})
290
291# fd-user
292if(NOT DEFINED fd-user)
293  set(fd-user "")
294endif()
295set(fd_user ${fd-user})
296
297# fd-group
298if(NOT DEFINED fd-group)
299  set(fd-group "")
300endif()
301set(fd_group ${fd-group})
302
303# dir-password
304if(NOT DEFINED dir-password)
305  set(dir-password "bareos")
306endif()
307set(dir_password ${dir-password})
308
309# fd-password
310if(NOT DEFINED fd-password)
311  set(fd-password "")
312endif()
313set(fd_password ${fd-password})
314
315# sd-password
316if(NOT DEFINED sd-password)
317  set(sd-password "")
318endif()
319set(sd_password ${sd-password})
320
321# mon-dir-password
322if(NOT DEFINED mon-dir-password)
323  set(mon-dir-password "")
324endif()
325set(mon_dir_password ${mon-dir-password})
326
327# mon-fd-password
328if(NOT DEFINED mon-fd-password)
329  set(mon-fd-password "")
330endif()
331set(mon_fd_password ${mon-fd-password})
332
333# mon-sd-password
334if(NOT DEFINED mon-sd-password)
335  set(mon-sd-password "")
336endif()
337set(mon_sd_password ${mon-sd-password})
338
339# basename
340if(NOT DEFINED basename)
341  set(basename localhost)
342endif()
343
344# hostname
345if(NOT DEFINED hostname)
346  set(hostname localhost)
347endif()
348
349# ##############################################################################
350# rights
351# ##############################################################################
352# sbin-perm
353if(NOT DEFINED sbin-perm)
354  set(sbin-perm 755)
355endif()
356
357# ##############################################################################
358# bool
359# ##############################################################################
360# python
361if(NOT DEFINED python)
362  set(python ON)
363endif()
364
365# lockmgr
366if(NOT DEFINED lockmgr)
367  set(lockmgr OFF)
368  set(LOCKMGR 0)
369endif()
370
371# readline
372if(NOT DEFINED readline)
373  set(readline ON)
374endif()
375
376# batch-insert
377if((NOT DEFINED batch-insert) OR (${batch-insert}))
378  set(batch-insert ON)
379  set(HAVE_POSTGRESQL_BATCH_FILE_INSERT 1)
380  set(USE_BATCH_FILE_INSERT 1)
381endif()
382
383# dynamic-cats-backends
384option(dynamic-cats-backends "enable dynamic catalog backends" ON)
385if(dynamic-cats-backends)
386  set(HAVE_DYNAMIC_CATS_BACKENDS 1)
387else()
388  set(HAVE_DYNAMIC_CATS_BACKENDS 0)
389endif()
390
391# dynamic-storage-backends
392if(NOT DEFINED dynamic-storage-backends)
393  set(dynamic-storage-backends ON)
394  set(HAVE_DYNAMIC_SD_BACKENDS 1)
395else()
396  if(${dynamic-storage-backends})
397    set(HAVE_DYNAMIC_SD_BACKENDS 1)
398  else()
399    set(HAVE_DYNAMIC_SD_BACKENDS 0)
400  endif()
401endif()
402
403# scsi-crypto
404if(NOT DEFINED scsi-crypto)
405  set(scsi-crypto OFF)
406endif()
407
408# lmdb
409if(NOT DEFINED lmdb)
410  set(lmdb ON)
411endif()
412
413# ndmp
414if(NOT DEFINED ndmp)
415  set(ndmp ON)
416endif()
417
418# ipv6
419if((NOT DEFINED ipv6) OR (${ipv6}))
420  set(ipv6 ON)
421  set(HAVE_IPV6 1)
422endif()
423
424# acl
425if(NOT DEFINED acl)
426  set(acl ON)
427endif()
428
429# xattr
430if(NOT DEFINED xattr)
431  set(xattr ON)
432endif()
433
434# build_ndmjob
435if(NOT DEFINED build_ndmjob)
436  set(build_ndmjob OFF)
437endif()
438
439# bat
440if(NOT DEFINED bat)
441  set(bat OFF)
442endif()
443
444# traymonitor
445if(NOT DEFINED traymonitor)
446  set(HAVE_TRAYMONITOR 0)
447endif()
448
449# client-only
450if(NOT DEFINED client-only)
451  set(client-only OFF)
452  set(build_client_only OFF)
453else()
454  set(client-only ON)
455  set(build_client_only ON)
456endif()
457
458# postgresql
459if(NOT DEFINED postgresql)
460  set(postgresql OFF)
461endif()
462
463# mysql
464if(NOT DEFINED mysql)
465  set(mysql OFF)
466endif()
467
468# sqlite3
469if(NOT DEFINED sqlite3)
470  set(sqlite3 OFF)
471endif()
472
473if(NOT sqlite3)
474  if(NOT mysql)
475    if(NOT postgresql)
476      if(NOT client-only)
477        message(
478          FATAL_ERROR
479            "No database backend was chosen, please choose at least one from \n"
480            " - postgresql (-Dpostgresql=yes)\n"
481            " - mysqli     (-Dmysql=yes)     \n"
482            " - sqlite3    (-Dsqlite3=yes)   \n"
483            " or select client only build     (-Dclient-only=yes)   \n"
484        )
485      endif()
486    endif()
487  endif()
488endif()
489
490if(NOT mysql)
491  set(MYSQL_INCLUDE_DIR "")
492endif()
493
494if(NOT postgresql)
495  set(PostgreSQL_INCLUDE_DIR "")
496endif()
497
498if(NOT Readline_LIBRARY)
499  set(Readline_LIBRARY "")
500endif()
501
502if(NOT LIBZ_FOUND)
503  set(ZLIB_LIBRARY "")
504endif()
505
506set(db_backends "")
507
508if(NOT client-only)
509
510  if(${postgresql})
511    set(HAVE_POSTGRESQL 1)
512    list(APPEND db_backends postgresql)
513  endif()
514
515  if(${sqlite3})
516    set(HAVE_SQLITE3 1)
517    list(APPEND db_backends sqlite3)
518  endif()
519
520  if(${mysql})
521    set(HAVE_MYSQL 1)
522    list(APPEND db_backends mysql)
523  endif()
524
525  if(NOT DEFINED default_db_backend)
526    # set first entry as default db backend if not already defined
527    list(GET db_backends 0 default_db_backend)
528  endif()
529  # set first backend to be tested by systemtests
530  list(GET db_backends 0 db_backend_to_test)
531  get_directory_property(hasParent PARENT_DIRECTORY)
532  if(hasParent)
533    set(db_backend_to_test
534        ${db_backend_to_test}
535        PARENT_SCOPE
536    )
537    set(DEFAULT_DB_TYPE
538        ${default_db_backend}
539        PARENT_SCOPE
540    )
541  endif()
542  set(DEFAULT_DB_TYPE ${default_db_backend})
543endif()
544
545# systemd
546if(NOT DEFINED systemd)
547  set(systemd OFF)
548endif()
549
550# includes
551if(NOT DEFINED includes)
552  set(includes ON)
553endif()
554
555# openssl
556if(NOT DEFINED openssl)
557  set(openssl ON)
558endif()
559
560# ports
561if(NOT DEFINED dir_port)
562  set(dir_port "9101")
563endif()
564
565if(NOT DEFINED fd_port)
566  set(fd_port "9102")
567endif()
568
569if(NOT DEFINED sd_port)
570  set(sd_port "9103")
571endif()
572
573if(DEFINED baseport)
574  math(EXPR dir_port "${baseport}+0")
575  math(EXPR fd_port "${baseport}+1")
576  math(EXPR sd_port "${baseport}+2")
577endif()
578
579if(NOT DEFINED job_email)
580  set(job_email "root")
581endif()
582
583if(NOT DEFINED dump_email)
584  set(dump_email "root")
585endif()
586
587if(NOT DEFINED smtp_host)
588  set(smtp_host "localhost")
589endif()
590
591if(DEFINED traymonitor)
592  set(HAVE_TRAYMONITOR 1)
593endif()
594
595if(DEFINED test-plugin)
596  set(HAVE_TEST_PLUGIN 1)
597endif()
598
599if(NOT DEFINED developer)
600  set(developer OFF)
601endif()
602
603if(DEFINED dynamic-debian-package-list)
604  set(GENERATE_DEBIAN_CONTROL ON)
605else()
606  set(GENERATE_DEBIAN_CONTROL OFF)
607endif()
608
609if(NOT DEFINED coverage)
610  set(coverage OFF)
611endif()
612
613# do not destroy bareos-config-lib.sh
614set(DB_NAME "@DB_NAME@")
615set(DB_USER "@DB_USER@")
616set(DB_PASS "@DB_PASS@")
617set(DB_VERSION "@DB_VERSION@")
618
619if(${CMAKE_COMPILER_IS_GNUCC})
620  set(HAVE_GCC 1)
621endif()
622
623set(HAVE_MYSQL_THREAD_SAFE 1)
624set(HAVE_SHA2 1)
625set(HAVE_PQISTHREADSAFE 1)
626
627set(_LARGEFILE_SOURCE 1)
628set(_LARGE_FILES 1)
629set(_FILE_OFFSET_BITS 64)
630set(HAVE_COMPRESS_BOUND 1)
631set(HAVE_SQLITE3_THREADSAFE 1)
632
633set(PACKAGE_NAME "\"${CMAKE_PROJECT_NAME}\"")
634set(PACKAGE_STRING "\"${CMAKE_PROJECT_NAME} ${BAREOS_NUMERIC_VERSION}\"")
635set(PACKAGE_VERSION "\"${BAREOS_NUMERIC_VERSION}\"")
636
637if(nls)
638  SET(ENABLE_NLS 1)
639else()
640  SET(ENABLE_NLS 0)
641endif()
642
643if(HAVE_WIN32)
644
645  if(NOT DEFINED WINDOWS_VERSION)
646    set(WINDOWS_VERSION 0x600)
647  endif()
648
649  if(NOT DEFINED WINDOWS_BITS)
650    set(WINDOWS_BITS 64)
651  endif()
652
653endif()
654
655if(DEFINED do-static-code-checks)
656  set(DO_STATIC_CODE_CHECKS ${do-static-code-checks})
657else()
658  set(DO_STATIC_CODE_CHECKS OFF)
659endif()
660