Found, according to rumors, an undocumented configuration qmake , which allows to place object files in separate folders in accordance with the structure of the project itself.
CONFIG += object_parallel_to_source This is necessary when you keep several classes with the same name in different namespaces in order to have the same file name for these classes in different directories (it’s really silly to create different file names each time).
If these classes are not inherited from QObject everything works fine, but in the opposite case qmake creates moc_ClassName (.cpp .h) files for which the rule for object files does not work, that is, everything is thrown into one directory.
Suppose we created two ActionDouble classes in two different namespaces and folders:
namespace Concept002 { class ActionDouble : public Action { Q_OBJECT public: ActionDouble(QObject *parent = 0); ... }; } and
namespace Concept003 { class ActionDouble : public Action { Q_OBJECT public: explicit ActionDouble(QObject *parent = 0); ... signals: public slots: }; } We get warnings and errors:
warning: overriding recipe for target 'moc_ActionDouble.cpp'
warning: ignoring old recipe for target 'moc_ActionDouble.cpp'
and as a consequence:
error: undefined reference to `vtable for Concept002 :: ActionDouble '
Actually, this is the question, can anyone know the qmake configuration flag (or another way to solve the above problem is to have several classes in different folders and different namespaces with the same name and inherited from QObject ), which allows generating moc_ files in different folders in accordance with the structure of the project. Or, for example, it can be possible to form mocks as moc_Namespace_ClassName ?