mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-18 10:50:05 +00:00
CMake: Enforce minimum stdlib versions
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
# like add_library(new ALIAS old) but avoids add_library cannot create ALIAS target "new" because target "old" is imported but not globally visible. on older cmake
|
||||
# This can be replaced with a direct alias call once our minimum is cmake 3.18
|
||||
function(dolphin_alias_library new old)
|
||||
@@ -148,3 +151,21 @@ function(dolphin_check_toolset_version LABEL VERSION_VAR MIN_VERSION)
|
||||
message(FATAL_ERROR "Requires ${LABEL} ${MIN_VERSION} or higher")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(dolphin_check_std_version LABEL VERSION_MACRO MIN_VERSION)
|
||||
check_cxx_symbol_exists(${VERSION_MACRO} version IS_${LABEL})
|
||||
if(NOT IS_${LABEL})
|
||||
return()
|
||||
endif()
|
||||
check_cxx_source_compiles([[
|
||||
#include <version>
|
||||
#if ${VERSION_MACRO} < ${MIN_VERSION}
|
||||
#error
|
||||
#endif
|
||||
int main(){}
|
||||
]] HAS_MINIMUM_${LABEL})
|
||||
if(NOT HAS_MINIMUM_${LABEL})
|
||||
message(FATAL_ERROR "Requires ${LABEL} ${MIN_VERSION} or higher")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -54,6 +54,9 @@ set(GCC_min_version 12)
|
||||
set(Clang_min_version 15)
|
||||
set(AppleClang_min_version 14.0.3)
|
||||
set(MSVC_min_version 19.32)
|
||||
# Standard libraries
|
||||
set(libstdc++_min_version 12) # This should match GCC_min_version's major version.
|
||||
set(libc++_min_version 150000) # This should match Clang_min_version in the format "xxyyzz" instead of "xx.yy.zz"
|
||||
|
||||
dolphin_check_toolset_version("Xcode" XCODE_VERSION ${Xcode_min_version})
|
||||
dolphin_check_toolset_version("MSVC Toolset" MSVC_TOOLSET_VERSION ${MSVC_toolset_min_version})
|
||||
@@ -66,6 +69,12 @@ elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${${COMPILER}_min_version})
|
||||
message(FATAL_ERROR "Requires ${COMPILER} ${${COMPILER}_min_version} or higher")
|
||||
endif()
|
||||
|
||||
# libstdc++ is almost always used on Linux, even when using clang as the compiler.
|
||||
# libc++ is used on the likes of Android, Apple devices, FreeBSD, and a few (very) rare Linux distros like Chimera Linux.
|
||||
# Windows uses its own standard library named STL, which we check as part of the toolset above. (outside of MinGW which can use either libstdc++ or libc++)
|
||||
dolphin_check_std_version("GNU_libstdc++" _GLIBCXX_RELEASE ${libstdc++_min_version})
|
||||
dolphin_check_std_version("LLVM_libc++" _LIBCPP_VERSION ${libc++_min_version})
|
||||
|
||||
# Name of the Dolphin distributor. If you redistribute Dolphin builds (forks,
|
||||
# unofficial builds) please consider identifying your distribution with a
|
||||
# unique name here.
|
||||
|
||||
Reference in New Issue
Block a user