Visual Studio Tools 2.3.1 with precompiled headers
-
I'm building a brand new VS2017 project with the VS addin version 2.3.1 installed. My project is set up to use precompiled headers; and my source files are being imported, having previously been successfully compiled in VS2015 and MinGW. In particular, each of my .cpp files which implements a class for which Q_OBJECT is defined contains the line
#include "moc_myClassName.cpp"
...at the end, where of course 'myClassName' is a placeholder for whatever the actual name of the file is.
The Qt addin correctly generates the custom build line for each header containing Q_OBJECT so that moc is run and the appropriate moc_*.cpp file is generated.
Here is where the problems start, though. What should happen is that, when the moc_*.cpp file is included at the end the class's own .cpp file, because the first line of that file is
#include "stdafx.h"
...the whole file, including the moc_*.cpp part at the end, should be compiled with the precompiled header included.
What actually happens is that the compiler goes ahead and tries to compile the moc_*.cpp file in its own right anyway. Because that file doesn't contain
#include "stdafx.h"
the result is an entirely predictable error message:
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
I cannot for the life of me see why the project is trying to compile the moc files in their own right, rather than just relying on the fact that they're included with the classes' .cpp files. The moc files are nowhere to be seen in the Solution Explorer, not even under the 'Generated Files' folder. I have delved in the .vcxproj file and I cannot find these moc_*.cpp files listed anywhere amongst the list of files to be compiled.
My question, therefore, is: why is the compiler trying to compile moc files which it hasn't been asked to compile and shouldn't be compiling, and how do I stop it from doing so?