forked from qt-creator/qt-creator
CMake: Fix parsing of C++ defines
Partially revert 20cfccd753 that somehow
assumed that compiler flags would also include the defines.
See comment on
Task-number: QTCREATORBUG-3922
Change-Id: Ic7cb9dfa33f53fde9302f38018102c15cb12f83d
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -353,6 +353,7 @@ bool CMakeProject::parseCMakeLists()
|
|||||||
|
|
||||||
QByteArray allDefines;
|
QByteArray allDefines;
|
||||||
allDefines.append(tc->predefinedMacros(cxxflags));
|
allDefines.append(tc->predefinedMacros(cxxflags));
|
||||||
|
allDefines.append(cbpparser.defines());
|
||||||
|
|
||||||
QStringList allFrameworkPaths;
|
QStringList allFrameworkPaths;
|
||||||
QList<ProjectExplorer::HeaderPath> allHeaderPaths;
|
QList<ProjectExplorer::HeaderPath> allHeaderPaths;
|
||||||
@@ -1215,8 +1216,18 @@ void CMakeCbpParser::parseAdd()
|
|||||||
|
|
||||||
QString compilerOption = addAttributes.value(QLatin1String("option")).toString();
|
QString compilerOption = addAttributes.value(QLatin1String("option")).toString();
|
||||||
// defining multiple times a macro to the same value makes no sense
|
// defining multiple times a macro to the same value makes no sense
|
||||||
if (!compilerOption.isEmpty() && !m_compilerOptions.contains(compilerOption))
|
if (!compilerOption.isEmpty() && !m_compilerOptions.contains(compilerOption)) {
|
||||||
m_compilerOptions.append(compilerOption);
|
m_compilerOptions.append(compilerOption);
|
||||||
|
int macroNameIndex = compilerOption.indexOf(QLatin1String("-D")) + 2;
|
||||||
|
if (macroNameIndex != 1) {
|
||||||
|
int assignIndex = compilerOption.indexOf(QLatin1Char('='), macroNameIndex);
|
||||||
|
if (assignIndex != -1)
|
||||||
|
compilerOption[assignIndex] = ' ';
|
||||||
|
m_defines.append("#define ");
|
||||||
|
m_defines.append(compilerOption.mid(macroNameIndex).toLatin1());
|
||||||
|
m_defines.append('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (!atEnd()) {
|
while (!atEnd()) {
|
||||||
readNext();
|
readNext();
|
||||||
@@ -1314,6 +1325,11 @@ QStringList CMakeCbpParser::includeFiles()
|
|||||||
return m_includeFiles;
|
return m_includeFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray CMakeCbpParser::defines() const
|
||||||
|
{
|
||||||
|
return m_defines;
|
||||||
|
}
|
||||||
|
|
||||||
QList<CMakeBuildTarget> CMakeCbpParser::buildTargets()
|
QList<CMakeBuildTarget> CMakeCbpParser::buildTargets()
|
||||||
{
|
{
|
||||||
return m_buildTargets;
|
return m_buildTargets;
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ public:
|
|||||||
QList<ProjectExplorer::FileNode *> cmakeFileList();
|
QList<ProjectExplorer::FileNode *> cmakeFileList();
|
||||||
QStringList includeFiles();
|
QStringList includeFiles();
|
||||||
QList<CMakeBuildTarget> buildTargets();
|
QList<CMakeBuildTarget> buildTargets();
|
||||||
|
QByteArray defines() const;
|
||||||
QString projectName() const;
|
QString projectName() const;
|
||||||
QString compilerName() const;
|
QString compilerName() const;
|
||||||
bool hasCMakeFiles();
|
bool hasCMakeFiles();
|
||||||
@@ -188,6 +189,7 @@ private:
|
|||||||
bool m_parsingCmakeUnit;
|
bool m_parsingCmakeUnit;
|
||||||
QStringList m_includeFiles;
|
QStringList m_includeFiles;
|
||||||
QStringList m_compilerOptions;
|
QStringList m_compilerOptions;
|
||||||
|
QByteArray m_defines;
|
||||||
|
|
||||||
CMakeBuildTarget m_buildTarget;
|
CMakeBuildTarget m_buildTarget;
|
||||||
QList<CMakeBuildTarget> m_buildTargets;
|
QList<CMakeBuildTarget> m_buildTargets;
|
||||||
|
|||||||
Reference in New Issue
Block a user