Autogen: Run moc for AUTOMOC_MACRO_NAMES keywords regardless of their position in the line
According to the documentation, CMake
should run moc
on files that contain any of the keywords stored in AUTOMOC_MACRO_NAMES
(by default: Q_OBJECT;Q_GADGET;Q_NAMESPACE;Q_NAMESPACE_EXPORT
).
However, if any of those keywords is not on its own line, CMake
fails to run moc
on the file.
For example, the following code won't generate a moc_xyz.cpp
file:
#ifndef ENUM_H
#define ENUM_H
#include "enumLib.h"
#include <QObject>
namespace EnumNamespace {
ENUMLIB_EXPORT Q_NAMESPACE
enum MyEnum : unsigned int
{
ZERO = 0,
ONE,
TWO
};
Q_ENUM_NS(MyEnum);
}
#endif // ENUM_H
but this one will:
#ifndef ENUM_H
#define ENUM_H
#include "enumLib.h"
#include <QObject>
namespace EnumNamespace {
ENUMLIB_EXPORT
Q_NAMESPACE
enum MyEnum : unsigned int
{
ZERO = 0,
ONE,
TWO
};
Q_ENUM_NS(MyEnum);
}
#endif // ENUM_H
Edited by Adri C