From da652a748675b679947710117329e9f77f374f2d Mon Sep 17 00:00:00 2001 From: dominic hamon <510002+dmah42@users.noreply.github.com> Date: Sat, 10 Dec 2022 19:42:44 -0400 Subject: [PATCH] Try removing attempt to set the C++ standard (#1464) * Try removing attempt to set the C++ standard Fixes #1460 #1462 * set the standard to 11 * spell it right * had it right the first time * require std 11 * plumb through the standard to cxxfeaturecheck * use policy instead * can't use policy just yet * Update CXXFeatureCheck.cmake * fix CXX_STANDARD_REQUIRED statement Co-authored-by: Dominic Hamon --- CMakeLists.txt | 4 ++++ cmake/CXXFeatureCheck.cmake | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ab265ed..9b9dd38e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,10 @@ if (BENCHMARK_BUILD_32_BITS) add_required_cxx_compiler_flag(-m32) endif() +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + if (MSVC) set(BENCHMARK_CXX_STANDARD 14) else() diff --git a/cmake/CXXFeatureCheck.cmake b/cmake/CXXFeatureCheck.cmake index 50e5f680..e5148265 100644 --- a/cmake/CXXFeatureCheck.cmake +++ b/cmake/CXXFeatureCheck.cmake @@ -40,6 +40,8 @@ function(cxx_feature_check FILE) message(STATUS "Cross-compiling to test ${FEATURE}") try_compile(COMPILE_${FEATURE} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} OUTPUT_VARIABLE COMPILE_OUTPUT_VAR) @@ -54,6 +56,8 @@ function(cxx_feature_check FILE) message(STATUS "Compiling and running to test ${FEATURE}") try_run(RUN_${FEATURE} COMPILE_${FEATURE} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR)