Attempt to make benchmarks fall back to -std=c++1z when C++17 isn't supported.

The benchmarks currently require C++17, however Clang 3.9 doesn't
support -std=c++17 while still supporting all the C++17 features needed
to compile the benchmarks.

This patch makes the benchmark build attempt to fall back to -std=c++1z
when -std=c++17 isn't supported.

See llvm.org/PR39629

llvm-svn: 346744
This commit is contained in:
Eric Fiselier 2018-11-13 07:03:16 +00:00
parent 32869c6997
commit 4de1c753ff
1 changed files with 12 additions and 1 deletions

View File

@ -67,8 +67,19 @@ add_custom_target(cxx-benchmarks)
set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
check_flag_supported("-std=c++17")
mangle_name("LIBCXX_SUPPORTS_STD_EQ_c++17_FLAG" BENCHMARK_SUPPORTS_STD_CXX17_FLAG)
if (${BENCHMARK_SUPPORTS_STD_CXX17_FLAG})
set(BENCHMARK_DIALECT_FLAG "-std=c++17")
else()
# If the compiler doesn't support -std=c++17, attempt to fall back to -std=c++1z while still
# requiring C++17 language features.
set(BENCHMARK_DIALECT_FLAG "-std=c++1z")
endif()
set(BENCHMARK_TEST_COMPILE_FLAGS
-std=c++17 -O2
${BENCHMARK_DIALECT_FLAG} -O2
-I${BENCHMARK_LIBCXX_INSTALL}/include
-I${LIBCXX_SOURCE_DIR}/test/support
)