when building a subcomponent of a static library, some.lib. The problem is that when I try to link to some.lib, I get a LNK2011: precompiled header not linked in, naming a seemingly random file from the directory of some_target. (Gotta love Windows).
I have a file in the target called _pch.cpp that includes _pch.h, whiich was the way I used it with Cotire.
However, I don’t think _pch.cpp.obj is the precompiled header object, as it is only 3kb. It seems to be some_target/CMakeFiles/some_target.dir/CMakeFiles/some_target.dir/cmake_pch.cxx.obj
However, this approach sounds counter intuitive to me. It seems like this inclusion should happen automatically, at least on Windows with Ninja.
NOTE: On Linux there is no problem.
Actually, this approach does not work, since ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/some_target.dir/cmake_pch.cxx will not exist at the time of CMake configuration.
LNK2011: (.../somelib1file.cpp) precompiled header not linked in, image may not run
LNK2011: (.../somelib2file.cpp) precompiled header not linked in, image may not run
However, I discovered that if I just made ONE of those subdirectory precompiled headers PUBLIC the shared library would link to it.
So, my solution was to generate a bogus/empty precompiled header for the STATIC library, and that seemed to rectify the problem.