Precompiled headers break when the visual studio compiler is updated.
I have a previously fully compiled project, using the Ninja Multi-Config generator, CMake 3.25.1, on Windows 10, using the Microsoft cl.exe
compiler, and link.exe
linker.
Microsoft Visual Studio updated the compiler without changing the folder it's deployed to, so the path on disk remains the same as it was when I previously built my project, though the internal build number changed. Sometimes visual studio updates change the toolchain number, sometimes they don't.
As a result, cmake was not called to re-configure the project, since nothing in the list of configuration dependencies have changed.
I changed a file during normal development after this compiler update, and triggered an incremental build.
This causes errors of the form:
D:\builds\mybuild\libblah_shared.dir\Unity\unity_0_cxx.cxx: fatal error C1853: 'D:/builds/mybuild/CMakeFiles/libblah_shared.dir/Release/cmake_pch.cxx.pch' precompiled header file is from a different version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)
Manually running the cmake configuration and then re-running the incremental build does not fix this problem, since the configuration step does not re-generate precompiled headers.
To fix this, the compiler could be included in the build graph as a dependency for the source files, so that a change in the compiler will cause targets to be rebuilt to stay up to date.