MOC produces parse error with MSVC/CMake/qt5_wrap_cpp when handling a plugin interface
-
Problem:
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. 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 why moc can't parse it. Even more confusing is, that if I enable CMAKE_AUTOMOC, then suddenly the problem goes away.
Preferably I'd like to build without the CMAKE_AUTOMOC: what am I missing here? Why does the direct approach not work? (also qt5_generate_moc fails in the same way). My feeling is that my code is correct, because it does work with automoccing.