From 4bf86b79bb05b9b7e67504ce093ecd534a481405 Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:05:07 +0900 Subject: [PATCH] Change MSVC's debug format from `/Zi` to `/Z7` With `/Zi`, it is technically impossible to use `REUSE_FROM` on PCH. --- CMakeLists.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40f14a6..61fd233 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,16 +49,17 @@ if(MSVC) unset(IRIS_MSVC_BIN_DIR) endif() -# Make debug information embedded in the object files (/Z7) also in Release. -# Unlike /Zi, it lets a precompiled header be shared between targets. -# See also: https://gitlab.kitware.com/cmake/cmake/-/issues/27434 +# Make debug information embedded in the object files (/Z7) in all configurations. +# +# With /Zi, `target_precompile_headers(... REUSE_FROM )` makes CMake copy +# the compiler PDB of over the consumer's compiler PDB before each build. +# If has sources other than the PCH, editing any of them updates its PDB, +# and the copy discards the type records that the consumer's unchanged objects still +# reference. The consumer then fails to link with LNK1103 ("debugging information +# corrupt") until it is rebuilt. (/Z7 has no compiler PDB, so nothing is copied.) function(iris_set_msvc_debug_info) if(MSVC) - set( - CMAKE_MSVC_DEBUG_INFORMATION_FORMAT - "$<$:ProgramDatabase>$<$:Embedded>" - PARENT_SCOPE - ) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded PARENT_SCOPE) add_link_options("$<$:/DEBUG:FULL;/OPT:REF;/OPT:ICF>") endif() endfunction()