@@ -147,15 +147,6 @@ endif()
147147set (CMAKE_CXX_STANDARD ${BENCHMARK_CXX_STANDARD} )
148148set (CMAKE_CXX_STANDARD_REQUIRED YES )
149149set (CMAKE_CXX_EXTENSIONS OFF )
150- option (BENCHMARK_ENABLE_EXPENSIVE_CMAKE_CHECKS "Enable use of expensive CMake checks for unused source files" ON )
151-
152- macro (handle_flag flag)
153- if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT BENCHMARK_ENABLE_EXPENSIVE_CMAKE_CHECKS)
154- list (APPEND CMAKE_CXX_FLAGS ${flag} )
155- else ()
156- add_cxx_compiler_flag(${flag} )
157- endif ()
158- endmacro ()
159150
160151if (MSVC )
161152 # Turn compiler warnings up to 11
@@ -194,49 +185,49 @@ else()
194185 add_definitions (-D_LARGEFILE64_SOURCE)
195186 add_definitions (-D_LARGEFILE_SOURCE)
196187 # Turn compiler warnings up to 11
197- handle_flag (-Wall)
198- handle_flag (-Wextra)
199- handle_flag (-Wshadow)
200- handle_flag (-Wfloat-equal )
201- handle_flag (-Wold-style-cast)
188+ add_cxx_compiler_flag (-Wall)
189+ add_cxx_compiler_flag (-Wextra)
190+ add_cxx_compiler_flag (-Wshadow)
191+ add_cxx_compiler_flag (-Wfloat-equal )
192+ add_cxx_compiler_flag (-Wold-style-cast)
202193 if (BENCHMARK_ENABLE_WERROR)
203- handle_flag (-Werror)
194+ add_cxx_compiler_flag (-Werror)
204195 endif ()
205196 if (NOT BENCHMARK_ENABLE_TESTING)
206197 # Disable warning when compiling tests as gtest does not use 'override'.
207- handle_flag (-Wsuggest-override)
198+ add_cxx_compiler_flag (-Wsuggest-override)
208199 endif ()
209- handle_flag (-pedantic)
210- handle_flag (-pedantic-errors)
211- handle_flag (-Wshorten-64-to-32)
212- handle_flag (-fstrict-aliasing)
200+ add_cxx_compiler_flag (-pedantic)
201+ add_cxx_compiler_flag (-pedantic-errors)
202+ add_cxx_compiler_flag (-Wshorten-64-to-32)
203+ add_cxx_compiler_flag (-fstrict-aliasing)
213204 # Disable warnings regarding deprecated parts of the library while building
214205 # and testing those parts of the library.
215- handle_flag (-Wno-deprecated-declarations)
206+ add_cxx_compiler_flag (-Wno-deprecated-declarations)
216207 if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" )
217208 # Intel silently ignores '-Wno-deprecated-declarations',
218209 # warning no. 1786 must be explicitly disabled.
219210 # See #631 for rationale.
220- handle_flag (-wd1786)
221- handle_flag (-fno-finite-math-only)
211+ add_cxx_compiler_flag (-wd1786)
212+ add_cxx_compiler_flag (-fno-finite-math-only)
222213 endif ()
223214 # Disable deprecation warnings for release builds (when -Werror is enabled).
224215 if (BENCHMARK_ENABLE_WERROR)
225- handle_flag (-Wno-deprecated)
216+ add_cxx_compiler_flag (-Wno-deprecated)
226217 endif ()
227218 if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
228- handle_flag (-fno-exceptions)
219+ add_cxx_compiler_flag (-fno-exceptions)
229220 endif ()
230221
231222 if (HAVE_CXX_FLAG_FSTRICT_ALIASING)
232223 if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" ) #ICC17u2: Many false positives for Wstrict-aliasing
233- handle_flag (-Wstrict-aliasing)
224+ add_cxx_compiler_flag (-Wstrict-aliasing)
234225 endif ()
235226 endif ()
236227 # ICC17u2: overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden
237228 # (because of deprecated overload)
238- handle_flag (-wd654)
239- handle_flag (-Wthread-safety)
229+ add_cxx_compiler_flag (-wd654)
230+ add_cxx_compiler_flag (-Wthread-safety)
240231 if (HAVE_CXX_FLAG_WTHREAD_SAFETY)
241232 cxx_feature_check(THREAD_SAFETY_ATTRIBUTES "-DINCLUDE_DIRECTORIES=${PROJECT_SOURCE_DIR} /include" )
242233 endif ()
@@ -255,8 +246,8 @@ else()
255246
256247 # Link time optimisation
257248 if (BENCHMARK_ENABLE_LTO)
258- handle_flag (-flto)
259- handle_flag (-Wno-lto-type -mismatch)
249+ add_cxx_compiler_flag (-flto)
250+ add_cxx_compiler_flag (-Wno-lto-type -mismatch)
260251 if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
261252 find_program (GCC_AR gcc-ar)
262253 if (GCC_AR)
@@ -287,7 +278,7 @@ else()
287278 BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE)
288279 set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE} " CACHE STRING
289280 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." )
290- handle_flag (--coverage COVERAGE)
281+ add_cxx_compiler_flag (--coverage COVERAGE)
291282endif ()
292283
293284if (BENCHMARK_USE_LIBCXX)
0 commit comments