summaryrefslogtreecommitdiff
path: root/src/plugins/cmakeprojectmanager/cmakeproject.cpp
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2013-03-11 17:15:54 +0100
committerDaniel Teske <daniel.teske@digia.com>2013-03-19 13:57:18 +0100
commit018083ee12e9bc7bfa18491d3a592a18bc50ee1e (patch)
tree34dc106ed76146d17b8d2f407f3f0850bd9f8e46 /src/plugins/cmakeprojectmanager/cmakeproject.cpp
parentb2d9290c40fa8b9aef49e3935211453d6dec8fc8 (diff)
downloadqt-creator-018083ee12e9bc7bfa18491d3a592a18bc50ee1e.tar.gz
CMake: Fix parsing of C++ defines
Partially revert 20cfccd7533fb68cc9759c015a2b6573d167581c 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>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeproject.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index be9ce97c48..310a0ff8f7 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -353,6 +353,7 @@ bool CMakeProject::parseCMakeLists()
QByteArray allDefines;
allDefines.append(tc->predefinedMacros(cxxflags));
+ allDefines.append(cbpparser.defines());
QStringList allFrameworkPaths;
QList<ProjectExplorer::HeaderPath> allHeaderPaths;
@@ -1215,8 +1216,18 @@ void CMakeCbpParser::parseAdd()
QString compilerOption = addAttributes.value(QLatin1String("option")).toString();
// 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);
+ 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()) {
readNext();
@@ -1314,6 +1325,11 @@ QStringList CMakeCbpParser::includeFiles()
return m_includeFiles;
}
+QByteArray CMakeCbpParser::defines() const
+{
+ return m_defines;
+}
+
QList<CMakeBuildTarget> CMakeCbpParser::buildTargets()
{
return m_buildTargets;