From d6d133da42b290183fdefdd080c8b492c3db0227 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 20 Jun 2019 14:00:33 +0200 Subject: [PATCH] CMake server-mode: Make sure the target's source dir is absolute Change-Id: I3c74e3a0ee9c854e4b97826a4397579d4755d8e0 Reviewed-by: hjk --- .../cmakeprojectmanager/servermodereader.cpp | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index 77f2cd8cb4c..abf05be4c8f 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -195,31 +195,35 @@ bool ServerModeReader::isParsing() const QList ServerModeReader::takeBuildTargets(QString &errorMessage) { Q_UNUSED(errorMessage) - const QList result = transform(m_targets, [](const Target *t) -> CMakeBuildTarget { - CMakeBuildTarget ct; - ct.title = t->name; - ct.executable = t->artifacts.isEmpty() ? FilePath() : t->artifacts.at(0); - TargetType type = UtilityType; - if (t->type == "EXECUTABLE") - type = ExecutableType; - else if (t->type == "STATIC_LIBRARY") - type = StaticLibraryType; - else if (t->type == "OBJECT_LIBRARY") - type = ObjectLibraryType; - else if (t->type == "MODULE_LIBRARY" || t->type == "SHARED_LIBRARY" - || t->type == "INTERFACE_LIBRARY") - type = DynamicLibraryType; - else - type = UtilityType; - ct.targetType = type; - if (t->artifacts.isEmpty()) { - ct.workingDirectory = t->buildDirectory; - } else { - ct.workingDirectory = Utils::FilePath::fromString(t->artifacts.at(0).toFileInfo().absolutePath()); - } - ct.sourceDirectory = t->sourceDirectory; - return ct; - }); + QDir topSourceDir(m_parameters.sourceDirectory.toString()); + const QList result + = transform(m_targets, [&topSourceDir](const Target *t) -> CMakeBuildTarget { + CMakeBuildTarget ct; + ct.title = t->name; + ct.executable = t->artifacts.isEmpty() ? FilePath() : t->artifacts.at(0); + TargetType type = UtilityType; + if (t->type == "EXECUTABLE") + type = ExecutableType; + else if (t->type == "STATIC_LIBRARY") + type = StaticLibraryType; + else if (t->type == "OBJECT_LIBRARY") + type = ObjectLibraryType; + else if (t->type == "MODULE_LIBRARY" || t->type == "SHARED_LIBRARY" + || t->type == "INTERFACE_LIBRARY") + type = DynamicLibraryType; + else + type = UtilityType; + ct.targetType = type; + if (t->artifacts.isEmpty()) { + ct.workingDirectory = t->buildDirectory; + } else { + ct.workingDirectory = Utils::FilePath::fromString( + t->artifacts.at(0).toFileInfo().absolutePath()); + } + ct.sourceDirectory = FilePath::fromString( + QDir::cleanPath(topSourceDir.absoluteFilePath(t->sourceDirectory.toString()))); + return ct; + }); m_targets.clear(); return result; }