@@ -2,12 +2,12 @@ include(ExternalProject)
2
2
include (CheckCXXCompilerFlag )
3
3
4
4
#==============================================================================
5
- # Build Google Benchmark for libc++
5
+ # Build Google Benchmark
6
6
#==============================================================================
7
7
8
8
set (CMAKE_FOLDER "${CMAKE_FOLDER} /Benchmarks" )
9
9
10
- set (BENCHMARK_LIBCXX_COMPILE_FLAGS
10
+ set (BENCHMARK_COMPILE_FLAGS
11
11
-Wno-unused-command-line-argument
12
12
-nostdinc++
13
13
-isystem "${LIBCXX_GENERATED_INCLUDE_DIR} "
@@ -16,64 +16,37 @@ set(BENCHMARK_LIBCXX_COMPILE_FLAGS
16
16
${SANITIZER_FLAGS}
17
17
)
18
18
if (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE )
19
- list (APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
19
+ list (APPEND BENCHMARK_COMPILE_FLAGS
20
20
-isystem "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR} " )
21
21
endif ()
22
22
if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH )
23
- list (APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
23
+ list (APPEND BENCHMARK_COMPILE_FLAGS
24
24
-L${LIBCXX_CXX_ABI_LIBRARY_PATH}
25
25
-Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH} )
26
26
endif ()
27
- split_list (BENCHMARK_LIBCXX_COMPILE_FLAGS )
27
+ split_list (BENCHMARK_COMPILE_FLAGS )
28
28
29
- ExternalProject_Add (google-benchmark-libcxx
29
+ ExternalProject_Add (google-benchmark
30
30
EXCLUDE_FROM_ALL ON
31
31
DEPENDS cxx cxx-headers
32
- PREFIX benchmark-libcxx
32
+ PREFIX google-benchmark
33
33
SOURCE_DIR ${LLVM_THIRD_PARTY_DIR} /benchmark
34
- INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR} /benchmark-libcxx
34
+ INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR} /google-benchmark
35
35
CMAKE_CACHE_ARGS
36
36
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
37
37
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
38
38
-DCMAKE_BUILD_TYPE:STRING=RELEASE
39
39
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
40
- -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS }
40
+ -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_COMPILE_FLAGS }
41
41
-DBENCHMARK_USE_LIBCXX:BOOL=ON
42
42
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF )
43
43
44
- #==============================================================================
45
- # Build Google Benchmark for the native stdlib
46
- #==============================================================================
47
- set (BENCHMARK_NATIVE_TARGET_FLAGS )
48
- if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN )
49
- set (BENCHMARK_NATIVE_TARGET_FLAGS
50
- --gcc-toolchain=${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN} )
51
- endif ()
52
- split_list (BENCHMARK_NATIVE_TARGET_FLAGS )
53
-
54
- if (LIBCXX_BENCHMARK_NATIVE_STDLIB )
55
- ExternalProject_Add (google-benchmark-native
56
- EXCLUDE_FROM_ALL ON
57
- PREFIX benchmark-native
58
- SOURCE_DIR ${LLVM_THIRD_PARTY_DIR} /benchmark
59
- INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR} /benchmark-native
60
- CMAKE_CACHE_ARGS
61
- -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
62
- -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
63
- -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_NATIVE_TARGET_FLAGS}
64
- -DCMAKE_BUILD_TYPE:STRING=RELEASE
65
- -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
66
- -DBENCHMARK_ENABLE_TESTING:BOOL=OFF )
67
- endif ()
68
-
69
-
70
44
#==============================================================================
71
45
# Benchmark tests configuration
72
46
#==============================================================================
73
47
add_custom_target (cxx-benchmarks )
74
48
set (BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} )
75
- set (BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR} /benchmark-libcxx )
76
- set (BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR} /benchmark-native )
49
+ set (BENCHMARK_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR} /google-benchmark )
77
50
78
51
add_library ( cxx-benchmarks-flags INTERFACE )
79
52
@@ -97,41 +70,23 @@ else()
97
70
target_compile_features ( cxx-benchmarks-flags INTERFACE cxx_std_23 )
98
71
endif ()
99
72
100
- target_compile_options ( cxx-benchmarks-flags INTERFACE -fsized-deallocation -nostdinc++ )
73
+ target_compile_options (cxx-benchmarks-flags INTERFACE -fsized-deallocation -nostdinc++
74
+ ${SANITIZER_FLAGS} -Wno-user-defined-literals -Wno-suggest-override )
101
75
target_include_directories (cxx-benchmarks-flags INTERFACE "${LIBCXX_GENERATED_INCLUDE_DIR} "
102
- INTERFACE "${BENCHMARK_LIBCXX_INSTALL } /include"
76
+ INTERFACE "${BENCHMARK_INSTALL_DIR } /include"
103
77
INTERFACE "${LIBCXX_SOURCE_DIR} /test/support" )
104
-
105
- add_library ( cxx-benchmarks-flags-native INTERFACE )
106
- target_link_libraries ( cxx-benchmarks-flags-native INTERFACE cxx-benchmarks-flags )
107
- target_compile_options (cxx-benchmarks-flags-native INTERFACE ${BENCHMARK_NATIVE_TARGET_FLAGS} )
108
- target_link_options ( cxx-benchmarks-flags-native INTERFACE ${BENCHMARK_NATIVE_TARGET_FLAGS} "-L${BENCHMARK_NATIVE_INSTALL} /lib" )
109
- if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++" )
110
- find_library (LIBSTDCXX_FILESYSTEM_TEST stdc++fs
111
- PATHS ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN}
112
- PATH_SUFFIXES lib lib64
113
- DOC "The libstdc++ filesystem library used by the benchmarks"
114
- )
115
- if (LIBSTDCXX_FILESYSTEM_TEST )
116
- target_link_libraries (cxx-benchmarks-flags-native INTERFACE -lstdc++fs )
117
- endif ()
118
- else ()
119
- target_link_libraries (cxx-benchmarks-flags-native INTERFACE -lc++fs -lc++experimental )
120
- endif ()
121
-
122
- add_library ( cxx-benchmarks-flags-libcxx INTERFACE )
123
- target_link_libraries ( cxx-benchmarks-flags-libcxx INTERFACE cxx-benchmarks-flags )
124
- target_compile_options (cxx-benchmarks-flags-libcxx INTERFACE ${SANITIZER_FLAGS} -Wno-user-defined-literals -Wno-suggest-override )
125
- target_link_options ( cxx-benchmarks-flags-libcxx INTERFACE -lm -nostdlib++ "-L${BENCHMARK_LIBCXX_INSTALL} /lib" "-L${BENCHMARK_LIBCXX_INSTALL} /lib64" ${SANITIZER_FLAGS} )
78
+ target_link_options (cxx-benchmarks-flags INTERFACE -lm -nostdlib++
79
+ "-L${BENCHMARK_INSTALL_DIR} /lib" "-L${BENCHMARK_INSTALL_DIR} /lib64"
80
+ ${SANITIZER_FLAGS} )
126
81
127
82
set (libcxx_benchmark_targets )
128
83
129
84
function (add_benchmark_test name source_file )
130
85
set (libcxx_target ${name} _libcxx )
131
86
list (APPEND libcxx_benchmark_targets ${libcxx_target} )
132
87
add_executable (${libcxx_target} EXCLUDE_FROM_ALL ${source_file} )
133
- target_link_libraries (${libcxx_target} PRIVATE cxx-benchmarks-flags-libcxx )
134
- add_dependencies (${libcxx_target} cxx google-benchmark-libcxx )
88
+ target_link_libraries (${libcxx_target} PRIVATE cxx-benchmarks-flags )
89
+ add_dependencies (${libcxx_target} cxx google-benchmark )
135
90
add_dependencies (cxx-benchmarks ${libcxx_target} )
136
91
if (LIBCXX_ENABLE_SHARED )
137
92
target_link_libraries (${libcxx_target} PRIVATE cxx_shared )
@@ -144,27 +99,10 @@ function(add_benchmark_test name source_file)
144
99
endif ()
145
100
set_target_properties (${libcxx_target}
146
101
PROPERTIES
147
- OUTPUT_NAME "${name} .libcxx .out"
102
+ OUTPUT_NAME "${name} .bench .out"
148
103
RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR} "
149
104
CXX_EXTENSIONS NO )
150
105
cxx_link_system_libraries (${libcxx_target} )
151
- if (LIBCXX_BENCHMARK_NATIVE_STDLIB )
152
- set (native_target ${name} _native )
153
- add_executable (${native_target} EXCLUDE_FROM_ALL ${source_file} )
154
- target_link_libraries (${native_target} PRIVATE cxx-benchmarks-flags-native )
155
- add_dependencies (${native_target} google-benchmark-native
156
- google-benchmark-libcxx )
157
- target_link_libraries (${native_target} PRIVATE -lbenchmark )
158
- if (LIBCXX_HAS_PTHREAD_LIB )
159
- target_link_libraries (${native_target} PRIVATE -pthread )
160
- endif ()
161
- add_dependencies (cxx-benchmarks ${native_target} )
162
- set_target_properties (${native_target}
163
- PROPERTIES
164
- OUTPUT_NAME "${name} .native.out"
165
- RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR} "
166
- CXX_EXTENSIONS NO )
167
- endif ()
168
106
endfunction ()
169
107
170
108
0 commit comments