@@ -11,24 +11,21 @@ if (BENCH_SOURCE_DIR STREQUAL BENCH_BINARY_DIR)
11
11
endif ()
12
12
13
13
# Set variables
14
- set (CMAKE_CXX_STANDARD 17 )
14
+ set (CMAKE_CXX_STANDARD 20 )
15
15
set (CMAKE_CXX_STANDARD_REQUIRED ON )
16
16
set (CMAKE_CXX_EXTENSIONS OFF )
17
17
set (CMAKE_CXX_VISIBILITY_PRESET hidden)
18
18
19
- set (CMAKE_C_STANDARD 11)
20
- set (CMAKE_C_STANDARD_REQUIRED ON )
21
- set (CMAKE_C_EXTENSIONS OFF )
22
- set (CMAKE_C_VISIBILITY_PRESET hidden)
23
-
24
19
set (CMAKE_VISIBILITY_INLINES_HIDDEN ON )
25
- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
26
20
set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
27
21
28
22
message ("COMPILE_OPTIONS: ${COMPILE_OPTIONS} " )
29
23
message ("LINK_OPTIONS : ${LINK_OPTIONS} " )
24
+
25
+ include (FetchContent)
26
+
30
27
if (LIBCXX)
31
- add_compile_options (-stdlib=libc++)
28
+ add_compile_options (-stdlib=libc++ -fno-inline )
32
29
add_link_options (-stdlib=libc++ -lc++abi)
33
30
endif ()
34
31
@@ -40,7 +37,6 @@ set(UTIL_HEADERS
40
37
find_package (benchmark QUIET )
41
38
42
39
if (NOT BENCHMARK_FOUND)
43
- include (FetchContent)
44
40
if (NOT BENCHMARK_FOUND)
45
41
set (BENCHMARK_ENABLE_TESTING NO )
46
42
FetchContent_Declare(
@@ -52,4 +48,108 @@ if (NOT BENCHMARK_FOUND)
52
48
endif ()
53
49
endif ()
54
50
55
- add_subdirectory (future)
51
+ function (add_bench BENCH_NAME)
52
+ add_executable (${BENCH_NAME} ${CMAKE_CURRENT_SOURCE_DIR} /test /${BENCH_NAME} /${BENCH_NAME} .cpp)
53
+ target_link_libraries (${BENCH_NAME}
54
+ PRIVATE ${GTEST_BOTH_LIBRARIES}
55
+ PRIVATE benchmark::benchmark
56
+ PRIVATE ${PROJECT_NAME}
57
+ )
58
+
59
+ if (STD)
60
+ target_compile_definitions (${BENCH_NAME} PUBLIC STD_ENABLE)
61
+ endif ()
62
+ if (YACLIB)
63
+ target_compile_definitions (${BENCH_NAME} PUBLIC YACLIB_ENABLE)
64
+ endif ()
65
+ if (CPPCORO)
66
+ target_compile_definitions (${BENCH_NAME} PUBLIC CPPCORO_ENABLE)
67
+ endif ()
68
+ if (FOLLY)
69
+ target_compile_definitions (${BENCH_NAME} PUBLIC FOLLY_ENABLE)
70
+ endif ()
71
+ if (ARANGODB)
72
+ target_compile_definitions (${BENCH_NAME} PUBLIC ARANGODB_ENABLE)
73
+ endif ()
74
+ if (BOOST_THREAD)
75
+ target_compile_definitions (${BENCH_NAME} PUBLIC BOOST_THREAD_ENABLE)
76
+ endif ()
77
+ if (QT)
78
+ target_compile_definitions (${BENCH_NAME} PUBLIC QT_ENABLE)
79
+ endif ()
80
+ if (EXPERIMENTAL)
81
+ target_compile_definitions (${BENCH_NAME} PUBLIC EXPERIMENTAL_ENABLE)
82
+ endif ()
83
+
84
+ add_test (NAME ${BENCH_NAME} COMMAND ${BENCH_NAME} )
85
+ endfunction ()
86
+
87
+ find_package (Threads REQUIRED)
88
+ link_libraries (Threads::Threads)
89
+ include_directories (vendor)
90
+
91
+ if (YACLIB) # v2022.08.31
92
+ FetchContent_Declare(yaclib
93
+ GIT_REPOSITORY https://github.com/YACLib/YACLib.git
94
+ GIT_TAG "${YACLIB} "
95
+ )
96
+ list (APPEND YACLIB_FLAGS "CORO" )
97
+ FetchContent_MakeAvailable(yaclib)
98
+ link_libraries (yaclib)
99
+ endif ()
100
+ if (FOLLY)
101
+ find_package (glog CONFIG REQUIRED) # Ad-hoc
102
+ find_package (folly CONFIG REQUIRED)
103
+ include_directories (${FOLLY_INCLUDE_DIR} )
104
+ link_libraries (Folly::folly)
105
+ endif ()
106
+ if (ARANGODB)
107
+ add_library (arangodb STATIC
108
+ ${CMAKE_CURRENT_SOURCE_DIR} /vendor/arangodb/futures/Future.cpp
109
+ )
110
+ endif ()
111
+ if (BOOST_THREAD)
112
+ find_package (Boost COMPONENTS thread REQUIRED)
113
+ link_libraries (Boost::thread)
114
+ endif ()
115
+ if (QT)
116
+ find_package (Qt6 COMPONENTS Concurrent REQUIRED)
117
+ link_libraries (Qt6::Concurrent)
118
+ endif ()
119
+ if (EXPERIMENTAL)
120
+ add_link_options (-lc++experimental)
121
+ endif ()
122
+ if (CPPCORO)
123
+ FetchContent_Declare(cppcoro
124
+ GIT_REPOSITORY https://github.com/YACLib/cppcoro-for-benchmark.git
125
+ GIT_TAG main
126
+ )
127
+ FetchContent_MakeAvailable(cppcoro)
128
+ link_libraries (cppcoro)
129
+ endif ()
130
+
131
+ macro (add_files)
132
+ set (BENCH_HEADERS ${BENCH_HEADERS} PARENT_SCOPE)
133
+ set (BENCH_SOURCES ${BENCH_SOURCES} PARENT_SCOPE)
134
+ endmacro ()
135
+
136
+ add_subdirectory (bind)
137
+ add_subdirectory (bench)
138
+ add_library (${PROJECT_NAME} STATIC )
139
+
140
+ target_sources (${PROJECT_NAME}
141
+ PRIVATE ${BENCH_SOURCES}
142
+ PRIVATE ${BENCH_HEADERS}
143
+ )
144
+
145
+ target_include_directories (${PROJECT_NAME}
146
+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
147
+ )
148
+
149
+ target_link_libraries (${PROJECT_NAME}
150
+ PRIVATE ${GTEST_BOTH_LIBRARIES}
151
+ PUBLIC benchmark::benchmark
152
+ )
153
+
154
+ add_bench(future)
155
+ add_bench(coro)
0 commit comments