MOC produces parse error with MSVC/CMake/qt5_wrap_cpp when handling a plugin interface
-
My problem using qt 5.4.0/MSVC 2013/cmake 3.2.2 (but also with 3.1.3):
I have a build infrastructure based on CMake, and try to build a plugin is MSVC2013. In the CMake file I write qt5_wrap_cpp(SOME_NAME ${PLUGIN_HEADER}) where the ${PLUGIN_HEADER} refers to the header file for the plugin, which declares the plugin interface, including the Q_OBJECT, Q_PLUGIN_METADATA and Q_INTERFACES macros. If it matters: the plugin interface itself is inside a namespace, the interface it implements is in a different namespace.
When building, and the build system tries to create the moc_-file corresponding to the ${PLUGIN_HEADER}, it complains about: 'Parse error at "IID"'. It also tells the line, which is the line where the Q_PLUGIN_METADATA macro is used.
So, it is pretty obvious what the complaint is about, namely the 'IID' tag I have to pass to that macro, but it is not clear to me why moc can't parse it. Even more confusing is: if I enable CMAKE_AUTOMOC, then suddenly the problem goes away.
Preferably I'd like to build without the CMAKE_AUTOMOC, so what am I missing here? Why does the direct approach not work? (btw: qt5_generate_moc fails in the same way). My feeling is that my code is correct, because it does work with automoccing. Have I stumbled upon some bug?