|
1 | | -include(ExternalProject) |
2 | | -include(CheckCXXCompilerFlag) |
3 | | - |
4 | 1 | #============================================================================== |
5 | 2 | # Build Google Benchmark |
6 | 3 | #============================================================================== |
7 | 4 |
|
| 5 | +include(ExternalProject) |
8 | 6 | set(BENCHMARK_COMPILE_FLAGS |
9 | 7 | -Wno-unused-command-line-argument |
10 | 8 | -nostdinc++ |
@@ -39,173 +37,4 @@ ExternalProject_Add(google-benchmark |
39 | 37 | -DBENCHMARK_USE_LIBCXX:BOOL=ON |
40 | 38 | -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) |
41 | 39 |
|
42 | | -#============================================================================== |
43 | | -# Benchmark tests configuration |
44 | | -#============================================================================== |
45 | | -add_custom_target(cxx-benchmarks) |
46 | | -set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
47 | | -set(BENCHMARK_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark) |
48 | | - |
49 | | -add_library( cxx-benchmarks-flags INTERFACE) |
50 | | - |
51 | | -# TODO(cmake): remove. This is a workaround to prevent older versions of GCC |
52 | | -# from failing the configure step because they don't support C++23. |
53 | | -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13.0") |
54 | | - return() |
55 | | -endif() |
56 | | -#TODO(cmake): remove the `add_compile_options`. Currently we have to explicitly |
57 | | -# pass the `std:c++latest` flag on Windows to work around an issue where |
58 | | -# requesting `cxx_std_23` results in an error -- somehow CMake fails to |
59 | | -# translate the `c++23` flag into `c++latest`, and the highest numbered C++ |
60 | | -# version that MSVC flags support is C++20. |
61 | | -if (MSVC) |
62 | | - add_compile_options(/std:c++latest) |
63 | | -# ibm-clang does not recognize the cxx_std_23 flag, so use this as a temporary |
64 | | -# workaround on AIX as well. |
65 | | -elseif (${CMAKE_SYSTEM_NAME} MATCHES "AIX") |
66 | | - add_compile_options(-std=c++23) |
67 | | -else() |
68 | | - target_compile_features( cxx-benchmarks-flags INTERFACE cxx_std_23) |
69 | | -endif() |
70 | | - |
71 | | -target_compile_options(cxx-benchmarks-flags INTERFACE -fsized-deallocation -nostdinc++ |
72 | | - ${SANITIZER_FLAGS} -Wno-user-defined-literals -Wno-suggest-override) |
73 | | -target_include_directories(cxx-benchmarks-flags INTERFACE "${LIBCXX_GENERATED_INCLUDE_DIR}" |
74 | | - INTERFACE "${BENCHMARK_INSTALL_DIR}/include" |
75 | | - INTERFACE "${LIBCXX_SOURCE_DIR}/test/support") |
76 | | -target_link_options(cxx-benchmarks-flags INTERFACE -lm -nostdlib++ |
77 | | - "-L${BENCHMARK_INSTALL_DIR}/lib" "-L${BENCHMARK_INSTALL_DIR}/lib64" |
78 | | - ${SANITIZER_FLAGS}) |
79 | | - |
80 | | -set(libcxx_benchmark_targets) |
81 | | - |
82 | | -function(add_benchmark_test name source_file) |
83 | | - set(libcxx_target ${name}_libcxx) |
84 | | - list(APPEND libcxx_benchmark_targets ${libcxx_target}) |
85 | | - add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file}) |
86 | | - target_link_libraries(${libcxx_target} PRIVATE cxx-benchmarks-flags) |
87 | | - add_dependencies(${libcxx_target} cxx google-benchmark) |
88 | | - add_dependencies(cxx-benchmarks ${libcxx_target}) |
89 | | - if (LIBCXX_ENABLE_SHARED) |
90 | | - target_link_libraries(${libcxx_target} PRIVATE cxx_shared) |
91 | | - else() |
92 | | - target_link_libraries(${libcxx_target} PRIVATE cxx_static) |
93 | | - endif() |
94 | | - target_link_libraries(${libcxx_target} PRIVATE cxx_experimental benchmark) |
95 | | - if (LLVM_USE_SANITIZER) |
96 | | - target_link_libraries(${libcxx_target} PRIVATE -ldl) |
97 | | - endif() |
98 | | - set_target_properties(${libcxx_target} |
99 | | - PROPERTIES |
100 | | - OUTPUT_NAME "${name}.bench.out" |
101 | | - RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" |
102 | | - CXX_EXTENSIONS NO) |
103 | | - cxx_link_system_libraries(${libcxx_target}) |
104 | | -endfunction() |
105 | | - |
106 | | - |
107 | | -#============================================================================== |
108 | | -# Register Benchmark tests |
109 | | -#============================================================================== |
110 | | -set(BENCHMARK_TESTS |
111 | | - algorithms.partition_point.bench.cpp |
112 | | - algorithms/count.bench.cpp |
113 | | - algorithms/equal.bench.cpp |
114 | | - algorithms/find.bench.cpp |
115 | | - algorithms/fill.bench.cpp |
116 | | - algorithms/for_each.bench.cpp |
117 | | - algorithms/lexicographical_compare.bench.cpp |
118 | | - algorithms/lower_bound.bench.cpp |
119 | | - algorithms/make_heap.bench.cpp |
120 | | - algorithms/make_heap_then_sort_heap.bench.cpp |
121 | | - algorithms/min.bench.cpp |
122 | | - algorithms/minmax.bench.cpp |
123 | | - algorithms/min_max_element.bench.cpp |
124 | | - algorithms/mismatch.bench.cpp |
125 | | - algorithms/pop_heap.bench.cpp |
126 | | - algorithms/pstl.stable_sort.bench.cpp |
127 | | - algorithms/push_heap.bench.cpp |
128 | | - algorithms/ranges_contains.bench.cpp |
129 | | - algorithms/ranges_ends_with.bench.cpp |
130 | | - algorithms/ranges_make_heap.bench.cpp |
131 | | - algorithms/ranges_make_heap_then_sort_heap.bench.cpp |
132 | | - algorithms/ranges_pop_heap.bench.cpp |
133 | | - algorithms/ranges_push_heap.bench.cpp |
134 | | - algorithms/ranges_sort.bench.cpp |
135 | | - algorithms/ranges_sort_heap.bench.cpp |
136 | | - algorithms/ranges_stable_sort.bench.cpp |
137 | | - algorithms/set_intersection.bench.cpp |
138 | | - algorithms/sort.bench.cpp |
139 | | - algorithms/sort_heap.bench.cpp |
140 | | - algorithms/stable_sort.bench.cpp |
141 | | - atomic_wait.bench.cpp |
142 | | - atomic_wait_vs_mutex_lock.bench.cpp |
143 | | - libcxxabi/dynamic_cast.bench.cpp |
144 | | - libcxxabi/dynamic_cast_old_stress.bench.cpp |
145 | | - allocation.bench.cpp |
146 | | - deque.bench.cpp |
147 | | - deque_iterator.bench.cpp |
148 | | - exception_ptr.bench.cpp |
149 | | - filesystem.bench.cpp |
150 | | - format/write_double_comparison.bench.cpp |
151 | | - format/write_int_comparison.bench.cpp |
152 | | - format/write_string_comparison.bench.cpp |
153 | | - format_to_n.bench.cpp |
154 | | - format_to.bench.cpp |
155 | | - format.bench.cpp |
156 | | - formatted_size.bench.cpp |
157 | | - formatter_float.bench.cpp |
158 | | - formatter_int.bench.cpp |
159 | | - function.bench.cpp |
160 | | - join_view.bench.cpp |
161 | | - lexicographical_compare_three_way.bench.cpp |
162 | | - map.bench.cpp |
163 | | - monotonic_buffer.bench.cpp |
164 | | - numeric/gcd.bench.cpp |
165 | | - ordered_set.bench.cpp |
166 | | - shared_mutex_vs_mutex.bench.cpp |
167 | | - stop_token.bench.cpp |
168 | | - std_format_spec_string_unicode.bench.cpp |
169 | | - std_format_spec_string_unicode_escape.bench.cpp |
170 | | - string.bench.cpp |
171 | | - stringstream.bench.cpp |
172 | | - system_error.bench.cpp |
173 | | - to_chars.bench.cpp |
174 | | - unordered_set_operations.bench.cpp |
175 | | - util_smartptr.bench.cpp |
176 | | - variant_visit_1.bench.cpp |
177 | | - variant_visit_2.bench.cpp |
178 | | - variant_visit_3.bench.cpp |
179 | | - vector_operations.bench.cpp |
180 | | - ) |
181 | | - |
182 | | -foreach(test_path ${BENCHMARK_TESTS}) |
183 | | - get_filename_component(test_file "${test_path}" NAME) |
184 | | - string(REPLACE ".bench.cpp" "" test_name "${test_file}") |
185 | | - if (NOT DEFINED ${test_name}_REPORTED) |
186 | | - message(STATUS "Adding Benchmark: ${test_file}") |
187 | | - # Only report the adding of the benchmark once. |
188 | | - set(${test_name}_REPORTED ON CACHE INTERNAL "") |
189 | | - endif() |
190 | | - add_benchmark_test(${test_name} ${test_path}) |
191 | | -endforeach() |
192 | | - |
193 | | -if (LIBCXX_INCLUDE_TESTS) |
194 | | - include(AddLLVM) |
195 | | - |
196 | | - configure_lit_site_cfg( |
197 | | - ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py.in |
198 | | - ${CMAKE_CURRENT_BINARY_DIR}/lit.cfg.py) |
199 | | - |
200 | | - configure_lit_site_cfg( |
201 | | - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in |
202 | | - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py) |
203 | | - |
204 | | - set(BENCHMARK_LIT_ARGS "--show-all --show-xfail --show-unsupported ${LIT_ARGS_DEFAULT}") |
205 | | - |
206 | | - add_lit_target(check-cxx-benchmarks |
207 | | - "Running libcxx benchmarks tests" |
208 | | - ${CMAKE_CURRENT_BINARY_DIR} |
209 | | - DEPENDS cxx-benchmarks cxx-test-depends |
210 | | - ARGS ${BENCHMARK_LIT_ARGS}) |
211 | | -endif() |
| 40 | +add_dependencies(cxx-test-depends google-benchmark) |
0 commit comments