# Suspected bug with PCH REUSE\_FROM with Visual Studio 2017

**URL:** <https://discourse.cmake.org/t/suspected-bug-with-pch-reuse-from-with-visual-studio-2017/5520>\
**Category:** Code\
**Created:** [April 22, 2022, 4:29pm UTC](https://discourse.cmake.org/t/suspected-bug-with-pch-reuse-from-with-visual-studio-2017/5520 "2022-04-22T16:29:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMH](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/e68b1a/32.png) [@JMH](https://discourse.cmake.org/u/JMH)\
**Post date:** [April 22, 2022, 4:29pm UTC](https://discourse.cmake.org/t/suspected-bug-with-pch-reuse-from-with-visual-studio-2017/5520/1 "2022-04-22T16:29:01Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [April 28, 2022, 2:49am UTC](https://discourse.cmake.org/t/suspected-bug-with-pch-reuse-from-with-visual-studio-2017/5520/2 "2022-04-28T02:49:37Z")

</div>

@cristianadam would be best placed to comment on this. I believe there has been some activity around PCH handling in recent releases, but if you still see the problem on master, that suggests there’s still more bugs to chase down.
