forked from arangodb/arangodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
880 lines (707 loc) · 29.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
# -*- mode: CMAKE; -*-
# ------------------------------------------------------------------------------
# General
# ------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
if (POLICY CMP0037)
cmake_policy(SET CMP0037 NEW)
endif ()
if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif ()
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 ()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "deployment target for MacOSX")
if (WIN32)
project(arangodb3 CXX C)
else ()
project(arangodb3 CXX C ASM)
endif ()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# where to find CMAKE modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
# be verbose about flags used
option(VERBOSE OFF)
# enable timer for development
option(USE_DEV_TIMERS OFF)
if (USE_DEV_TIMERS)
add_definitions("-DUSE_DEV_TIMERS=1")
endif ()
################################################################################
## ARANGODB
################################################################################
set(ARANGODB_VERSION_MAJOR "3")
set(ARANGODB_VERSION_MINOR "0")
set(ARANGODB_VERSION_REVISION "devel")
set(ARANGODB_PACKAGE_REVISION "1")
set(ARANGODB_VERSION
"${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.${ARANGODB_VERSION_REVISION}")
# for the packages
set(ARANGODB_PACKAGE_VENDOR "ArangoDB GmbH")
set(ARANGODB_PACKAGE_CONTACT "[email protected]")
set(ARANGODB_DISPLAY_NAME "ArangoDB")
set(ARANGODB_URL_INFO_ABOUT "https://www.arangodb.com")
set(ARANGODB_HELP_LINK "https://docs.arangodb.com/${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}/")
set(ARANGODB_CONTACT "[email protected]")
set(ARANGODB_FRIENDLY_STRING "ArangoDB - the multi-model database")
# MSVC
set(ARANGO_BENCH_FRIENDLY_STRING "arangobench - stress test program")
set(ARANGO_DUMP_FRIENDLY_STRING "arangodump - export")
set(ARANGO_RESTORE_FRIENDLY_STRING "arangrestore - importer")
set(ARANGO_IMP_FRIENDLY_STRING "arangoimp - TSV/CSV/JSON importer")
set(ARANGOSH_FRIENDLY_STRING "arangosh - commandline client")
set(ARANGO_VPACK_FRIENDLY_STRING "arangovpack - vpack printer")
# libraries
set(LIB_ARANGO arango)
set(LIB_ARANGO_V8 arango_v8)
# binaries
set(BIN_ARANGOBENCH arangobench)
set(BIN_ARANGOD arangod)
set(BIN_ARANGODUMP arangodump)
set(BIN_ARANGOIMP arangoimp)
set(BIN_ARANGORESTORE arangorestore)
set(BIN_ARANGOSH arangosh)
set(BIN_ARANGOVPACK arangovpack)
# test binaries
set(TEST_BASICS_SUITE basics_suite)
set(TEST_GEO_SUITE geo_suite)
set(PACKAGES_LIST)
################################################################################
## VERSION FILES
################################################################################
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
)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/build-date.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/lib/Basics/build-date.h"
NEWLINE_STYLE UNIX
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/VERSION.in"
"${CMAKE_CURRENT_SOURCE_DIR}/VERSION"
NEWLINE_STYLE UNIX
)
find_program (GIT_EXE git)
set (EXECUTE_COMMAND ${GIT_EXE} describe --all --tags --long --dirty=-dirty)
execute_process(COMMAND ${EXECUTE_COMMAND} OUTPUT_VARIABLE GIT_OUTPUT)
string(STRIP ${GIT_OUTPUT} REPOSITORY_VERSION)
set(ARANGODB_BUILD_REPOSITORY ${REPOSITORY_VERSION})
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)
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)
elseif ((CMAKE_SYSTEM_NAME MATCHES "Solaris.*") OR (CMAKE_SYSTEM_NAME MATCHES "SunOS.*"))
set(SOLARIS TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(HPUX TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(AIX TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(MINIX TRUE)
endif ()
elseif (APPLE)
if (CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(DARWIN TRUE)
elseif (CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(MACOSX TRUE)
endif ()
endif ()
################################################################################
## ROCKSDB
################################################################################
option(USE_ROCKSDB
"whether RocksDB is enabled"
ON
)
if (USE_ROCKSDB)
add_definitions("-DARANGODB_ENABLE_ROCKSDB=1")
add_definitions(-DARANGODB_ROCKSDB_VERSION=\"${ROCKSDB_VERSION}\")
include_directories(${ROCKSDB_INCLUDE_DIR})
else ()
set(ROCKSDB_LIBS "")
endif ()
################################################################################
## EXTERNAL PROGRAMS
################################################################################
if (SOLARIS)
set(MAKE gmake)
else ()
set(MAKE make)
endif ()
find_package(PythonInterp 2 REQUIRED)
get_filename_component(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" REALPATH)
################################################################################
## ARCHITECTURE
################################################################################
if (SOLARIS OR NOT CMAKE_SIZEOF_VOID_P)
set(CMAKE_SIZEOF_VOID_P 8)
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
endif ()
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)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(CMAKE_COMPILER_IS_INTEL 1)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_COMPILER_IS_INTEL 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" 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 (SOLARIS)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
set(CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
/lib;/lib64;/lib64;/usr/lib;/usr/lib64;/usr/lib64
)
list(APPEND SYSTEM_LIBRARIES nsl socket)
# force 64bit compile
set(BASE_FLAGS "-I /opt/csw/include -D_REENTRANT -m64 ${BASE_FLAGS}")
endif ()
if (CMAKE_COMPILER_IS_GNUCC)
set(BASE_C_FLAGS "${BASE_C_FLAGS} -std=gnu89")
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR APPLE)
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++11")
endif ()
if (CMAKE_COMPILER_IS_CLANG)
if (APPLE)
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -stdlib=libc++")
add_definitions("-Wno-deprecated-declarations")
else ()
list(APPEND BASE_LIBS atomic)
endif ()
endif ()
# need c++11
set(CMAKE_CXX_STANDARD 11)
include(CheckCXX11Features)
# 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")
# 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")
set(MSVC_LIBS crypt32.lib;WINMM.LIB;Ws2_32.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 ()
################################################################################
## INCLUDE DIRECTORIES
################################################################################
include_directories(${PROJECT_SOURCE_DIR}/3rdParty/linenoise-ng/include)
include_directories(${PROJECT_SOURCE_DIR}/3rdParty/linenoise-ng/src)
include_directories(${PROJECT_SOURCE_DIR}/3rdParty/velocypack/include)
include_directories(${PROJECT_SOURCE_DIR}/3rdParty/rocksdb/rocksdb/include)
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_BINARY_DIR}/lib)
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/arangod)
include_directories(${PROJECT_SOURCE_DIR}/arangosh)
include_directories(${PROJECT_SOURCE_DIR}/lib)
if (CUSTOM_INCLUDES)
include_directories(${CUSTOM_INCLUDES})
endif ()
################################################################################
## TARGET ARCHITECTURE
################################################################################
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)
# mop: core2 (merom) is our absolute minimum!
# SET(TARGET_ARCHITECTURE "merom")
include(OptimizeForArchitecture)
OptimizeForArchitecture()
endif ()
set(BASE_FLAGS "${Vc_ARCHITECTURE_FLAGS} ${BASE_FLAGS}")
endif ()
################################################################################
## BACKTRACE
################################################################################
option(USE_BACKTRACE
"whether we should try to generate c-level stacktraces"
OFF
)
if (USE_BACKTRACE)
if (MSVC)
set(BT_LIBS "Dbghelp" CACHE path "Debug Helper libraries")
else ()
set(BT_LIBS "" CACHE path "Debug Helper libraries")
endif ()
add_definitions("-DARANGODB_ENABLE_BACKTRACE=1")
else ()
set(BT_LIBS "" 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(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")
find_package(FLEX)
find_package(BISON)
endif ()
################################################################################
## 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 ()
################################################################################
## JEMALLOC
################################################################################
find_package(jemalloc)
set(JEMALLOC_DEFAULT_VALUE ${JEMALLOC_FOUND})
if (WINDOWS OR SOLARIS OR USE_TCMALLOC)
set(JEMALLOC_DEFAULT_VALUE OFF)
endif ()
option(USE_JEMALLOC
"use JEMALLOC if the library is available"
${JEMALLOC_DEFAULT_VALUE}
)
set(FORCE_JEMALLOC_LIB "" CACHE STRING "force this library command to link jemalloc")
if (USE_JEMALLOC)
if (NOT JEMALLOC_FOUND)
message(FATAL_ERROR "jemalloc build was requested but jemalloc not found")
endif ()
add_definitions("-DARANGODB_HAVE_JEMALLOC=1")
if (FORCE_JEMALLOC_LIB STREQUAL "")
set(SYS_LIBS ${SYS_LIBS} ${JEMALLOC_jemalloc_LIBRARY})
else ()
set(SYS_LIBS ${SYS_LIBS} ${FORCE_JEMALLOC_LIB})
endif ()
endif ()
################################################################################
## TCMALLOC
################################################################################
option(USE_TCMALLOC
"use TCMALLOC if the library is available"
OFF
)
if (USE_TCMALLOC)
find_package(tcmalloc)
if (TCMALLOC_FOUND)
add_definitions("-DARANGODB_HAVE_TCMALLOC=1")
set(SYS_LIBS ${SYS_LIBS} ${TCMALLOC_tcmalloc_LIBRARY})
message(STATUS "Found TCMALLOC")
else ()
message(STATUS "Missing TCMALLOC")
endif ()
endif ()
if (${USE_JEMALLOC} AND ${USE_TCMALLOC})
MESSAGE(FATAL_ERROR " you mustn't demand for tcmalloc and jemalloc at the same time!")
endif()
################################################################################
## LIBRARY RESOLV
################################################################################
if (NOT WINDOWS)
set(SYS_LIBS ${SYS_LIBS} resolv)
if (NOT DARWIN)
set(SYS_LIBS ${SYS_LIBS} rt)
endif ()
endif ()
################################################################################
## FLAGS
################################################################################
if (VERBOSE)
message(STATUS)
endif ()
# compiler options
if (CMAKE_COMPILER_IS_GNUCC)
if (VERBOSE)
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "-Wall -Wextra -Wno-unused-parameter ${BASE_FLAGS}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C release with debug info flags")
set(CMAKE_CXX_FLAGS "-g" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C++ debug flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C++ release flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C++ release with debug info flags")
elseif (CMAKE_COMPILER_IS_CLANG)
if (VERBOSE)
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "-Wall -Wextra -Wno-unused-parameter ${BASE_FLAGS}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C release with debug info flags")
set(CMAKE_CXX_FLAGS "-g" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C++ debug flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C++ release flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C++ release with debug info flags")
elseif (MSVC)
if (VERBOSE)
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
endif ()
set(CMAKE_C_FLAGS "/MTd" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_C_FLAGS_DEBUG "/D _DEBUG /MTd /Zi /Ob0 /Od /RTC1" CACHE INTERNAL "C++ debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG" CACHE INTERNAL "C++ release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG" 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" CACHE INTERNAL "C++ debug flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG" CACHE INTERNAL "C++ release flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG" CACHE INTERNAL "C++ release with debug info flags")
else ()
# unknown compiler
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "-Wall ${BASE_FLAGS}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C minimal size flags")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C release flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C release with debug info flags")
set(CMAKE_CXX_FLAGS "-g" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C++ debug flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os" CACHE INTERNAL "C++ minimal size flags")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer" CACHE INTERNAL "C++ release flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -fno-omit-frame-pointer" CACHE INTERNAL "C++ release with debug info flags")
endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${BASE_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${BASE_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${BASE_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${BASE_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_FLAGS} ${BASE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_FLAGS} ${BASE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_FLAGS} ${BASE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_FLAGS} ${BASE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_FLAGS} ${BASE_CXX_FLAGS}")
if (VERBOSE)
message(STATUS "Info BASE_FLAGS: ${BASE_FLAGS}")
message(STATUS "Info BASE_C_FLAGS: ${BASE_C_FLAGS}")
message(STATUS "Info BASE_CXX_FLAGS: ${BASE_CXX_FLAGS}")
message(STATUS "Info BASE_LD_FLAGS: ${BASE_LD_FLAGS}")
message(STATUS "Info BASE_LIBS: ${BASE_LIBS}")
message(STATUS)
if (CMAKE_BUILD_TYPE STREQUAL "None")
message(STATUS "Info CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "Info CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Info CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
message(STATUS "Info CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Info CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
message(STATUS "Info CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
message(STATUS "Info CMAKE_C_FLAGS_RELWITHDEBINFO: ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
message(STATUS "Info CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
message(STATUS "Info CMAKE_C_FLAGS_MINSIZEREL: ${CMAKE_C_FLAGS_MINSIZEREL}")
message(STATUS "Info CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL}")
endif ()
message(STATUS "Info CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS)
endif ()
################################################################################
## 3RD PARTY
################################################################################
# 3rdParty exports:
#
# V8_VERSION
# V8_LIBS
# V8_INCLUDE_DIR
#
# ICU_VERSION
# ICU_LIBS
# ICU_INCLUDE_DIR
#
# LIBEV_VERSION
# LIBEV_LIBS
# LIBEV_INCLUDE_DIR
#
# ZLIB_VERSION
# ZLIB_LIBS
# ZLIB_INCLUDE_DIR
add_subdirectory(3rdParty)
################################################################################
## VELOCYPACK
################################################################################
add_definitions("-DVELOCYPACK_XXHASH=1")
foreach (LINK_DIR ${LINK_DIRECTORIES})
link_directories("${LINK_DIR}")
endforeach()
################################################################################
## BOOST
################################################################################
message(STATUS "using 3rdParty BOOST")
option(USE_BOOST_UNITTESTS "use boost unit-tests" ON)
set(Boost_VERSION "1.61.0")
set(Boost_INCLUDE_DIR
"${PROJECT_SOURCE_DIR}/3rdParty/boost/${Boost_VERSION}"
)
if (NOT USE_BOOST_UNITTESTS)
message(STATUS "BOOST unit-tests are disabled")
endif ()
include_directories(${Boost_INCLUDE_DIR})
add_definitions(-DARANGODB_BOOST_VERSION=\"${Boost_VERSION}\")
################################################################################
## ICU
################################################################################
include_directories(${ICU_INCLUDE_DIR})
################################################################################
## LIBEV
################################################################################
include_directories(${LIBEV_INCLUDE_DIR})
add_definitions("-DARANGODB_LIBEV_VERSION=\"${LIBEV_VERSION}\"")
################################################################################
## OPENSSL
################################################################################
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DARANGODB_OPENSSL_VERSION=\"${OPENSSL_VERSION}\")
if (OPENSSL_VERSION)
string(REPLACE "." ";" OPENSSL_VERSION_LIST ${OPENSSL_VERSION})
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
if ("${OPENSSL_VERSION_MAJOR}" GREATER 0 AND "${OPENSSL_VERSION_MINOR}" GREATER 0)
option(USE_OPENSSL_NO_SSL2
"do not use OPENSSL_NO_SSL2"
ON
)
else ()
option(USE_OPENSSL_NO_SSL2
"do not use OPENSSL_NO_SSL2"
OFF
)
endif ()
endif ()
if (USE_OPENSSL_NO_SSL2)
add_definitions(-DOPENSSL_NO_SSL2)
endif ()
################################################################################
## V8
################################################################################
include_directories(${V8_INCLUDE_DIR})
add_definitions("-DARANGODB_V8_VERSION=\"${V8_VERSION}\"")
################################################################################
## ZLIB
################################################################################
include_directories(${ZLIB_INCLUDE_DIR})
add_definitions("-DARANGODB_ZLIB_VERSION=\"${ZLIB_VERSION}\"")
################################################################################
## PATHS, installation, packages
################################################################################
include(ArangoDBInstall)
include(packages/packages)
################################################################################
## ERRORS FILE
################################################################################
if (USE_MAINTAINER_MODE)
set(ERROR_FILES
lib/Basics/voc-errors.h
lib/Basics/voc-errors.cpp
js/common/bootstrap/errors.js
)
set(ERROR_FILES_GEN)
set(ERRORS_DAT lib/Basics/errors.dat)
foreach (m IN LISTS ERROR_FILES)
add_custom_command(
OUTPUT
${CMAKE_SOURCE_DIR}/${m}
COMMAND
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} ./utils/generateErrorfile.sh ./${ERRORS_DAT} ./${m}
DEPENDS
${CMAKE_SOURCE_DIR}/${ERRORS_DAT}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
COMMENT
"Building errors files ${m}"
VERBATIM
)
list(APPEND ERROR_FILES_GEN ${CMAKE_SOURCE_DIR}/${m})
endforeach ()
add_custom_target(errorfiles ALL DEPENDS ${ERROR_FILES_GEN})
endif ()
################################################################################
## MIMETYPES FILE
################################################################################
if (USE_MAINTAINER_MODE)
set(MIMETYPES_FILES
lib/Basics/voc-mimetypes.h
lib/Basics/voc-mimetypes.cpp
)
set(MIMETYPES_FILES_GEN)
set(MIMETYPES_DAT lib/Basics/mimetypes.dat)
foreach (m IN LISTS MIMETYPES_FILES)
add_custom_command(
OUTPUT
${CMAKE_SOURCE_DIR}/${m}
COMMAND
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} ./utils/generateMimetypes.sh ./${MIMETYPES_DAT} ./${m}
DEPENDS
${CMAKE_SOURCE_DIR}/${MIMETYPES_DAT}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
COMMENT
"Building mimetypes files ${m}"
VERBATIM
)
list(APPEND MIMETYPES_FILES_GEN ${CMAKE_SOURCE_DIR}/${m})
endforeach ()
add_custom_target(mimetypes ALL DEPENDS ${MIMETYPES_FILES_GEN})
endif ()
################################################################################
## SUB-PROJECTS
################################################################################
list(INSERT SYSTEM_LIBRARIES 0
${BT_LIBS}
${ZLIB_LIBS}
${ICU_LIBS}
${OPENSSL_LIBRARIES}
${BASE_LIBS}
${CMAKE_DL_LIBS}
${SYS_LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
add_subdirectory(lib)
add_subdirectory(arangosh)
add_subdirectory(arangod)
if (USE_BOOST_UNITTESTS)
add_subdirectory(UnitTests)
endif()
add_subdirectory(Documentation)
add_dependencies(arangobench zlibstatic)
add_dependencies(arangod ev zlibstatic)
add_dependencies(arangodump zlibstatic)
add_dependencies(arangoimp zlibstatic)
add_dependencies(arangorestore zlibstatic)
add_dependencies(arangosh zlibstatic)
if (NOT USE_PRECOMPILED_V8)
# all binaries depend on v8_build because it contains ICU as well
add_dependencies(arangobench v8_build)
add_dependencies(arangod v8_build)
add_dependencies(arangodump v8_build)
add_dependencies(arangoimp v8_build)
add_dependencies(arangorestore v8_build)
add_dependencies(arangosh v8_build)
endif ()
#copy compile commands to source dir
if( EXISTS "${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json" )
message(STATUS "copy compile_commands.json")
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
)
endif()
add_custom_target(packages
DEPENDS ${PACKAGES_LIST}
)