mdbx-cmake: включение стандарта C23.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-10-08 23:08:52 +03:00
parent d40e4db13a
commit d2b74e4da5
2 changed files with 13 additions and 5 deletions

View File

@ -450,7 +450,6 @@ if(MDBX_MANAGE_BUILD_FLAGS)
setup_compile_flags() setup_compile_flags()
endif() endif()
list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 HAS_C11)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 HAS_CXX17) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 HAS_CXX17)
@ -481,6 +480,9 @@ if(NOT DEFINED MDBX_CXX_STANDARD)
set(MDBX_CXX_STANDARD 98) set(MDBX_CXX_STANDARD 98)
endif() endif()
endif() endif()
list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 HAS_C11)
list(FIND CMAKE_C_COMPILE_FEATURES c_std_23 HAS_C23)
if(NOT DEFINED MDBX_C_STANDARD) if(NOT DEFINED MDBX_C_STANDARD)
# MSVC >= 19.28 (Microsoft Visual Studio 16.8) is mad! # MSVC >= 19.28 (Microsoft Visual Studio 16.8) is mad!
# It unable process Windows SDK headers in the C11 mode! # It unable process Windows SDK headers in the C11 mode!
@ -488,6 +490,8 @@ if(NOT DEFINED MDBX_C_STANDARD)
set(MDBX_C_STANDARD 99) set(MDBX_C_STANDARD 99)
set(C_FALLBACK_11 OFF) set(C_FALLBACK_11 OFF)
set(C_FALLBACK_GNU11 OFF) set(C_FALLBACK_GNU11 OFF)
elseif(NOT HAS_C23 LESS 0)
set(MDBX_C_STANDARD 23)
elseif(HAS_C11 LESS 0 AND NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11) elseif(HAS_C11 LESS 0 AND NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11)
set(MDBX_C_STANDARD 99) set(MDBX_C_STANDARD 99)
else() else()
@ -800,7 +804,7 @@ macro(target_setup_options TARGET)
set_target_properties(${TARGET} PROPERTIES set_target_properties(${TARGET} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>) INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
endif() endif()
if(NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11) if(NOT MDBX_C_STANDARD EQUAL 11 OR (NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11))
set_target_properties(${TARGET} PROPERTIES set_target_properties(${TARGET} PROPERTIES
C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON) C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON)
endif() endif()

View File

@ -384,12 +384,16 @@ endif()
if(CMAKE_CXX_COMPILER_LOADED) if(CMAKE_CXX_COMPILER_LOADED)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
if(HAS_CXX11 LESS 0) if(HAS_CXX11 LESS 0)
if (MSVC)
check_cxx_compiler_flag("/std:c++11" CXX_FALLBACK_11)
else()
check_cxx_compiler_flag("-std=gnu++11" CXX_FALLBACK_GNU11) check_cxx_compiler_flag("-std=gnu++11" CXX_FALLBACK_GNU11)
if(NOT CXX_FALLBACK_GNU11) if(NOT CXX_FALLBACK_GNU11)
check_cxx_compiler_flag("-std=c++11" CXX_FALLBACK_11) check_cxx_compiler_flag("-std=c++11" CXX_FALLBACK_11)
endif() endif()
endif() endif()
endif() endif()
endif()
# Crutch for mad C compilers and/or CMake to enabling C11 # Crutch for mad C compilers and/or CMake to enabling C11
if(CMAKE_C_COMPILER_LOADED) if(CMAKE_C_COMPILER_LOADED)