RemoteLinux: Allow adding Qt to LD_LIBRARY_PATH

When running on the remote build device. And make it work with CMake.

Change-Id: If25bef8ab836c1d59a586116b3c3447a29c4e7e8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-10-18 09:31:47 +02:00
parent 50979f1606
commit e9ed3d6d05
2 changed files with 20 additions and 6 deletions

View File

@@ -264,18 +264,18 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
continue; continue;
const FilePath buildDir = haveLibrariesRelativeToBuildDirectory ? buildDirectory : currentBuildDir; const FilePath buildDir = haveLibrariesRelativeToBuildDirectory ? buildDirectory : currentBuildDir;
FilePath tmp = buildDir.resolvePath(FilePath::fromUserInput(part)); FilePath tmp = buildDir.resolvePath(FilePath::fromUserInput(part).onDevice(buildDir));
if (f.role == "libraries") if (f.role == "libraries")
tmp = tmp.parentDir(); tmp = tmp.parentDir();
if (!tmp.isEmpty() && tmp.isDir()) { if (!tmp.isEmpty() && tmp.isDir()) {
// f.role is libraryPath or frameworkPath // f.role is libraryPath or frameworkPath
// On Linux, exclude sub-paths from "/lib(64)", "/usr/lib(64)" and // On *nix, exclude sub-paths from "/lib(64)", "/usr/lib(64)" and
// "/usr/local/lib" since these are usually in the standard search // "/usr/local/lib" since these are usually in the standard search
// paths. There probably are more, but the naming schemes are arbitrary // paths. There probably are more, but the naming schemes are arbitrary
// so we'd need to ask the linker ("ld --verbose | grep SEARCH_DIR"). // so we'd need to ask the linker ("ld --verbose | grep SEARCH_DIR").
if (!HostOsInfo::isLinuxHost() if (buildDir.osType() == OsTypeWindows
|| !isChildOf(tmp, || !isChildOf(tmp,
{"/lib", {"/lib",
"/lib64", "/lib64",
@@ -285,9 +285,8 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
librarySeachPaths.append(tmp); librarySeachPaths.append(tmp);
// Libraries often have their import libs in ../lib and the // Libraries often have their import libs in ../lib and the
// actual dll files in ../bin on windows. Qt is one example of that. // actual dll files in ../bin on windows. Qt is one example of that.
if (tmp.fileName() == "lib" && HostOsInfo::isWindowsHost()) { if (tmp.fileName() == "lib" && buildDir.osType() == OsTypeWindows) {
const FilePath path = tmp.parentDir().pathAppended("bin"); const FilePath path = tmp.parentDir().pathAppended("bin");
if (path.isDir()) if (path.isDir())
librarySeachPaths.append(path); librarySeachPaths.append(path);
} }

View File

@@ -53,13 +53,22 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<X11ForwardingAspect>(macroExpander()); addAspect<X11ForwardingAspect>(macroExpander());
setUpdater([this, target, exeAspect, symbolsAspect] { auto libAspect = addAspect<UseLibraryPathsAspect>();
libAspect->setValue(false);
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
setUpdater([this, target, exeAspect, symbolsAspect, libAspect] {
BuildTargetInfo bti = buildTargetInfo(); BuildTargetInfo bti = buildTargetInfo();
const FilePath localExecutable = bti.targetFilePath; const FilePath localExecutable = bti.targetFilePath;
DeployableFile depFile = target->deploymentData().deployableForLocalFile(localExecutable); DeployableFile depFile = target->deploymentData().deployableForLocalFile(localExecutable);
exeAspect->setExecutable(FilePath::fromString(depFile.remoteFilePath())); exeAspect->setExecutable(FilePath::fromString(depFile.remoteFilePath()));
symbolsAspect->setFilePath(localExecutable); symbolsAspect->setFilePath(localExecutable);
const IDeviceConstPtr buildDevice = BuildDeviceKitAspect::device(target->kit());
const IDeviceConstPtr runDevice = DeviceKitAspect::device(target->kit());
libAspect->setEnabled(buildDevice == runDevice);
}); });
setRunnableModifier([this](Runnable &r) { setRunnableModifier([this](Runnable &r) {
@@ -67,6 +76,12 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display()); r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display());
}); });
envAspect->addModifier([this, libAspect](Environment &env) {
BuildTargetInfo bti = buildTargetInfo();
if (bti.runEnvModifier)
bti.runEnvModifier(env, libAspect->value());
});
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update); connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update);
connect(target, &Target::kitChanged, this, &RunConfiguration::update); connect(target, &Target::kitChanged, this, &RunConfiguration::update);