CMake: Fix working directory for targets in fileapi mode

Prepend the full path to the build directory.

Change-Id: I55111b656fd4b99ee68517c09117f142e88947b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2019-07-26 11:37:13 +02:00
parent d2796546a4
commit 4daba5a9fa

View File

@@ -172,47 +172,45 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
QDir sourceDir(sourceDirectory.toString()); QDir sourceDir(sourceDirectory.toString());
QDir buildDir(buildDirectory.toString()); QDir buildDir(buildDirectory.toString());
const QList<CMakeBuildTarget> result = transform< const QList<CMakeBuildTarget> result = transform<QList>(
QList>(input.targetDetails, [&sourceDir, &buildDir](const TargetDetails &t) -> CMakeBuildTarget { input.targetDetails, [&sourceDir, &buildDir](const TargetDetails &t) -> CMakeBuildTarget {
CMakeBuildTarget ct; CMakeBuildTarget ct;
ct.title = t.name; ct.title = t.name;
ct.executable = t.artifacts.isEmpty() ct.executable = t.artifacts.isEmpty()
? FilePath() ? FilePath()
: FilePath::fromString(QDir::cleanPath( : FilePath::fromString(QDir::cleanPath(
buildDir.absoluteFilePath(t.artifacts.at(0).toString()))); buildDir.absoluteFilePath(t.artifacts.at(0).toString())));
TargetType type = UtilityType; TargetType type = UtilityType;
if (t.type == "EXECUTABLE") if (t.type == "EXECUTABLE")
type = ExecutableType; type = ExecutableType;
else if (t.type == "STATIC_LIBRARY") else if (t.type == "STATIC_LIBRARY")
type = StaticLibraryType; type = StaticLibraryType;
else if (t.type == "OBJECT_LIBRARY") else if (t.type == "OBJECT_LIBRARY")
type = ObjectLibraryType; type = ObjectLibraryType;
else if (t.type == "MODULE_LIBRARY" || t.type == "SHARED_LIBRARY") else if (t.type == "MODULE_LIBRARY" || t.type == "SHARED_LIBRARY")
type = DynamicLibraryType; type = DynamicLibraryType;
else else
type = UtilityType; type = UtilityType;
ct.targetType = type; ct.targetType = type;
if (t.artifacts.isEmpty()) { ct.workingDirectory = ct.executable.isEmpty() ? FilePath::fromString(
ct.workingDirectory = t.buildDir; buildDir.absoluteFilePath(t.buildDir.toString()))
} else { : ct.executable.parentDir();
ct.workingDirectory = FilePath::fromString(QDir::cleanPath( ct.sourceDirectory = FilePath::fromString(
QDir(t.buildDir.toString()).absoluteFilePath(t.artifacts.at(0).toString() + "/.."))); QDir::cleanPath(sourceDir.absoluteFilePath(t.sourceDir.toString())));
}
ct.sourceDirectory = FilePath::fromString(
QDir::cleanPath(sourceDir.absoluteFilePath(t.sourceDir.toString())));
if (t.backtrace >= 0) { if (t.backtrace >= 0) {
const BacktraceNode &node = t.backtraceGraph.nodes[static_cast<size_t>(t.backtrace)]; const BacktraceNode &node = t.backtraceGraph.nodes[static_cast<size_t>(t.backtrace)];
const int fileIndex = node.file; const int fileIndex = node.file;
if (fileIndex >= 0) { if (fileIndex >= 0) {
ct.definitionFile = FilePath::fromString(QDir::cleanPath(sourceDir.absoluteFilePath( ct.definitionFile = FilePath::fromString(
t.backtraceGraph.files[static_cast<size_t>(fileIndex)]))); QDir::cleanPath(sourceDir.absoluteFilePath(
ct.definitionLine = node.line; t.backtraceGraph.files[static_cast<size_t>(fileIndex)])));
ct.definitionLine = node.line;
}
} }
}
return ct; return ct;
}); });
return result; return result;
} }