I have a complex project using CMake 3.22.2. To optimize the compilation time, I want to use precompiled headers. It works fine with Linux/ RedHat7 / gcc but fails with Winserver 2016 / Visual Studio 2017. For Windows compilation, I have a /Zi option.
I create a PCH in the top CMakeList, and call a REUSE_FROM in sub CMakeList.
The problem is about .idb files that are not copied into the subdirectories target. The compilation error message is :
error C2859: . . . \aSubdir.dir\Debug\TOP_PCH.idb is not the idb file that was used when this precompiled header was created, recreate the precompiled header.
If i patch a generated ‘copy_idb_pdb_Debug.cmake’ file to add the copy of the .idb file, the compilation turns OK for a subdir
While inspecting the CMake-master source code, I found the ‘problem’ in cmLocalGenerator.cxx, in the cmLocalGenerator::AddPchDependencies method.
The comments says : // MSVC 2008 is producing both .pdb and .idb files with /Zi
In my situation, with Visual Studio 2017, the .idb is also requiered.
Are you aware of this situation, and have you a test with the target_precompile_headers REUSE_FROM with /Zi set under Visual Studio 2017 ?