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 <dominichamon@users.noreply.github.com>
This commit is contained in:
dominic hamon 2022-12-10 19:42:44 -04:00 committed by GitHub
parent e67028c510
commit da652a7486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -138,6 +138,10 @@ if (BENCHMARK_BUILD_32_BITS)
add_required_cxx_compiler_flag(-m32) add_required_cxx_compiler_flag(-m32)
endif() endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (MSVC) if (MSVC)
set(BENCHMARK_CXX_STANDARD 14) set(BENCHMARK_CXX_STANDARD 14)
else() else()

View File

@ -40,6 +40,8 @@ function(cxx_feature_check FILE)
message(STATUS "Cross-compiling to test ${FEATURE}") message(STATUS "Cross-compiling to test ${FEATURE}")
try_compile(COMPILE_${FEATURE} try_compile(COMPILE_${FEATURE}
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS}
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES}
OUTPUT_VARIABLE COMPILE_OUTPUT_VAR) OUTPUT_VARIABLE COMPILE_OUTPUT_VAR)
@ -54,6 +56,8 @@ function(cxx_feature_check FILE)
message(STATUS "Compiling and running to test ${FEATURE}") message(STATUS "Compiling and running to test ${FEATURE}")
try_run(RUN_${FEATURE} COMPILE_${FEATURE} try_run(RUN_${FEATURE} COMPILE_${FEATURE}
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS}
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES}
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR) COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR)