mdbx: add workaround for old MSVC and/or old Windows SDK.

Resolves https://github.com/erthink/libmdbx/issues/265.

Change-Id: I295b5d9d5ecd670ccf258791bf87379a3ca17f21
This commit is contained in:
Leonid Yuriev
2022-01-31 23:29:03 +03:00
parent 1c409a38d3
commit 79e1cc3bbc
4 changed files with 62 additions and 28 deletions

View File

@@ -264,9 +264,24 @@ endif()
if(CMAKE_CXX_COMPILER_LOADED)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
if(HAS_CXX11 LESS 0)
check_compiler_flag("-std=gnu++11" CXX_FALLBACK_STDGNU11)
if(NOT CXX_FALLBACK_STDGNU11)
check_compiler_flag("-std=c++11" CXX_FALLBACK_STD11)
check_cxx_compiler_flag("-std=gnu++11" CXX_FALLBACK_GNU11)
if(NOT CXX_FALLBACK_GNU11)
check_cxx_compiler_flag("-std=c++11" CXX_FALLBACK_11)
endif()
endif()
endif()
# Crutch for mad C compilers and/or CMake to enabling C11
if(CMAKE_C_COMPILER_LOADED)
list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 HAS_C11)
if(HAS_C11 LESS 0)
if (MSVC)
check_c_compiler_flag("/std:c11" C_FALLBACK_11)
else()
check_c_compiler_flag("-std=gnu11" C_FALLBACK_GNU11)
if(NOT C_FALLBACK_GNU11)
check_c_compiler_flag("-std=c11" C_FALLBACK_11)
endif()
endif()
endif()
endif()
@@ -536,14 +551,24 @@ macro(setup_compile_flags)
if(CMAKE_CXX_COMPILER_LOADED)
set(CXX_FLAGS ${INITIAL_CMAKE_CXX_FLAGS})
# Crutch for old C++ compilers and/or CMake to enabling C++11
if(CXX_FALLBACK_STDGNU11)
if(CXX_FALLBACK_GNU11)
add_compile_flags("CXX" "-std=gnu++11")
elseif(CXX_FALLBACK_STD11)
elseif(CXX_FALLBACK_11)
add_compile_flags("CXX" "-std=c++11")
endif()
endif()
if(CMAKE_C_COMPILER_LOADED)
set(C_FLAGS ${INITIAL_CMAKE_C_FLAGS})
# Crutch for mad C compilers and/or CMake to enabling C11
if(C_FALLBACK_GNU11)
add_compile_flags("C" "-std=gnu11")
elseif(C_FALLBACK_11)
if(MSVC)
add_compile_flags("C" "/std:c11")
else()
add_compile_flags("C" "-std=c11")
endif()
endif()
endif()
set(EXE_LINKER_FLAGS ${INITIAL_CMAKE_EXE_LINKER_FLAGS})
set(SHARED_LINKER_FLAGS ${INITIAL_CMAKE_SHARED_LINKER_FLAGS})