forked from arangodb/arangodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
1068 lines (865 loc) · 36 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.2)
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 ()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "deployment target for MacOSX; adjust to your sysem")
endif ()
if (WIN32)
project(arangodb3 CXX C)
else ()
project(arangodb3 CXX C ASM)
endif ()
# required for clang completion in editors
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# 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)
# enable enterprise features
set(ENTERPRISE_INCLUDE_DIR "enterprise")
option(USE_ENTERPRISE "enable enterprise build" OFF)
if (USE_ENTERPRISE)
add_subdirectory(enterprise)
endif ()
option(DEBUG_SYNC_REPLICATION "Enable debug code to enable synchronous replication debugging" OFF)
if (DEBUG_SYNC_REPLICATION)
add_definitions("-DDEBUG_SYNC_REPLICATION=1")
endif ()
# ------------------------------------------------------------------------------
# VERSION information
# ------------------------------------------------------------------------------
set(ARANGODB_VERSION_MAJOR "3")
set(ARANGODB_VERSION_MINOR "3")
set(ARANGODB_VERSION_REVISION "devel")
set(ARANGODB_PACKAGE_REVISION "1")
# version for the windows rc file needs to be numeric:
if (ARANGODB_VERSION_REVISION GREATER -1)
set(ARANGODB_NUMERIC_VERSION_REVISION "${ARANGODB_VERSION_REVISION}")
else()
set(ARANGODB_NUMERIC_VERSION_REVISION 1337)
endif()
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 "info@arangodb.com")
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 "hackers@arangodb.com")
set(ARANGODB_FRIENDLY_STRING "ArangoDB - the native multi-model NoSQL 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_EXPORT_FRIENDLY_STRING "arangoexport - datae xporter")
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_ARANGOEXPORT arangoexport)
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_CACHE_SUITE cache_suite)
set(TEST_GEO_SUITE geo_suite)
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
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Installation/Pipeline/Jenkinsfile.groovy.in"
"${CMAKE_CURRENT_SOURCE_DIR}/Installation/Pipeline/Jenkinsfile.groovy"
NEWLINE_STYLE UNIX @ONLY
)
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
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/js/common/tests/shell/shell-database.js.in"
"${CMAKE_CURRENT_SOURCE_DIR}/js/common/tests/shell/shell-database.js"
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)
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(DARWIN TRUE)
endif ()
find_program(BREW brew)
endif ()
# ------------------------------------------------------------------------------
# user options
# ------------------------------------------------------------------------------
if (WINDOWS)
SET(USE_JEMALLOC OFF)
else ()
option(
USE_JEMALLOC
"use jemalloc memory allocator"
ON
)
endif ()
if (CROSS_COMPILING)
# curently off, need additional params to configure like --hoast=triple <params>
SET(USE_JEMALLOC OFF)
endif()
################################################################################
## EXTERNAL PROGRAMS
################################################################################
if (SOLARIS)
set(MAKE gmake)
else ()
set(MAKE make)
endif ()
find_package(PythonInterp 2 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(
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
################################################################################
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)
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)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.4")
message(FATAL_ERROR "ArangoDB requires GCC 5.4 or newer.")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.9.9")
message(FATAL_ERROR "ArangoDB doesn't support GCC 7.0 yet.")
endif()
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 ()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3")
message(FATAL_ERROR "ArangoDB requires clang 3.3 or newer.")
endif()
list(APPEND BASE_LIBS atomic)
endif ()
endif ()
# need c++11
# XXX this should really be set on a per target level using cmake compile_features capabilties
set(CMAKE_CXX_STANDARD 11)
# 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 Shlwapi.lib;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 ()
# 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_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/v5.6.X/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
################################################################################
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)
# mop: core2 (merom) is our absolute minimum!
# SET(TARGET_ARCHITECTURE "merom")
include(OptimizeForArchitecture)
OptimizeForArchitecture()
endif ()
if (USE_SSE4_2)
set(ARANGODB_SSE42_FLAGS "-msse4.2")
endif ()
set(BASE_FLAGS "${Vc_COMPILE_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")
if (CMAKE_COMPILER_IS_GNUCC)
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(MARKDOWN_EXECUTABLE markdown)
find_program(HTML2TEXT_EXECUTABLE html2text)
find_program(SED_EXECUTABLE sed)
find_program(AWK_EXECUTABLE awk)
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 ()
################################################################################
## 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
# ------------------------------------------------------------------------------
if (USE_JEMALLOC)
add_subdirectory(3rdParty/jemalloc)
add_definitions("-DARANGODB_HAVE_JEMALLOC=1")
include_directories("${JEMALLOC_HOME}/include")
link_directories("${JEMALLOC_HOME}/lib")
set(SYS_LIBS ${SYS_LIBS} ${JEMALLOC_LIB})
if (LINUX OR DARWIN)
add_definitions("-DARANGODB_MMAP_JEMALLOC=1")
endif ()
endif ()
# ------------------------------------------------------------------------------
# NDEBUG
# ------------------------------------------------------------------------------
if ( NOT USE_MAINTAINER_MODE AND ( CMAKE_BUILD_TYPE STREQUAL "Release" OR
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR
CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"
)
)
add_definitions(-DNDEBUG)
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 -D_DEBUG=1" 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 -Wnon-virtual-dtor" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D_DEBUG=1" 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 -D_DEBUG=1" 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 -Wnon-virtual-dtor" CACHE INTERNAL "default C++ compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D_DEBUG=1" 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" 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" 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")
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}")
else ()
message(STATUS "Info CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}: ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
message(STATUS "Info CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
endif ()
message(STATUS "Info CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS)
endif ()
if(ARANGODB_DEBUG_CMAKE)
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
message( STATUS "Found Define: " ${d} )
endforeach()
message( STATUS "DirDefs: ${DirDefs}" )
endif()
################################################################################
## 3RD PARTY
################################################################################
# 3rdParty exports:
#
# V8_VERSION
# V8_LIBS
# V8_INCLUDE_DIR
#
# ICU_VERSION
# ICU_LIBS
# ICU_INCLUDE_DIR
#
# ZLIB_VERSION
# ZLIB_LIBS
# ZLIB_INCLUDE_DIR
add_definitions(-DBOOST_ALL_NO_LIB=1) #disable boost autolink on windows
add_subdirectory(3rdParty)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/boost)
add_definitions("-DARANGODB_BOOST_VERSION=\"${BOOST_VERSION}\"")
# ------------------------------------------------------------------------------
# RocksDB
# ------------------------------------------------------------------------------
add_subdirectory(3rdParty/rocksdb)
add_definitions(-DARANGODB_ROCKSDB_VERSION=\"${ROCKSDB_VERSION}\")
include_directories(${ROCKSDB_INCLUDE_DIR})
set(ROCKSDB_LIBS rocksdb;snappystatic)
add_dependencies(rocksdb snappystatic)
if (USE_JEMALLOC)
add_dependencies(rocksdb jemalloc)
endif ()
################################################################################
## VELOCYPACK
################################################################################
add_definitions("-DVELOCYPACK_XXHASH=1")
set(V8_LINK_DIRECTORIES "${LINK_DIRECTORIES}" CACHE INTERNAL "" FORCE)
foreach (LINK_DIR ${V8_LINK_DIRECTORIES})
link_directories("${LINK_DIR}")
endforeach()
################################################################################
## ICU
################################################################################
include_directories(${ICU_INCLUDE_DIR})
################################################################################
## OPENSSL
################################################################################
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DARANGODB_OPENSSL_VERSION=\"${OPENSSL_VERSION}\")
add_definitions(-DOPENSSL_VERSION_MAJOR=${OPENSSL_VERSION_MAJOR})
add_definitions(-DOPENSSL_VERSION_MINOR=${OPENSSL_VERSION_MINOR})
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}\"")
################################################################################
## cURL
################################################################################
add_definitions(-DCURL_STATICLIB=1)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/curl/curl-7.50.3/include/
${CMAKE_CURRENT_BINARY_DIR}/3rdParty/curl/curl-7.50.3/include/curl/
)
################################################################################
## PATHS, installation, packages, frontend
################################################################################
if (MSVC)
# versioning
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Installation/Windows/version")
include(generate_product_version)
endif()
include(ArangoDBInstall)
include(frontend/aardvark)
if (NOT(SKIP_PACKAGING))
include(packages/packages)
endif()
################################################################################
## 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} ./utils/generateErrorfile.py ./${ERRORS_DAT} ./${m}.tmp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ./${m}.tmp ./${m}
COMMAND ${CMAKE_COMMAND} -E remove ./${m}.tmp
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})
set(EXIT_CODE_FILES
lib/Basics/exitcodes.h
lib/Basics/exitcodes.cpp
js/common/bootstrap/exitcodes.js
Installation/Windows/Plugins/exitcodes.nsh
)
set(EXIT_CODE_FILES_GEN)
set(EXIT_CODES_DAT lib/Basics/exitcodes.dat)
foreach (m IN LISTS EXIT_CODE_FILES)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${m}
COMMAND ${PYTHON_EXECUTABLE} ./utils/generateExitCodesFiles.py ./${EXIT_CODES_DAT} ./${m}.tmp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ./${m}.tmp ./${m}
COMMAND ${CMAKE_COMMAND} -E remove ./${m}.tmp
DEPENDS ${CMAKE_SOURCE_DIR}/${EXIT_CODES_DAT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building exitcode files ${m}"
VERBATIM
)
list(APPEND EXIT_CODE_FILES_GEN ${CMAKE_SOURCE_DIR}/${m})
endforeach ()
add_custom_target(exitcodefiles ALL DEPENDS ${EXIT_CODE_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} ./utils/generateMimetypes.py ./${MIMETYPES_DAT} ./${m}.tmp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ./${m}.tmp ./${m}
COMMAND ${CMAKE_COMMAND} -E remove ./${m}.tmp
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}
libcurl
${BASE_LIBS}
${SYS_LIBS}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
add_subdirectory(lib)
add_subdirectory(arangosh)
add_subdirectory(arangod)
add_subdirectory(Documentation)