|
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,169 +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/lower_bound.bench.cpp |
118 |
| - algorithms/make_heap.bench.cpp |
119 |
| - algorithms/make_heap_then_sort_heap.bench.cpp |
120 |
| - algorithms/min.bench.cpp |
121 |
| - algorithms/minmax.bench.cpp |
122 |
| - algorithms/min_max_element.bench.cpp |
123 |
| - algorithms/mismatch.bench.cpp |
124 |
| - algorithms/pop_heap.bench.cpp |
125 |
| - algorithms/pstl.stable_sort.bench.cpp |
126 |
| - algorithms/push_heap.bench.cpp |
127 |
| - algorithms/ranges_contains.bench.cpp |
128 |
| - algorithms/ranges_ends_with.bench.cpp |
129 |
| - algorithms/ranges_make_heap.bench.cpp |
130 |
| - algorithms/ranges_make_heap_then_sort_heap.bench.cpp |
131 |
| - algorithms/ranges_pop_heap.bench.cpp |
132 |
| - algorithms/ranges_push_heap.bench.cpp |
133 |
| - algorithms/ranges_sort.bench.cpp |
134 |
| - algorithms/ranges_sort_heap.bench.cpp |
135 |
| - algorithms/ranges_stable_sort.bench.cpp |
136 |
| - algorithms/set_intersection.bench.cpp |
137 |
| - algorithms/sort.bench.cpp |
138 |
| - algorithms/sort_heap.bench.cpp |
139 |
| - algorithms/stable_sort.bench.cpp |
140 |
| - atomic_wait.bench.cpp |
141 |
| - atomic_wait_vs_mutex_lock.bench.cpp |
142 |
| - libcxxabi/dynamic_cast.bench.cpp |
143 |
| - libcxxabi/dynamic_cast_old_stress.bench.cpp |
144 |
| - allocation.bench.cpp |
145 |
| - deque.bench.cpp |
146 |
| - deque_iterator.bench.cpp |
147 |
| - exception_ptr.bench.cpp |
148 |
| - filesystem.bench.cpp |
149 |
| - format_to_n.bench.cpp |
150 |
| - format_to.bench.cpp |
151 |
| - format.bench.cpp |
152 |
| - formatted_size.bench.cpp |
153 |
| - formatter_float.bench.cpp |
154 |
| - formatter_int.bench.cpp |
155 |
| - function.bench.cpp |
156 |
| - join_view.bench.cpp |
157 |
| - lexicographical_compare_three_way.bench.cpp |
158 |
| - map.bench.cpp |
159 |
| - monotonic_buffer.bench.cpp |
160 |
| - numeric/gcd.bench.cpp |
161 |
| - ordered_set.bench.cpp |
162 |
| - shared_mutex_vs_mutex.bench.cpp |
163 |
| - stop_token.bench.cpp |
164 |
| - std_format_spec_string_unicode.bench.cpp |
165 |
| - std_format_spec_string_unicode_escape.bench.cpp |
166 |
| - string.bench.cpp |
167 |
| - stringstream.bench.cpp |
168 |
| - system_error.bench.cpp |
169 |
| - to_chars.bench.cpp |
170 |
| - unordered_set_operations.bench.cpp |
171 |
| - util_smartptr.bench.cpp |
172 |
| - variant_visit_1.bench.cpp |
173 |
| - variant_visit_2.bench.cpp |
174 |
| - variant_visit_3.bench.cpp |
175 |
| - vector_operations.bench.cpp |
176 |
| - ) |
177 |
| - |
178 |
| -foreach(test_path ${BENCHMARK_TESTS}) |
179 |
| - get_filename_component(test_file "${test_path}" NAME) |
180 |
| - string(REPLACE ".bench.cpp" "" test_name "${test_file}") |
181 |
| - if (NOT DEFINED ${test_name}_REPORTED) |
182 |
| - message(STATUS "Adding Benchmark: ${test_file}") |
183 |
| - # Only report the adding of the benchmark once. |
184 |
| - set(${test_name}_REPORTED ON CACHE INTERNAL "") |
185 |
| - endif() |
186 |
| - add_benchmark_test(${test_name} ${test_path}) |
187 |
| -endforeach() |
188 |
| - |
189 |
| -if (LIBCXX_INCLUDE_TESTS) |
190 |
| - include(AddLLVM) |
191 |
| - |
192 |
| - configure_lit_site_cfg( |
193 |
| - ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py.in |
194 |
| - ${CMAKE_CURRENT_BINARY_DIR}/lit.cfg.py) |
195 |
| - |
196 |
| - configure_lit_site_cfg( |
197 |
| - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in |
198 |
| - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py) |
199 |
| - |
200 |
| - set(BENCHMARK_LIT_ARGS "--show-all --show-xfail --show-unsupported ${LIT_ARGS_DEFAULT}") |
201 |
| - |
202 |
| - add_lit_target(check-cxx-benchmarks |
203 |
| - "Running libcxx benchmarks tests" |
204 |
| - ${CMAKE_CURRENT_BINARY_DIR} |
205 |
| - DEPENDS cxx-benchmarks cxx-test-depends |
206 |
| - ARGS ${BENCHMARK_LIT_ARGS}) |
207 |
| -endif() |
| 40 | +add_dependencies(cxx-test-depends google-benchmark) |
0 commit comments