-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
157 lines (123 loc) · 4.98 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
cmake_minimum_required (VERSION 3.1)
set(PROJECT "dariadb")
project (${PROJECT} VERSION 0.5.0)
IF(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE is not set, set to default = RELWITHDEBINFO")
SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
ENDIF()
MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
option(DARIADB_ENABLE_TESTS "Enable testing of the dariadb." ON)
option(DARIADB_ENABLE_INTEGRATION_TESTS "Enable integration test." ON)
option(DARIADB_ENABLE_SERVER "Enable build dariadb server." ON)
option(DARIADB_ENABLE_BENCHMARKS "Enable build dariadb benchmarks." ON)
option(DARIADB_ENABLE_SAMPLES "Build dariadb sample programs." ON)
option(DARIADB_ENABLE_DOUBLECHECKS "More checks in code." OFF)
option(DARIADB_ASAN_UBSAN "Enable address & undefined behavior sanitizer for binary." OFF)
option(DARIADB_MSAN "Enable memory sanitizer for binary." OFF)
option(DARIADB_SYSTEM_JEMALLOC "Use jemalloc installed in the system." ON)
if((DARIADB_ASAN_UBSAN AND DARIADB_MSAN))
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously.")
endif()
MESSAGE(STATUS "Options: ")
MESSAGE(STATUS "DARIADB_ENABLE_TESTS - " ${DARIADB_ENABLE_TESTS})
MESSAGE(STATUS "DARIADB_ENABLE_INTEGRATION_TESTS - " ${DARIADB_ENABLE_INTEGRATION_TESTS})
MESSAGE(STATUS "DARIADB_ENABLE_SERVER - " ${DARIADB_ENABLE_SERVER})
MESSAGE(STATUS "DARIADB_ENABLE_BENCHMARKS - " ${DARIADB_ENABLE_BENCHMARKS})
MESSAGE(STATUS "DARIADB_ENABLE_SAMPLES - " ${DARIADB_ENABLE_SAMPLES})
MESSAGE(STATUS "DARIADB_ENABLE_DOUBLECHECKS - " ${DARIADB_ENABLE_DOUBLECHECKS})
MESSAGE(STATUS "DARIADB_MSAN - " ${DARIADB_MSAN})
MESSAGE(STATUS "DARIADB_ASAN_UBSAN - " ${DARIADB_ASAN_UBSAN})
MESSAGE(STATUS "DARIADB_SYSTEM_JEMALLOC - " ${DARIADB_SYSTEM_JEMALLOC})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddCXXCompilerFlag)
include(CompillerSettings)
include(CompillerSettings)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_DEP system filesystem date_time)
IF(DARIADB_ENABLE_DOUBLECHECKS)
add_definitions(-DDOUBLE_CHECKS)
ENDIF()
IF(WIN32 AND MSVC)
find_package(Boost 1.54.0 COMPONENTS ${BOOST_DEP} REQUIRED)
else()
set(BOOST_DEP ${BOOST_DEP} program_options)
find_package(Boost REQUIRED ${BOOST_DEP})
ENDIF()
########## BOOST
IF(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
SET(DARIADB_LIB_PATH ${Boost_LIBRARY_DIRS}
CACHE STRING "dariadb libs path.")
else()
MESSAGE(FATAL_ERROR "boost not found")
EXIT()
ENDIF()
##### THREADS
find_package (Threads)
##### MISC
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include_directories(extern)
include_directories(extern/spdlog/include)
include_directories(extern/stx-btree/include)
UNSET(JEMALLOC_LIBS)
if(DARIADB_SYSTEM_JEMALLOC)
include(FindJeMalloc)
if(JEMALLOC_FOUND)
MESSAGE(STATUS "jemalloc-dev - found")
SET(JEMALLOC_LIBS ${JEMALLOC_LIBRARIES})
endif(JEMALLOC_FOUND)
else(DARIADB_SYSTEM_JEMALLOC)
MESSAGE(STATUS "LOCAL JEMALLOC")
set(BuildTests OFF)
add_subdirectory(extern/jemalloc-cmake)
include_directories(extern/jemalloc-cmake/include/jemalloc)
if(MSVC)
include_directories(extern/jemalloc-cmake/include/msvc_compat)
endif()
SET(JEMALLOC_LIBS jemallocso)
set_target_properties(jemalloc_jet PROPERTIES FOLDER Extern)
set_target_properties(jemalloc_util_int_test PROPERTIES FOLDER Extern)
set_target_properties(jemallocso PROPERTIES FOLDER Extern)
set_target_properties(jemalloc PROPERTIES FOLDER Extern)
endif(DARIADB_SYSTEM_JEMALLOC)
if(DARIADB_ENABLE_TESTS)
cmake_policy(SET CMP0048 OLD)
add_subdirectory(extern/googletest)
set_target_properties(gtest PROPERTIES FOLDER Extern)
set_target_properties(gtest_main PROPERTIES FOLDER Extern)
set_target_properties(gmock PROPERTIES FOLDER Extern)
set_target_properties(gmock_main PROPERTIES FOLDER Extern)
endif(DARIADB_ENABLE_TESTS)
if(DARIADB_ENABLE_BENCHMARKS)
set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(extern/benchmark)
include_directories(extern/benchmark/include)
set_target_properties(benchmark PROPERTIES FOLDER Extern)
endif(DARIADB_ENABLE_BENCHMARKS)
add_subdirectory(extern/libsqlite3)
include_directories(extern/libsqlite3)
set_target_properties(sqlite3 PROPERTIES FOLDER Extern)
SET(DARIADB_STORAGE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
CACHE STRING "dariadb storage include dir for storage engine.")
add_subdirectory (libdariadb)
if(DARIADB_ENABLE_SERVER)
add_subdirectory (network)
endif()
if (DARIADB_ENABLE_TESTS)
enable_testing()
add_subdirectory(unittests)
endif()
if(DARIADB_ENABLE_BENCHMARKS)
add_subdirectory (microbenchmarks)
add_subdirectory (benchmarks)
endif()
if(DARIADB_ENABLE_SAMPLES)
add_subdirectory(examples)
endif()