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)