-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
166 lines (145 loc) · 6.73 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
# Copyright Louis Dionne 2017
# Distributed under the Boost Software License, Version 1.0.
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
#=============================================================================
# Setup required packages
#=============================================================================
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
include(ExternalProject)
ExternalProject_Add(install-Hana EXCLUDE_FROM_ALL 1
URL https://github.com/boostorg/hana/archive/develop.zip
TIMEOUT 120
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies/hana"
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
TEST_COMMAND "" # Disable test step
UPDATE_COMMAND "" # Disable source work-tree update
)
ExternalProject_Get_Property(install-Hana SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
include(ExternalProject)
ExternalProject_Add(install-Brigand EXCLUDE_FROM_ALL 1
URL https://github.com/edouarda/brigand/archive/master.zip
TIMEOUT 120
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies/brigand"
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
TEST_COMMAND "" # Disable test step
UPDATE_COMMAND "" # Disable source work-tree update
)
ExternalProject_Get_Property(install-Brigand SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
include(ExternalProject)
ExternalProject_Add(install-Metal EXCLUDE_FROM_ALL 1
URL https://github.com/brunocodutra/metal/archive/master.zip
TIMEOUT 120
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies/metal"
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
TEST_COMMAND "" # Disable test step
UPDATE_COMMAND "" # Disable source work-tree update
)
ExternalProject_Get_Property(install-Metal SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
include(ExternalProject)
ExternalProject_Add(install-CallableTraits EXCLUDE_FROM_ALL 1
URL https://github.com/badair/callable_traits/archive/master.zip
TIMEOUT 120
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies/callable_traits"
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
TEST_COMMAND "" # Disable test step
UPDATE_COMMAND "" # Disable source work-tree update
)
ExternalProject_Get_Property(install-CallableTraits SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
include(ExternalProject)
ExternalProject_Add(install-Dyno EXCLUDE_FROM_ALL 1
URL https://github.com/ldionne/dyno/archive/master.zip
TIMEOUT 120
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies/dyno"
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
TEST_COMMAND "" # Disable test step
UPDATE_COMMAND "" # Disable source work-tree update
)
ExternalProject_Get_Property(install-Dyno SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
add_custom_target(install-dependencies DEPENDS install-Hana install-Brigand
install-Metal install-CallableTraits
install-Dyno)
#=============================================================================
# Setup compiler flags
#=============================================================================
include(CheckCXXCompilerFlag)
macro(append_cxx_flag testname flag)
check_cxx_compiler_flag(${flag} ${testname})
if (${testname})
add_compile_options(${flag})
endif()
endmacro()
append_cxx_flag(HAS_W_FLAG -W)
append_cxx_flag(HAS_WALL_FLAG -Wall)
append_cxx_flag(HAS_WEXTRA_FLAG -Wextra)
append_cxx_flag(HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
append_cxx_flag(HAS_WNO_UNUSED_LOCAL_TYPEDEFS_FLAG -Wno-unused-local-typedefs)
append_cxx_flag(HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
append_cxx_flag(HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
append_cxx_flag(HAS_STDCXX1Y_FLAG -std=c++1z)
append_cxx_flag(HAS_PEDANTIC_FLAG -pedantic)
append_cxx_flag(HAS_WNO_GNU_STRING_UDL -Wno-gnu-string-literal-operator-template)
append_cxx_flag(HAS_WNO_UNUSED_VARIABLE -Wno-unused-variable)
#=============================================================================
# Setup code samples
#=============================================================================
enable_testing()
add_custom_target(samples)
file(GLOB CODE_SAMPLES code/*.cpp)
foreach(_file IN LISTS CODE_SAMPLES)
file(RELATIVE_PATH _target ${CMAKE_CURRENT_SOURCE_DIR}/code ${_file})
string(REPLACE ".cpp" "" _target "${_target}")
add_executable(sample.${_target} "${_file}")
target_compile_options(sample.${_target} PRIVATE -O3)
add_dependencies(samples sample.${_target})
add_test(sample.${_target} sample.${_target})
endforeach()
add_custom_target(check ALL
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS samples
COMMENT "Build all the samples and then run them.")
#=============================================================================
# Setup benchmarks
#=============================================================================
include(metabench)
add_custom_target(benchmarks)
foreach(target hana hana.extensible std.function std.unordered_map std.unordered_map.enum std.array.enum)
metabench_add_dataset(benchmark.callbacks.${target}
benchmark/callbacks.${target}.cpp.erb
"[1, 2, 4, 6, 8, 10]"
NAME ${target}
ENV "{maxn: 10, iterations: 10_000_000}")
target_compile_options(benchmark.callbacks.${target} PRIVATE -O3 -flto)
endforeach()
metabench_add_chart(benchmark.callbacks
DATASETS benchmark.callbacks.hana
benchmark.callbacks.std.function
benchmark.callbacks.std.unordered_map
benchmark.callbacks.std.unordered_map.enum
benchmark.callbacks.std.array.enum
ASPECT EXECUTION_TIME
XLABEL "Number of events triggered (x 10M)"
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/benchmark/callbacks.html)
metabench_add_chart(benchmark.callbacks.extensible
DATASETS benchmark.callbacks.hana.extensible
benchmark.callbacks.std.unordered_map
ASPECT EXECUTION_TIME
XLABEL "Number of events triggered (x 10M)"
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/benchmark/callbacks.extensible.html)
add_dependencies(benchmarks benchmark.callbacks benchmark.callbacks.extensible)