forked from qt-creator/qt-creator
Clang: Free us from specific Qt versions
More precisely, free us from specific Q_MOC_RUN/QT_NO_META_MACROS code
paths in QtCore/qobjectdefs.h.
In order to track signals and slots we provided custom definitions of
e.g. "Q_SIGNAL" by including qt5-qobjectdefs-injected.h with "-include".
We also had to ensure that those macros were not overwritten by Qt's
qobjectdefs.h, which we did by defining QT_NO_META_MACROS. However, this
came with a cost: we needed to replicate all the other macro definitions
in the Q_MOC_RUN/QT_NO_META_MACROS code path, e.g. Q_INTERFACES. This
bound us to specific versions of qobjectdefs.h and occasionally we had
to adapt (see change 4eafa2e02b).
The new approach wraps Qt's qobjectdefs.h with the help of
"include_next". In the wrapper header, we only redefine what is
necessary.
The "include_next" directive is originally a GNU extension. Clang seems
to support it unconditionally, as [1] implicitly states.
[1] http://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros
Change-Id: Ic1a263f94b178349cb32bfdbb074ad5e6e0761ee
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -130,8 +130,8 @@ public:
|
||||
optionsBuilder.addToolchainAndProjectDefines();
|
||||
|
||||
optionsBuilder.addResourceDirOptions();
|
||||
optionsBuilder.addWrappedQtHeadersIncludePath();
|
||||
optionsBuilder.addHeaderPathOptions();
|
||||
optionsBuilder.addInjectedHeaderWithCustomQtMacros();
|
||||
optionsBuilder.addProjectConfigFileInclude();
|
||||
|
||||
optionsBuilder.addExtraOptions();
|
||||
@@ -160,19 +160,14 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void addInjectedHeaderWithCustomQtMacros()
|
||||
void addWrappedQtHeadersIncludePath()
|
||||
{
|
||||
static const QString injectedHeader = ICore::instance()->resourcePath()
|
||||
+ QLatin1String("/cplusplus/qt%1-qobjectdefs-injected.h");
|
||||
static const QString wrappedQtHeaders = ICore::instance()->resourcePath()
|
||||
+ QLatin1String("/cplusplus/wrappedQtHeaders");
|
||||
|
||||
// if (pPart->qtVersion == ProjectPart::Qt4) {
|
||||
// builder.addOption(QLatin1String("-include"));
|
||||
// builder.addOption(injectedHeader.arg(QLatin1Char('4')));
|
||||
// }
|
||||
|
||||
if (m_projectPart->qtVersion == ProjectPart::Qt5) {
|
||||
add(QLatin1String("-include"));
|
||||
add(injectedHeader.arg(QLatin1Char('5')));
|
||||
if (m_projectPart->qtVersion != ProjectPart::NoQt) {
|
||||
add(QLatin1String("-I") + wrappedQtHeaders);
|
||||
add(QLatin1String("-I") + wrappedQtHeaders + QLatin1String("/QtCore"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user