From 763c4267e03f91c5c3a8c3e1eddd6b4477789707 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Wed, 8 Apr 2015 17:14:04 +0200 Subject: [PATCH] CMake: Tweak detecting of right project part Don't consider targets that end in _unittest or _automoc. Also don't read CMakeDirectoryInformation.cmake as that doesn't work with add_subdirectory. Change-Id: If06af60e1637e94cccd32d09fc26c6b87488671b Task-number: QTCREATORBUG-12183 Reviewed-by: Tobias Hunger --- .../cmakeprojectmanager/cmakeproject.cpp | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 08e287fe8e2..4ae5adf4801 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -1029,7 +1029,9 @@ void CMakeCbpParser::parseBuildTarget() while (!atEnd()) { readNext(); if (isEndElement()) { - if (!m_buildTarget.title.endsWith(QLatin1String("/fast"))) + if (!m_buildTarget.title.endsWith(QLatin1String("/fast")) + && !m_buildTarget.title.endsWith(QLatin1String("_automoc")) + && !m_buildTarget.title.endsWith(QLatin1String("_unittest"))) m_buildTargets.append(m_buildTarget); return; } else if (name() == QLatin1String("Compiler")) { @@ -1054,28 +1056,10 @@ void CMakeCbpParser::parseBuildTargetOption() m_buildTarget.targetType = TargetType(value.toInt()); } else if (attributes().hasAttribute(QLatin1String("working_dir"))) { m_buildTarget.workingDirectory = attributes().value(QLatin1String("working_dir")).toString(); - - QFile cmakeSourceInfoFile(m_buildTarget.workingDirectory - + QStringLiteral("/CMakeFiles/CMakeDirectoryInformation.cmake")); - if (cmakeSourceInfoFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream stream(&cmakeSourceInfoFile); - const QLatin1String searchSource("SET(CMAKE_RELATIVE_PATH_TOP_SOURCE \""); - while (!stream.atEnd()) { - const QString lineTopSource = stream.readLine().trimmed(); - if (lineTopSource.startsWith(searchSource)) { - m_buildTarget.sourceDirectory = lineTopSource.mid(searchSource.size()); - m_buildTarget.sourceDirectory.chop(2); // cut off ") - break; - } - } - } - - if (m_buildTarget.sourceDirectory.isEmpty()) { - QDir dir(m_buildDirectory); - const QString relative = dir.relativeFilePath(m_buildTarget.workingDirectory); - m_buildTarget.sourceDirectory - = FileName::fromString(m_sourceDirectory).appendPath(relative).toString(); - } + QDir dir(m_buildDirectory); + const QString relative = dir.relativeFilePath(m_buildTarget.workingDirectory); + m_buildTarget.sourceDirectory + = FileName::fromString(m_sourceDirectory).appendPath(relative).toString(); } while (!atEnd()) { readNext();