CMake: detect/features.cmake: fix try_compile if CXX_STANDARD or CXX_EXTENSIONS unset

This commit is contained in:
2025-05-12 14:17:15 +02:00
parent d9314150c2
commit 3bad408674

View File

@ -1,8 +1,5 @@
try_compile(cxx-least-11 ${CMAKE_BINARY_DIR}/detect ${CMAKE_SOURCE_DIR}/detect/cxxstd.cpp
COMPILE_DEFINITIONS -DCXX_STANDARD=201103
CXX_STANDARD ${CMAKE_CXX_STANDARD}
CXX_STANDARD_REQUIRED ${CMAKE_CXX_STANDARD_REQUIRED}
CXX_EXTENSIONS ${CMAKE_CXX_EXTENSIONS}
)
if(NOT cxx-least-11)
@ -16,20 +13,13 @@ endif()
try_compile(cxx-least-14 ${CMAKE_BINARY_DIR}/detect ${CMAKE_SOURCE_DIR}/detect/cxxstd.cpp
COMPILE_DEFINITIONS -DCXX_STANDARD=201402
CXX_STANDARD ${CMAKE_CXX_STANDARD}
CXX_STANDARD_REQUIRED ${CMAKE_CXX_STANDARD_REQUIRED}
CXX_EXTENSIONS ${CMAKE_CXX_EXTENSIONS}
)
if(cxx-least-14)
set(RING_BUFFER_CONSTEXPR ON)
message(STATUS "Enabling RING_BUFFER_CONSTEXPR (C++14 and up)")
endif()
try_compile(constexpr-destructors-compile ${CMAKE_BINARY_DIR}/detect ${CMAKE_SOURCE_DIR}/detect/constexpr_destructors.cpp
CXX_STANDARD ${CMAKE_CXX_STANDARD}
CXX_STANDARD_REQUIRED ${CMAKE_CXX_STANDARD_REQUIRED}
CXX_EXTENSIONS ${CMAKE_CXX_EXTENSIONS}
)
try_compile(constexpr-destructors-compile ${CMAKE_BINARY_DIR}/detect ${CMAKE_SOURCE_DIR}/detect/constexpr_destructors.cpp)
if(constexpr-destructors-compile)
set(RING_BUFFER_CONSTEXPR_DESTRUCTORS ON)
message(STATUS "Enabling RING_BUFFER_CONSTEXPR_DESTRUCTORS (C++20 and up)")