From 0287faeb13f7c5e15b58ea3cea560cd081d4bd85 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 10 Jan 2022 10:39:55 +0000 Subject: [PATCH] Work around MSVC+CMake+LTO bug Disables tests in MSVC LTO configurations. Refs #3778 --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a08b694b0..fc37ec725 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,13 @@ else() endif() set(PROJECT_VERSION_WITH_SUFFIX "${PROJECT_VERSION}$<$:-${VERSION_SUFFIX}>") +if(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT DISABLE_LTO) + # Work around MSVC + CMake bug when LTO is enabled. + # See https://github.com/diasurgical/devilutionX/issues/3778 + # and https://gitlab.kitware.com/cmake/cmake/-/issues/23035 + set(BUILD_TESTING OFF) +endif() + # This built-in CMake module adds a BUILD_TESTING option (ON by default). # Must be included in the top-level `CMakeLists.txt` after calling `project`. # Because we must include `VcPkgManifestFeatures` before the `project` call,