CMake: Fix deployment path

Previously the path would be created based on the build device
instead of the target device. Therefore when building on windows with a
linux target the path might become "c:\usr\bin\..." instead of
"/usr/bin/...".

Fixes: QTCREATORBUG-29797
Change-Id: I13a9941b87b863f3e1b8420bcab230db1f70a28b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-24 09:15:02 +02:00
parent 022847c852
commit cca7bc98a9

View File

@@ -775,22 +775,23 @@ void CMakeBuildStep::updateDeploymentData()
DeploymentData deploymentData;
deploymentData.setLocalInstallRoot(rootDir);
IDeviceConstPtr device = BuildDeviceKitAspect::device(buildSystem()->kit());
IDeviceConstPtr runDevice = DeviceKitAspect::device(buildSystem()->kit());
const auto appFileNames = transform<QSet<QString>>(buildSystem()->applicationTargets(),
[](const BuildTargetInfo &appTarget) { return appTarget.targetFilePath.fileName(); });
auto handleFile = [&appFileNames, rootDir, &deploymentData, device](const FilePath &filePath) {
const DeployableFile::Type type = appFileNames.contains(filePath.fileName())
? DeployableFile::TypeExecutable
: DeployableFile::TypeNormal;
auto handleFile =
[&appFileNames, rootDir, &deploymentData, runDevice](const FilePath &filePath) {
const DeployableFile::Type type = appFileNames.contains(filePath.fileName())
? DeployableFile::TypeExecutable
: DeployableFile::TypeNormal;
FilePath targetDirPath = filePath.parentDir().relativePathFrom(rootDir);
FilePath targetDirPath = filePath.parentDir().relativePathFrom(rootDir);
const FilePath targetDir = device->rootPath().pathAppended(targetDirPath.path());
deploymentData.addFile(filePath, targetDir.nativePath(), type);
return IterationPolicy::Continue;
};
const FilePath targetDir = runDevice->rootPath().pathAppended(targetDirPath.path());
deploymentData.addFile(filePath, targetDir.nativePath(), type);
return IterationPolicy::Continue;
};
rootDir.iterateDirectory(handleFile,
{{}, QDir::Files | QDir::Hidden, QDirIterator::Subdirectories});