forked from arangodb/arangodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1405 lines (1149 loc) · 48.6 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- mode: CMAKE; -*-
# ------------------------------------------------------------------------------
# General
# ------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.9)
message(STATUS "CMake version: ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release
CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif ()
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"
OR CMAKE_BUILD_TYPE STREQUAL "Release"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"
OR CMAKE_BUILD_TYPE STREQUAL "None"))
message(FATAL_ERROR "expecting CMAKE_BUILD_TYPE: None Debug Release RelWithDebInfo MinSizeRel, got ${CMAKE_BUILD_TYPE}.")
endif ()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
if (APPLE)
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
if (NOT DEFINED ENV{MACOSX_DEPLOYMENT_TARGET} OR "ENV{MACOSX_DEPLOYMENT_TARGET}" STREQUAL "")
message(FATAL_ERROR "environment variable MACOSX_DEPLOYMENT_TARGET is missing")
else ()
set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING "deployment target for MacOSX; adjust to your system")
endif ()
else ()
set($ENV{MACOSX_DEPLOYMENT_TARGET} ${CMAKE_OSX_DEPLOYMENT_TARGET})
endif ()
endif ()
# where to find CMAKE modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
option(SKIP_PACKAGING "" OFF)
# be verbose about flags used
option(VERBOSE "be verbose about flags used" OFF)
# treat warnings as errors on some platforms
option(USE_FAIL_ON_WARNINGS "treat warnings as errors (MSVC and MacOS only)" ON)
# use strictly required OpenSSL version (from ./VERSIONS file)
option(USE_STRICT_OPENSSL_VERSION "use strictly required OpenSSL version (from ./VERSIONS file)" OFF)
option(USE_MINIMAL_DEBUGINFO "use minimal debug symbols for builds containing debug information" OFF)
# don't use standalone boost asio
# use this when asio is included outside of Boost
# add_definitions("-DARANGODB_STANDALONE_ASIO=0")
# add_definitions("-DFUERTE_STANDALONE_ASIO=0")
# ------------------------------------------------------------------------------
# VERSION information
# ------------------------------------------------------------------------------
# stable release: MAJOR.MINOR.PATCH
# hot fix: MAJOR.MINOR.PATCH-FIXNUMBER
# unstable release: MAJOR.MINOR.PATCH-TYPE.NUMBER
# devel: MAJOR.MINOR.0-devel
#
# These are mapped to the following variables:
#
# ARANGODB_VERSION_MAJOR = MAJOR
# ARANGODB_VERSION_MINOR = MINOR
# ARANGODB_VERSION_PATCH = PATCH
#
# for pre-releases, otherwise empty:
#
# ARANGODB_VERSION_PRELEASE_TYPE = TYPE
# ARANGODB_VERSION_PRELEASE_NUMBER = NUMBER
#
# This will set the following variables
#
# ARANGODB_DEBIAN_UPSTREAM
# ARANGODB_DEBIAN_REVISION
#
# ARANGODB_RPM_UPSTREAM
# ARANGODB_RPM_REVISION
set(ARANGODB_VERSION_MAJOR "3")
set(ARANGODB_VERSION_MINOR "8")
# when building the nightly ARANGODB_VERSION_PATCH will be set
if (NOT DEFINED ARANGODB_VERSION_PATCH)
set(ARANGODB_VERSION_PATCH "0")
set(ARANGODB_VERSION_RELEASE_TYPE "devel")
set(ARANGODB_VERSION_RELEASE_NUMBER "")
else()
unset (ARANGODB_VERSION_RELEASE_TYPE) # do not remove space
unset (ARANGODB_VERSION_RELEASE_NUMBER) # do not remove space
endif()
# unset TYPE and NUMBER in case they are empty
if (DEFINED ARANGODB_VERSION_RELEASE_TYPE)
if (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "")
unset (ARANGODB_VERSION_RELEASE_TYPE) # do not remove space
unset (ARANGODB_VERSION_RELEASE_NUMBER) # do not remove space
endif()
else()
unset (ARANGODB_VERSION_RELEASE_NUMBER) # do not remove space
endif()
if (DEFINED ARANGODB_VERSION_RELEASE_NUMBER)
if (ARANGODB_VERSION_RELEASE_NUMBER STREQUAL "")
unset (ARANGODB_VERSION_RELEASE_NUMBER) # do not remove space
endif()
endif()
# semantic version
set(ARANGODB_PLAIN_VERSION "${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.${ARANGODB_VERSION_PATCH}")
if (DEFINED ARANGODB_VERSION_RELEASE_TYPE)
if (DEFINED ARANGODB_VERSION_RELEASE_NUMBER)
set(ARANGODB_VERSION "${ARANGODB_PLAIN_VERSION}-${ARANGODB_VERSION_RELEASE_TYPE}.${ARANGODB_VERSION_RELEASE_NUMBER}")
else()
set(ARANGODB_VERSION "${ARANGODB_PLAIN_VERSION}-${ARANGODB_VERSION_RELEASE_TYPE}")
endif()
else()
set(ARANGODB_VERSION "${ARANGODB_PLAIN_VERSION}")
endif()
set(ARANGODB_JS_VERSION "js")
message(STATUS "ARANGODB PLAIN VERSION: ${ARANGODB_PLAIN_VERSION}")
message(STATUS "ARANGODB VERSION: ${ARANGODB_VERSION}")
message(STATUS "ARANGODB JS VERSION: ${ARANGODB_JS_VERSION}")
################################################################################
# DEBIAN, RPM, MacOS version
################################################################################
if (DEFINED ARANGODB_VERSION_RELEASE_TYPE)
# devel
if (ARANGODB_VERSION_PATCH STREQUAL "0" AND ARANGODB_VERSION_RELEASE_TYPE STREQUAL "devel")
set(ARANGODB_DEBIAN_UPSTREAM "${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.0~~${ARANGODB_VERSION_PATCH}")
set(ARANGODB_DEBIAN_REVISION "1")
set(ARANGODB_RPM_UPSTREAM "${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.0")
set(ARANGODB_RPM_REVISION "0.1.devel")
set(ARANGODB_DARWIN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DARWIN_REVISION "devel")
# nightly
elseif (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "nightly")
set(ARANGODB_DEBIAN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DEBIAN_REVISION "1")
set(ARANGODB_RPM_UPSTREAM "${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.0")
set(ARANGODB_RPM_REVISION "0.2.nightly")
set(ARANGODB_DARWIN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DARWIN_REVISION "nightly")
# unstable version
elseif ( ARANGODB_VERSION_RELEASE_TYPE STREQUAL "alpha"
OR ARANGODB_VERSION_RELEASE_TYPE STREQUAL "beta"
OR ARANGODB_VERSION_RELEASE_TYPE STREQUAL "milestone"
OR ARANGODB_VERSION_RELEASE_TYPE STREQUAL "preview"
OR ARANGODB_VERSION_RELEASE_TYPE STREQUAL "rc")
if (NOT DEFINED ARANGODB_VERSION_RELEASE_NUMBER)
message(FATAL_ERROR "ARANGODB_VERSION_RELEASE_NUMBER is missing")
endif()
if (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "alpha")
set(ARANGODB_RPM_REVISION_NUMBER 100)
elseif (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "beta")
set(ARANGODB_RPM_REVISION_NUMBER 200)
elseif (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "milestone")
set(ARANGODB_RPM_REVISION_NUMBER 300)
elseif (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "preview")
set(ARANGODB_RPM_REVISION_NUMBER 400)
elseif (ARANGODB_VERSION_RELEASE_TYPE STREQUAL "rc")
set(ARANGODB_RPM_REVISION_NUMBER 500)
endif()
MATH(EXPR ARANGODB_RPM_REVISION_NUMBER "${ARANGODB_RPM_REVISION_NUMBER}+${ARANGODB_VERSION_RELEASE_NUMBER}")
set(ARANGODB_DEBIAN_UPSTREAM "${ARANGODB_PLAIN_VERSION}~${ARANGODB_VERSION_RELEASE_TYPE}.${ARANGODB_VERSION_RELEASE_NUMBER}")
set(ARANGODB_DEBIAN_REVISION "1")
set(ARANGODB_RPM_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_RPM_REVISION "0.${ARANGODB_RPM_REVISION_NUMBER}")
set(ARANGODB_DARWIN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DARWIN_REVISION "${ARANGODB_VERSION_RELEASE_TYPE}.${ARANGODB_VERSION_RELEASE_NUMBER}")
# hot-fix
else()
if (DEFINED ARANGODB_VERSION_RELEASE_NUMBER)
message(FATAL_ERROR "ARANGODB_VERSION_RELEASE_NUMBER must be empty for type ${ARANGODB_VERSION_RELEASE_TYPE}")
endif()
set(ARANGODB_DEBIAN_UPSTREAM "${ARANGODB_PLAIN_VERSION}.${ARANGODB_VERSION_RELEASE_TYPE}")
set(ARANGODB_DEBIAN_REVISION "1")
set(ARANGODB_RPM_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_RPM_REVISION "1.${ARANGODB_VERSION_RELEASE_TYPE}")
set(ARANGODB_DARWIN_UPSTREAM "${ARANGODB_PLAIN_VERSION}.${ARANGODB_VERSION_RELEASE_TYPE}")
set(ARANGODB_DARWIN_REVISION "")
endif()
else()
# stable version
set(ARANGODB_DEBIAN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DEBIAN_REVISION "1")
set(ARANGODB_RPM_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_RPM_REVISION "1.0")
set(ARANGODB_DARWIN_UPSTREAM "${ARANGODB_PLAIN_VERSION}")
set(ARANGODB_DARWIN_REVISION "")
endif()
message(STATUS "DEBIAN VERSION: ${ARANGODB_DEBIAN_UPSTREAM} / ${ARANGODB_DEBIAN_REVISION}")
message(STATUS "RPM VERSION: ${ARANGODB_RPM_UPSTREAM} / ${ARANGODB_RPM_REVISION}")
message(STATUS "DARWIN VERSION: ${ARANGODB_DARWIN_UPSTREAM} / ${ARANGODB_DARWIN_REVISION}")
################################################################################
# Windows version
################################################################################
# PATCH needs to be numeric for the windows rc file
set(ARANGODB_WINDOWS_UPSTREAM "${ARANGODB_VERSION}")
if (ARANGODB_VERSION_PATCH GREATER -1)
set(ARANGODB_WINDOWS_PATCH "${ARANGODB_VERSION_PATCH}")
else()
set(ARANGODB_WINDOWS_PATCH 1337)
endif()
message(STATUS "WINDOWS VERSION: ${ARANGODB_WINDOWS_UPSTREAM}")
if (MSVC)
option(USE_CLCACHE_MODE
"whether we want to use CLCACHE-specific build options"
OFF
)
endif ()
################################################################################
# SNAP version
################################################################################
set(ARANGODB_SNAP_REVISION "1")
message(STATUS "SNAP REVISION: ${ARANGODB_SNAP_REVISION}")
# ------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
if (WIN32)
project(arangodb3 LANGUAGES CXX C VERSION ${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR})
else ()
project(arangodb3 LANGUAGES CXX C ASM VERSION ${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR})
endif ()
# required for clang completion in editors - must be set after creating project
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Static executables:
option(STATIC_EXECUTABLES "produce static executables" OFF)
if (STATIC_EXECUTABLES)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
if (WINDOWS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
else ()
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif ()
endif()
# enable dtrace
option(USE_DTRACE "enable dtrace probes" OFF)
if (USE_DTRACE)
add_definitions("-DUSE_DTRACE=1")
endif ()
# enable Enterprise Edition features
set(ENTERPRISE_INCLUDE_DIR "enterprise")
option(USE_ENTERPRISE "enable enterprise build" OFF)
if (USE_ENTERPRISE)
add_definitions("-DUSE_ENTERPRISE=1")
add_subdirectory(enterprise)
endif ()
# we want the following definitions to be in effect for both rocksdb and arangodb
add_definitions("-DNROCKSDB_THREAD_STATUS")
add_definitions("-DROCKSDB_SUPPORT_THREAD_LOCAL")
# for the packages
set(ARANGODB_PACKAGE_VENDOR "ArangoDB GmbH")
set(ARANGODB_PACKAGE_CONTACT "info@arangodb.com")
set(ARANGODB_DISPLAY_NAME "ArangoDB")
set(ARANGODB_URL_INFO_ABOUT "https://www.arangodb.com")
set(ARANGODB_HELP_LINK "https://www.arangodb.com/docs/${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}/")
set(ARANGODB_CONTACT "hackers@arangodb.com")
set(ARANGODB_FRIENDLY_STRING "ArangoDB - the native multi-model NoSQL database")
# MSVC
set(ARANGO_BENCH_FRIENDLY_STRING "arangobench - stress test tool")
set(ARANGO_BACKUP_FRIENDLY_STRING "arangobackup - hot backup tool")
set(ARANGO_DUMP_FRIENDLY_STRING "arangodump - data and configuration dumping tool")
set(ARANGO_RESTORE_FRIENDLY_STRING "arangrestore - data and configuration restoration tool")
set(ARANGO_EXPORT_FRIENDLY_STRING "arangoexport - data exporter")
set(ARANGO_IMPORT_FRIENDLY_STRING "arangoimport - data importer")
set(ARANGOSH_FRIENDLY_STRING "arangosh - commandline client")
set(ARANGO_VPACK_FRIENDLY_STRING "arangovpack - VelocyPack formatter")
# binaries
set(BIN_ARANGOBENCH arangobench)
set(BIN_ARANGOBACKUP arangobackup)
set(BIN_ARANGOD arangod)
set(BIN_ARANGODUMP arangodump)
set(BIN_ARANGOEXPORT arangoexport)
set(BIN_ARANGOIMPORT arangoimport)
set(BIN_ARANGORESTORE arangorestore)
set(BIN_ARANGOSH arangosh)
set(BIN_ARANGOVPACK arangovpack)
# test binaries
set(BIN_ARANGODB_TESTS arangodbtests)
set(CLEAN_AUTOGENERATED_FILES)
set(PACKAGES_LIST)
set(COPY_PACKAGES_LIST)
set(CLEAN_PACKAGES_LIST)
set(INSTALL_CONFIGFILES_LIST)
# ------------------------------------------------------------------------------
# update files containing VERSION information
# ------------------------------------------------------------------------------
if (${CMAKE_MAJOR_VERSION} EQUAL 2)
set(ARANGODB_BUILD_DATE "YYYY-MM-DD HH:MM:SS")
else ()
string(TIMESTAMP ARANGODB_BUILD_DATE "%Y-%m-%d %H:%M:%S")
endif ()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/build.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/lib/Basics/build.h"
NEWLINE_STYLE UNIX
)
if (NOT DEFINED GENERATE_BUILD_DATE OR GENERATE_BUILD_DATE)
set(GENERATE_BUILD_DATE ON CACHE INTERNAL "whether we should generate the build date")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/build-date.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/lib/Basics/build-date.h"
NEWLINE_STYLE UNIX
)
else()
set(GENERATE_BUILD_DATE OFF CACHE INTERNAL "whether we should generate the build date")
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/VERSION.in"
"${CMAKE_CURRENT_SOURCE_DIR}/VERSION"
NEWLINE_STYLE UNIX
)
################################################################################
## Find the git revision
################################################################################
find_program (GIT_EXE git)
if (DEFINED GIT_EXE AND IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT_EXE} describe --all --tags --long --dirty=-dirty
OUTPUT_VARIABLE GIT_OUTPUT)
# this may fail on shallow clones that only knows about a limited number of commits.
# if there is an older merged revision the head, it may not be available to git.
if (NOT GIT_OUTPUT)
set(ARANGODB_BUILD_REPOSITORY "GIT FAILED TO RETRIEVE THE VERSION - SHALLOW CLONE?")
set(HAVE_ARANGODB_BUILD_REPOSITORY "1")
else()
string(STRIP ${GIT_OUTPUT} REPOSITORY_VERSION)
set(ARANGODB_BUILD_REPOSITORY ${REPOSITORY_VERSION})
set(HAVE_ARANGODB_BUILD_REPOSITORY "1")
endif()
else ()
set(ARANGODB_BUILD_REPOSITORY "")
set(HAVE_ARANGODB_BUILD_REPOSITORY "0")
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/build-repository.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/lib/Basics/build-repository.h"
NEWLINE_STYLE UNIX
)
if (VERBOSE)
message(STATUS "ARANGODB_BUILD_REPOSITORY=\"${ARANGODB_BUILD_REPOSITORY}\"")
endif ()
################################################################################
## OPERATION SYSTEM
################################################################################
option(HOMEBREW
"whether to install for homebrew"
Off
)
if (WIN32)
set(WINDOWS TRUE)
set(MSBUILD TRUE)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
add_definitions(-D_WIN32_WINNT=0x600)
add_definitions(-DINCL_EXTRA_HTON_FUNCTIONS)
add_definitions(-DPSAPI_VERSION=1)
elseif (UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(LINUX TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(FREEBSD TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(NETBSD TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(OPENBSD TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(GNU TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(BSDI TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(FREEBSD TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SYSV5 TRUE)
endif ()
elseif (APPLE)
if (CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(DARWIN TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(DARWIN TRUE)
endif ()
find_program(BREW brew)
endif ()
# ------------------------------------------------------------------------------
# user options
# ------------------------------------------------------------------------------
if (WINDOWS)
SET(USE_JEMALLOC OFF)
elseif (APPLE)
SET(USE_JEMALLOC OFF)
else ()
option(
USE_JEMALLOC
"use jemalloc memory allocator"
ON
)
endif ()
if (LINUX)
option(
USE_LIBUNWIND
"use libunwind for stack traces"
ON
)
else ()
SET(USE_LIBUNWIND OFF)
endif ()
if (CROSS_COMPILING)
# currently off, need additional params to configure like --host=triple <params>
SET(USE_JEMALLOC OFF)
SET(USE_LIBUNWIND OFF)
endif()
################################################################################
## EXTERNAL PROGRAMS
################################################################################
set(MAKE make)
find_package(PythonInterp 3 EXACT REQUIRED)
get_filename_component(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" REALPATH)
set($ENV{PYTHON_EXECUTABLE} ${PYTHON_EXECUTABLE})
# FIXME the build containers seem to have a
# /usr/bin/ch(mod|own) to prevent the search
# to find those files the NO_DEFAULT_PATH
# argument is passed
if (NOT WINDOWS)
find_program (MAKE make gmake)
find_program(
CHMOD_EXECUTABLE chmod
PATHS "/bin/" "/usr/bin/"
NO_DEFAULT_PATH
)
message(STATUS "chmod found in ${CHMOD_EXECUTABLE}")
find_program(
CHOWN_EXECUTABLE chown
PATHS "/bin" "/usr/bin"
NO_DEFAULT_PATH
)
message(STATUS "chown found in ${CHOWN_EXECUTABLE}")
endif()
################################################################################
## ARCHITECTURE
################################################################################
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
add_definitions("-DARANGODB_BITS=${BITS}")
################################################################################
## COMPILER FEATURES
################################################################################
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
set(CMAKE_COMPILER_IS_CLANG 1)
endif ()
if (WINDOWS)
set(BASE_FLAGS "/D WIN32 /D _WINDOWS /W3 /MP" CACHE STRING "base flags")
set(BASE_C_FLAGS "" CACHE STRING "base C flags")
set(BASE_CXX_FLAGS "/GR /EHsc /Zc:__cplusplus" CACHE STRING "base C++flags")
else ()
set(BASE_FLAGS "" CACHE STRING "base flags")
set(BASE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}" CACHE STRING "base C flags")
set(BASE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}" CACHE STRING "base C++ flags")
set(BASE_LD_FLAGS "$ENV{LDFLAGS}" CACHE STRING "base linker flags")
set(BASE_LIBS "$ENV{LIBS}" CACHE STRING "base libraries")
endif ()
if (CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.3")
message(WARNING "ArangoDB requires g++ 9.3 or newer, building with older compiler versions is unsupported")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "10.9.9")
message(WARNING "ArangoDB doesn't support g++ 11.0 yet, building with newer compiler versions is unsupported")
endif()
set(BASE_C_FLAGS "${BASE_C_FLAGS}")
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR APPLE)
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++17")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# MSVC2018.1 - MSVC2018.7 does not correctly support alignas()
if (MSVC_VERSION VERSION_LESS 1915)
message(FATAL_ERROR "ArangoDB doesn't support MSVC less than 2017 update 15.8!")
elseif (MSVC_VERSION VERSION_GREATER_EQUAL 1915 AND MSVC_VERSION VERSION_LESS 1920)
message(WARNING "ArangoDB requires MSVC 2019 update 16.4 or newer, building with older compiler versions is unsupported")
# according to https://developercommunity.visualstudio.com/solutions/616098/view.html,
# the following define is not necessary anymore, as it should be fixed in MSVC 16.0:
# MSVC2018.8 requires the following define
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
elseif (MSVC_VERSION VERSION_GREATER_EQUAL 1920 AND MSVC_VERSION VERSION_LESS 1924)
message(FATAL_ERROR "ArangoDB requires at least MSVC 2019 update 16.4!")
endif()
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std:c++17")
endif()
if (CMAKE_COMPILER_IS_CLANG)
if (APPLE)
if (NOT DEFINED ENV{MACOSX_DEPLOYMENT_TARGET} OR ENV{MACOSX_DEPLOYMENT_TARGET} STREQUAL "")
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -stdlib=libc++")
else ()
set(BASE_C_FLAGS "${BASE_C_FLAGS} -mmacosx-version-min=$ENV{MACOSX_DEPLOYMENT_TARGET}")
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -stdlib=libc++ -mmacosx-version-min=$ENV{MACOSX_DEPLOYMENT_TARGET}")
set(BASE_LD_FLAGS "${BASE_LD_FLAGS} -mmacosx-version-min=$ENV{MACOSX_DEPLOYMENT_TARGET}")
endif ()
add_definitions("-Wno-deprecated-declarations")
else ()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
message(WARNING "ArangoDB requires clang 10.0 or newer, building with older compiler versions is unsupported")
endif()
list(APPEND BASE_LIBS atomic)
endif ()
endif ()
# need c++17
# XXX this should really be set on a per target level using cmake compile_features capabilties
set(CMAKE_CXX_STANDARD 17)
# need threads
find_package(Threads REQUIRED)
if (MSVC)
configure_file("Installation/Windows/vcproj.user/arangod.vcxproj.user" ${CMAKE_BINARY_DIR})
add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
add_definitions("-DFD_SETSIZE=8192")
add_definitions("-DU_STATIC_IMPLEMENTATION=1")
add_definitions("-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS=1") # try to remove this when
# boost is upgraded to 1.70 or later
# https://blogs.msdn.microsoft.com/vcblog/2016/04/14/stl-fixes-in-vs-2015-update-2/
# https://connect.microsoft.com/VisualStudio/feedback/details/1892487
# http://lists.boost.org/boost-users/2016/04/85968.php
add_definitions("-D_ENABLE_ATOMIC_ALIGNMENT_FIX")
# bcrypt is needed for SSL
set(MSVC_LIBS Shlwapi.lib;crypt32.lib;bcrypt.lib;WINMM.LIB;Ws2_32.lib;Psapi.lib)
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /SAFESEH:NO /MACHINE:x64 /ignore:4099 ${BASE_LD_FLAGS}"
)
else ()
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${BASE_LD_FLAGS}"
)
endif ()
# broken clock_gettime on MacOSX
SET(USE_LOCAL_CLOCK_GETTIME FALSE)
if (APPLE)
TRY_RUN(RUN_CLOCK_GETTIME
COMPILE_CLOCK_GETTIME
${PROJECT_BINARY_DIR}/test_clock_gettime
${CMAKE_SOURCE_DIR}/cmake/test_clock_gettime.c
OUTPUT_VARIABLE OUTPUT_CLOCK_GETTIME)
if (${COMPILE_CLOCK_GETTIME})
if (${RUN_CLOCK_GETTIME} STREQUAL "FAILED_TO_RUN")
set(USE_LOCAL_CLOCK_GETTIME TRUE)
endif ()
endif ()
if (USE_LOCAL_CLOCK_GETTIME)
message(STATUS "using a home-made clock_gettime")
endif ()
endif ()
################################################################################
## INCLUDE DIRECTORIES
################################################################################
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_BINARY_DIR}/lib)
include_directories(${PROJECT_SOURCE_DIR}/arangod)
include_directories(${PROJECT_SOURCE_DIR}/lib)
if (CUSTOM_INCLUDES)
include_directories(${CUSTOM_INCLUDES})
endif ()
################################################################################
## TARGET ARCHITECTURE
################################################################################
set(ARANGODB_SSE42_FLAGS "")
if (WINDOWS)
add_definitions("-DNO_SSE42")
else ()
include(TargetArch)
target_architecture(CMAKE_TARGET_ARCHITECTURES)
list(LENGTH CMAKE_TARGET_ARCHITECTURES cmake_target_arch_len)
if (NOT "${cmake_target_arch_len}" EQUAL "1")
set(CMAKE_TARGET_ARCHITECTURE_UNIVERSAL TRUE)
set(CMAKE_TARGET_ARCHITECTURE_CODE "universal")
else ()
set(CMAKE_TARGET_ARCHITECTURE_UNIVERSAL FALSE)
set(CMAKE_TARGET_ARCHITECTURE_CODE "${CMAKE_TARGET_ARCHITECTURES}")
endif ()
include(VcMacros)
option(USE_OPTIMIZE_FOR_ARCHITECTURE "try to determine CPU architecture" ON)
if (USE_OPTIMIZE_FOR_ARCHITECTURE)
include(OptimizeForArchitecture)
OptimizeForArchitecture()
endif ()
if (USE_SSE4_2)
set(ARANGODB_SSE42_FLAGS "-msse4.2")
endif ()
set(BASE_FLAGS "${Vc_ARCHITECTURE_FLAGS} ${BASE_FLAGS}")
endif ()
set(ARCHITECTURE_OPTIMIZATIONS "\"${Vc_ARCHITECTURE_FLAGS}\"")
################################################################################
## BACKTRACE
################################################################################
option(USE_BACKTRACE
"whether we should try to generate c-level stacktraces"
OFF
)
# iresearch uses backtrace anyway, so we need to find and link libexecinfo
# for the case that we are on libmusl and not on glibc
if (NOT MSVC)
find_package(Backtrace)
endif()
if (USE_BACKTRACE)
if (MSVC)
set(BT_LIBS "Dbghelp" CACHE PATH "Debug Helper libraries")
else ()
set(BT_LIBS ${Backtrace_LIBRARY} CACHE PATH "Debug Helper libraries")
endif ()
add_definitions("-DARANGODB_ENABLE_BACKTRACE=1")
else ()
set(BT_LIBS ${Backtrace_LIBRARY} CACHE PATH "Debug Helper libraries")
endif ()
################################################################################
## ASSEMBLER OPTIMIZATIONS
################################################################################
# Allow to prohibit assembler optimization code explicitly
if (MSVC)
SET(ASM_OPTIMIZATIONS_DEFAULT OFF)
else (MSVC)
SET(ASM_OPTIMIZATIONS_DEFAULT ON)
endif (MSVC)
option(ASM_OPTIMIZATIONS "whether hand-optimized assembler code should be used"
${ASM_OPTIMIZATIONS_DEFAULT})
if (ASM_OPTIMIZATIONS)
add_definitions("-DASM_OPTIMIZATIONS=1")
else (ASM_OPTIMIZATIONS)
add_definitions("-DASM_OPTIMIZATIONS=0")
endif (ASM_OPTIMIZATIONS)
################################################################################
## MAINTAINER MODE
################################################################################
option(UNCONDITIONALLY_BUILD_LOG_MESSAGES
"whether log strings should be generated regardless of active loglevel"
OFF
)
if (UNCONDITIONALLY_BUILD_LOG_MESSAGES)
add_definitions("-DARANGODB_UNCONDITIONALLY_BUILD_LOG_MESSAGES=1")
endif()
option(USE_MAINTAINER_MODE
"whether we want to have assertions and other development features"
OFF
)
if (USE_MAINTAINER_MODE)
add_definitions("-DARANGODB_ENABLE_MAINTAINER_MODE=1")
if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions("-D_FORTIFY_SOURCE=2")
endif()
find_package(FLEX)
find_package(BISON)
# these are required for generateREADME.sh
find_program(FGREP_EXECUTABLE fgrep)
find_program(SED_EXECUTABLE sed)
find_program(AWK_EXECUTABLE awk)
endif ()
option(USE_GOOGLE_TESTS "Compile C++ unit tests" ON)
if (USE_GOOGLE_TESTS)
add_definitions("-DARANGODB_USE_GOOGLE_TESTS=1")
endif()
include(debugInformation)
find_program(READELF_EXECUTABLE readelf)
detect_binary_id_type(CMAKE_DEBUG_FILENAMES_SHA_SUM)
################################################################################
## FAILURE TESTS
################################################################################
option(USE_FAILURE_TESTS
"whether we want to have failure tests compiled in"
OFF
)
if (USE_FAILURE_TESTS)
add_definitions("-DARANGODB_ENABLE_FAILURE_TESTS=1")
endif ()
################################################################################
## INTERPROCEDURAL OPTIMIZATION (LINK TIME OPTIMIZATION)
################################################################################
set(USE_IPO AUTO CACHE STRING "Use interprocedural optimization: ON, OFF or AUTO")
set_property(CACHE USE_IPO PROPERTY STRINGS AUTO ON OFF)
set(IPO_ENABLED False)
# Determine value if IPO_ENABLED from USE_IPO and CMAKE_BUILD_TYPE
if (USE_IPO STREQUAL "AUTO")
# When USE_IPO=AUTO, enable IPO for optimized / release builds.
# But to work around a g++ segfault triggered by using both -flto and
# -fno-devirtualize-functions, we disable IPO when using google tests, because
# this will set no-devirtualize. See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91387 and
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91375.
# So this check may be removed later as soon as we use fixed gcc versions.
# - Tobias, 2019-08-08
if (NOT USE_GOOGLE_TESTS AND
(CMAKE_BUILD_TYPE STREQUAL "Release"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"))
set(IPO_ENABLED True)
else()
set(IPO_ENABLED False)
endif ()
elseif (USE_IPO)
set(IPO_ENABLED True)
else()
set(IPO_ENABLED False)
endif()
message(STATUS "IPO_ENABLED: ${IPO_ENABLED}")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${IPO_ENABLED})
if (IPO_ENABLED)
add_definitions("-DARANGODB_USE_IPO=1")
endif()
################################################################################
## LIBRARY RESOLV
################################################################################
if (NOT WINDOWS)
set(SYS_LIBS ${SYS_LIBS} resolv)
if (NOT DARWIN)
set(SYS_LIBS ${SYS_LIBS} rt)
endif ()
endif ()
# ------------------------------------------------------------------------------
# IMPLICIT INCLUDES AND LIBIRARY DIRECTORIES
# ------------------------------------------------------------------------------
function(CREATE_FLAGS OUTPUT GLUE)
set(_TMP_RESULT "")
foreach(arg ${ARGN})
set(_TMP_RESULT "${_TMP_RESULT} ${GLUE}${arg}")
endforeach()
set(${OUTPUT} "${_TMP_RESULT}" PARENT_SCOPE)
endfunction()
# CREATE_FLAGS(IMPLICIT_C_INCLUDES "${CMAKE_C_SYSROOT_FLAG} " ${CMAKE_OSX_SYSROOT})
# CREATE_FLAGS(IMPLICIT_CXX_INCLUDES "${CMAKE_CXX_SYSROOT_FLAG} " ${CMAKE_OSX_SYSROOT})
# ------------------------------------------------------------------------------
# JEMALLOC
# ------------------------------------------------------------------------------
option(USE_JEMALLOC_PROF "use jemalloc profiler" OFF)
if (USE_JEMALLOC)
add_definitions("-DARANGODB_HAVE_JEMALLOC=1")
endif ()
if (USE_JEMALLOC_PROF)
add_definitions("-DUSE_MEMORY_PROFILE=1")
endif ()
# ------------------------------------------------------------------------------
# LIBUNWIND
# ------------------------------------------------------------------------------
if (USE_LIBUNWIND)
add_definitions("-DARANGODB_HAVE_LIBUNWIND=1")
endif ()
# ------------------------------------------------------------------------------
# NDEBUG
# ------------------------------------------------------------------------------
add_definitions(-DNDEBUG)
################################################################################
## FLAGS
################################################################################
if (VERBOSE)
message(STATUS)
endif ()
# compiler options
if (MSVC)
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
if (USE_MINIMAL_DEBUGINFO)
message(FATAL_ERROR "USE_MINIMAL_DEBUGINFO is not supported for this compiler")
endif ()
set(BASE_FLAGS "/wd4996 ${BASE_FLAGS}")
set(CMAKE_C_FLAGS "/MTd" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "/D _DEBUG /MTd /Zi /Ob0 /Od /RTC1 /bigobj" CACHE INTERNAL "C debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1" CACHE INTERNAL "C minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2" CACHE INTERNAL "C release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1" CACHE INTERNAL "C release with debug info flags")
set(CMAKE_CXX_FLAGS "/MTd" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "/D _DEBUG /MTd /Zi /Ob0 /Od /RTC1 /bigobj" CACHE INTERNAL "C++ debug flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2" CACHE INTERNAL "C++ release flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1" CACHE INTERNAL "C++ release with debug info flags")
if (USE_CLCACHE_MODE)
set(CMAKE_VS_GLOBALS "TrackFileAccess=false")
add_definitions(/Z7)
endif ()
else () # NOT MSVC
set(EXTRA_C_FLAGS "")
set(EXTRA_CXX_FLAGS "")
if (CMAKE_COMPILER_IS_GNUCC)
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations ${BASE_FLAGS}")
set(EXTRA_CXX_FLAGS "-Wsuggest-override -Wnon-virtual-dtor")
elseif (CMAKE_COMPILER_IS_CLANG)
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations ${BASE_FLAGS}")
set(EXTRA_CXX_FLAGS "-Wnon-virtual-dtor")
if (NOT DARWIN AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0")
# clang 11 and higher supports -Wsuggest-override. older versions don't
set(EXTRA_CXX_FLAGS "-Wsuggest-override ${EXTRA_CXX_FLAGS}")
endif ()
if (DARWIN AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.1")
# With the introduction of apple clang version 12.0.0 (clang-1200.0.32.2) the warning "range-loop-analysis" is now
# enabled by default or changed analysis behaviour. The compiler now complains about "wrong" usage of
# VPackObjectIterator and VPackArrayIterator - which is not the case.
#
# See example here: https://github.com/arangodb/arangodb/pull/12730
#
# Since we're stopping compilation on Apple in any warning case, we need to temporary disable that warning and
# check upcoming versions if the compiler behaviour will be fixed.
set(EXTRA_C_FLAGS "-Wno-range-loop-analysis")
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-range-loop-analysis")
endif ()
else ()
# unknown compiler
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "-Wall ${BASE_FLAGS}")
endif ()
# flags for builds without debug symbols
set(NODEBUGINFO_FLAGS "-g0")
# flags for builds with debug symbols
if (USE_MINIMAL_DEBUGINFO)
# minimal debug symbols
set(DEBUGINFO_FLAGS "-g1 -gno-column-info -gz")
else ()
# full debug symbols
set(DEBUGINFO_FLAGS "-g")
endif ()
# c
# note: when building one of the build types, CMake will automatically combine
# the base flags from CMAKE_C_FLAGS with build type-specific flags in
# CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}.
# there is no need to repeat the base flags in the build-type specific flags!
set(CMAKE_C_FLAGS "${EXTRA_C_FLAGS}" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "${DEBUGINFO_FLAGS} -O0 -D_DEBUG=1" CACHE INTERNAL "C debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "${NODEBUGINFO_FLAGS} -Os" CACHE INTERNAL "C minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "${NODEBUGINFO_FLAGS} -O3 -fomit-frame-pointer" CACHE INTERNAL "C release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${DEBUGINFO_FLAGS} -O3 -fno-omit-frame-pointer" CACHE INTERNAL "C release with debug info flags")
# cxx
# note: when building one of the build types, CMake will automatically combine
# the base flags from CMAKE_CXX_FLAGS with build type-specific flags in
# CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}.
# there is no need to repeat the base flags in the build-type specific flags!
set(CMAKE_CXX_FLAGS "${EXTRA_CXX_FLAGS}" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "${DEBUGINFO_FLAGS} -O0 -D_DEBUG=1" CACHE INTERNAL "C++ debug flags")