diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 1608a454d60..875971a1cfa 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -300,7 +300,7 @@ void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter) emit progress(percent, {}); }); formatter->addLineParser(progressParser); - cmakeParser->setSourceDirectory(project()->projectDirectory().toString()); + cmakeParser->setSourceDirectory(project()->projectDirectory()); formatter->addLineParsers({cmakeParser, new GnuMakeParser}); ToolChain *tc = ToolChainKitAspect::cxxToolChain(kit()); OutputTaskParser *xcodeBuildParser = nullptr; diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.cpp b/src/plugins/cmakeprojectmanager/cmakeparser.cpp index e4a1c7b093e..1b6573869dc 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeparser.cpp @@ -32,12 +32,19 @@ CMakeParser::CMakeParser() QTC_CHECK(m_locationLine.isValid()); } -void CMakeParser::setSourceDirectory(const QString &sourceDir) +void CMakeParser::setSourceDirectory(const FilePath &sourceDir) { if (m_sourceDirectory) - emit searchDirExpired(FilePath::fromString(m_sourceDirectory.value().path())); - m_sourceDirectory = QDir(sourceDir); - emit newSearchDirFound(FilePath::fromString(sourceDir)); + emit searchDirExpired(m_sourceDirectory.value()); + m_sourceDirectory = sourceDir; + emit newSearchDirFound(sourceDir); +} + +FilePath CMakeParser::resolvePath(const QString &path) const +{ + if (m_sourceDirectory) + return m_sourceDirectory->resolvePath(path); + return FilePath::fromUserInput(path); } OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputFormat type) @@ -69,12 +76,11 @@ OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputForm match = m_commonError.match(trimmedLine); if (match.hasMatch()) { - QString path = m_sourceDirectory ? m_sourceDirectory->absoluteFilePath( - QDir::fromNativeSeparators(match.captured(1))) - : QDir::fromNativeSeparators(match.captured(1)); + const FilePath path = resolvePath(match.captured(1)); + m_lastTask = BuildSystemTask(Task::Error, QString(), - absoluteFilePath(FilePath::fromUserInput(path)), + absoluteFilePath(path), match.captured(2).toInt()); m_lines = 1; LinkSpecs linkSpecs; @@ -94,12 +100,10 @@ OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputForm } match = m_commonWarning.match(trimmedLine); if (match.hasMatch()) { - QString path = m_sourceDirectory ? m_sourceDirectory->absoluteFilePath( - QDir::fromNativeSeparators(match.captured(2))) - : QDir::fromNativeSeparators(match.captured(2)); + const FilePath path = resolvePath(match.captured(2)); m_lastTask = BuildSystemTask(Task::Warning, QString(), - absoluteFilePath(FilePath::fromUserInput(path)), + absoluteFilePath(path), match.captured(3).toInt()); m_lines = 1; LinkSpecs linkSpecs; diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.h b/src/plugins/cmakeprojectmanager/cmakeparser.h index 686840575ee..e9d28b78e75 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.h +++ b/src/plugins/cmakeprojectmanager/cmakeparser.h @@ -8,7 +8,8 @@ #include #include -#include +#include + #include #include @@ -21,17 +22,18 @@ class CMAKE_EXPORT CMakeParser : public ProjectExplorer::OutputTaskParser public: explicit CMakeParser(); - void setSourceDirectory(const QString &sourceDir); + void setSourceDirectory(const Utils::FilePath &sourceDir); private: Result handleLine(const QString &line, Utils::OutputFormat type) override; void flush() override; + Utils::FilePath resolvePath(const QString &path) const; enum TripleLineError { NONE, LINE_LOCATION, LINE_DESCRIPTION, LINE_DESCRIPTION2 }; TripleLineError m_expectTripleLineErrorData = NONE; - std::optional m_sourceDirectory; + std::optional m_sourceDirectory; ProjectExplorer::Task m_lastTask; QRegularExpression m_commonError; QRegularExpression m_nextSubError; @@ -41,4 +43,4 @@ private: int m_lines = 0; }; -} // namespace CMakeProjectManager +} // CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index ce089733632..4960b2e5c09 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -97,7 +97,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & } const auto parser = new CMakeParser; - parser->setSourceDirectory(parameters.sourceDirectory.path()); + parser->setSourceDirectory(parameters.sourceDirectory); m_parser.addLineParser(parser); // Always use the sourceDir: If we are triggered because the build directory is getting deleted