-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
152 lines (118 loc) · 6.12 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
cmake_minimum_required(VERSION 2.8)
project(milliways)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
message(STATUS "Enabled C++11 for compiler ${CMAKE_CXX_COMPILER}.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
message(STATUS "Enabled C++0X for compiler ${CMAKE_CXX_COMPILER}.")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++0X or C++11 support. Please use a different C++ compiler.")
endif()
if(MSVC)
add_definitions(-DNOMINMAX)
endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
include(CheckCXXSourceCompiles)
include(CheckTypeSize)
check_cxx_source_compiles("
#include <memory>
int main() { std::shared_ptr<int> p; return 0; }
" HAVE_STD_SHARED_PTR)
check_cxx_source_compiles("
#include <tr1/memory>
int main() { std::tr1::shared_ptr<int> p; return 0; }
" HAVE_STD_TR1_SHARED_PTR)
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
int main() { boost::shared_ptr<int> p; return 0; }
" HAVE_BOOST_SHARED_PTR)
check_cxx_source_compiles("
#include <stdint.h>
#include <stddef.h>
template <typename T>
struct Traits;
template <>
struct Traits<uint8_t>
{ typedef uint8_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint16_t>
{ typedef uint16_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint32_t>
{ typedef uint32_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint64_t>
{ typedef uint64_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<size_t>
{ typedef size_t type; static size_t size() { return sizeof(type); } };
int main() { size_t size = Traits<size_t>::size(); size++; }
" ALLOWS_TEMPLATED_SIZE_T)
check_cxx_source_compiles("
#include <stdint.h>
#include <stddef.h>
template <typename T>
struct Traits;
template <>
struct Traits<uint8_t>
{ typedef uint8_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint16_t>
{ typedef uint16_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint32_t>
{ typedef uint32_t type; static size_t size() { return sizeof(type); } };
template <>
struct Traits<uint64_t>
{ typedef uint64_t type; static size_t size() { return sizeof(type); } };
int main() { size_t size = Traits<size_t>::size(); size++; }
" DOESNT_NEED_TEMPLATED_SIZE_T)
check_cxx_source_compiles("
#include <vector>
int main() { typename std::vector<int> v; v.push_back(1); }
" ALLOWS_TYPENAME_OUTSIDE_TEMPLATES)
SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T LANGUAGE CXX)
CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T LANGUAGE CXX)
CHECK_TYPE_SIZE(short SIZEOF_SHORT LANGUAGE CXX)
CHECK_TYPE_SIZE(int SIZEOF_INT LANGUAGE CXX)
CHECK_TYPE_SIZE(long SIZEOF_LONG LANGUAGE CXX)
CHECK_TYPE_SIZE("unsigned long" SIZEOF_UNSIGNED_LONG LANGUAGE CXX)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG LANGUAGE CXX)
CHECK_TYPE_SIZE(float SIZEOF_FLOAT LANGUAGE CXX)
CHECK_TYPE_SIZE(double SIZEOF_DOUBLE LANGUAGE CXX)
SET(CMAKE_EXTRA_INCLUDE_FILES)
configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
configure_file (config.h.cmake ${PROJECT_SOURCE_DIR}/config.h )
#set(SOURCE_FILES main.cpp BlockStorage.impl.hpp BlockStorage.h LRUCache.impl.hpp LRUCache.h ordered_map.h ordered_map.impl.hpp)
#add_executable(milliways ${SOURCE_FILES})
set(SOURCE_FILES test_ordered_map.cpp catch.hpp ordered_map.h ordered_map.impl.hpp)
add_executable(test_ordered_map ${SOURCE_FILES})
set(SOURCE_FILES test_lrucache.cpp catch.hpp ordered_map.h ordered_map.impl.hpp LRUCache.h LRUCache.impl.hpp)
add_executable(test_lrucache ${SOURCE_FILES})
set(SOURCE_FILES test_btree_btreenode.cpp catch.hpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp)
add_executable(test_btree_btreenode ${SOURCE_FILES})
set(SOURCE_FILES test_btree_filestorage.cpp catch.hpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp)
add_executable(test_btree_filestorage ${SOURCE_FILES})
set(SOURCE_FILES test_btree_ops.cpp catch.hpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp)
add_executable(test_btree_ops ${SOURCE_FILES})
set(SOURCE_FILES test_kv.cpp catch.hpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp KeyValueStore.h KeyValueStore.impl.hpp)
add_executable(test_kv ${SOURCE_FILES})
set(SOURCE_FILES test_kv2.cpp catch.hpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp KeyValueStore.h KeyValueStore.impl.hpp)
add_executable(test_kv2 ${SOURCE_FILES})
set(SOURCE_FILES test_shptr.cpp catch.hpp Utils.h Utils.impl.hpp)
add_executable(test_shptr ${SOURCE_FILES})
set(SOURCE_FILES benchmark_kv.cpp Utils.h Utils.impl.hpp Seriously.h Seriously.impl.hpp BlockStorage.h BlockStorage.impl.hpp BTreeCommon.h BTreeNode.h BTreeNode.impl.hpp BTree.h BTree.impl.hpp BTreeFileStorage.h BTreeFileStorage.impl.hpp KeyValueStore.h KeyValueStore.impl.hpp)
add_executable(benchmark_kv ${SOURCE_FILES})
if (MSVC)
target_link_libraries(benchmark_kv Ws2_32)
target_link_libraries(test_btree_filestorage Ws2_32)
target_link_libraries(test_btree_ops Ws2_32)
target_link_libraries(test_kv Ws2_32)
target_link_libraries(test_kv2 Ws2_32)
endif()