build: Get minor MSVC version from host registry
This commit is contained in:
parent
57d1e42eca
commit
39e7f60c5a
2 changed files with 18 additions and 17 deletions
|
|
@ -94,8 +94,22 @@ set(REQUIRED_OPENSSL_VERSION 3.0)
|
||||||
set(REQUIRED_LIBEI_VERSION 1.3)
|
set(REQUIRED_LIBEI_VERSION 1.3)
|
||||||
set(REQUIRED_LIBPORTAL_VERSION 0.8)
|
set(REQUIRED_LIBPORTAL_VERSION 0.8)
|
||||||
set(REQUIRED_QT_VERSION 6.7.0)
|
set(REQUIRED_QT_VERSION 6.7.0)
|
||||||
set(REQUIRED_MSVC_RUNTIME_MAJOR 14)
|
|
||||||
set(REQUIRED_MSVC_RUNTIME_MINOR 42)
|
if (MSVC)
|
||||||
|
# On Windows, require that the same MSVC runtime is used as on the host.
|
||||||
|
# Mitigates things like access violations caused by accidental ABI-compatibility breakage.
|
||||||
|
set(REQUIRED_MSVC_RUNTIME_MAJOR 14)
|
||||||
|
cmake_host_system_information(
|
||||||
|
RESULT REQUIRED_MSVC_RUNTIME_MINOR
|
||||||
|
QUERY WINDOWS_REGISTRY
|
||||||
|
"HKLM/SOFTWARE/Microsoft/VisualStudio/${REQUIRED_MSVC_RUNTIME_MAJOR}.0/VC/Runtimes/x64"
|
||||||
|
VALUE "Minor")
|
||||||
|
if (REQUIRED_MSVC_RUNTIME_MINOR)
|
||||||
|
message(STATUS "MSVC runtime: ${REQUIRED_MSVC_RUNTIME_MAJOR}.${REQUIRED_MSVC_RUNTIME_MINOR}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "MSVC runtime registry entry not found")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Control debug item visibility
|
# Control debug item visibility
|
||||||
# When not set logging is forced to DEBUG and show code locations
|
# When not set logging is forced to DEBUG and show code locations
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,6 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
// See table of the compiler versions and the matching runtime DLL versions:
|
|
||||||
// https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd
|
|
||||||
#if _MSC_VER >= 1942 // Visual Studio 2022 Update 12 (v17.12.4)
|
|
||||||
const auto kRequiredMajor = kWindowsRuntimeMajor;
|
|
||||||
const auto kRequiredMinor = kWindowsRuntimeMinor;
|
|
||||||
#elif _MSC_VER >= 1920 // Visual Studio 2019 Update 7 (v16.7)
|
|
||||||
const auto kRequiredMajor = 14;
|
|
||||||
const auto kRequiredMinor = 27;
|
|
||||||
#else
|
|
||||||
#pragma message("MSC version: " STRINGIFY(_MSC_VER))
|
|
||||||
#error "Unsupported MSC version"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Useful for debugging Windows specific bootstrapping code before the logging system is initialized.
|
// Useful for debugging Windows specific bootstrapping code before the logging system is initialized.
|
||||||
// This output can be viewed by attaching a Microsoft debugger or by using the DebugView program.
|
// This output can be viewed by attaching a Microsoft debugger or by using the DebugView program.
|
||||||
#define MS_LOG_DEBUG(message, ...) \
|
#define MS_LOG_DEBUG(message, ...) \
|
||||||
|
|
@ -606,12 +593,12 @@ void ArchMiscWindows::guardRuntimeVersion() // NOSONAR - `noreturn` is not avail
|
||||||
|
|
||||||
MS_LOG_DEBUG("msvc runtime dll version: %d.%d.%d", currentMajor, currentMinor, currentBuild);
|
MS_LOG_DEBUG("msvc runtime dll version: %d.%d.%d", currentMajor, currentMinor, currentBuild);
|
||||||
|
|
||||||
if (currentMajor < kRequiredMajor || currentMinor < kRequiredMinor) {
|
if (currentMajor < kWindowsRuntimeMajor || currentMinor < kWindowsRuntimeMinor) {
|
||||||
const auto message = deskflow::string::sprintf(
|
const auto message = deskflow::string::sprintf(
|
||||||
"Installed Microsoft Visual C++ Runtime v%d.%d.%d is outdated.\n\n"
|
"Installed Microsoft Visual C++ Runtime v%d.%d.%d is outdated.\n\n"
|
||||||
"Minimum required version: v%d.%d\n\n"
|
"Minimum required version: v%d.%d\n\n"
|
||||||
"Please update to the latest Microsoft Visual C++ Redistributable.",
|
"Please update to the latest Microsoft Visual C++ Redistributable.",
|
||||||
currentMajor, currentMinor, currentBuild, kRequiredMajor, kRequiredMinor
|
currentMajor, currentMinor, currentBuild, kWindowsRuntimeMajor, kWindowsRuntimeMinor
|
||||||
);
|
);
|
||||||
MessageBoxA(nullptr, message.c_str(), "Dependency Error", MB_ICONERROR | MB_OK);
|
MessageBoxA(nullptr, message.c_str(), "Dependency Error", MB_ICONERROR | MB_OK);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue