forked from qt-creator/qt-creator
CMakePM: Add build artifacts to the PATH env variable
Projects that have dll artifacts need to have the build paths added to PATH so that the dependent executables would start. Previously the code checked only if the dlls were present on disk, now it also checks if the dlls are part of the project's build artifacts. Fixes: QTCREATORBUG-30644 Change-Id: I924753ffaf0a9720acb70585ccd589abab1b9cc1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -209,7 +209,8 @@ static bool isChildOf(const FilePath &path, const FilePaths &prefixes)
|
||||
static CMakeBuildTarget toBuildTarget(const TargetDetails &t,
|
||||
const FilePath &sourceDirectory,
|
||||
const FilePath &buildDirectory,
|
||||
bool relativeLibs)
|
||||
bool relativeLibs,
|
||||
const QSet<FilePath> &artifacts)
|
||||
{
|
||||
const FilePath currentBuildDir = buildDirectory.resolvePath(t.buildDir);
|
||||
|
||||
@@ -341,14 +342,17 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t,
|
||||
librarySeachPaths.append(tmp);
|
||||
|
||||
if (buildDir.osType() == OsTypeWindows && dllName) {
|
||||
if (tmp.pathAppended(*dllName).exists())
|
||||
const auto validPath = [&artifacts](const FilePath& path) {
|
||||
return path.exists() || artifacts.contains(path);
|
||||
};
|
||||
if (validPath(tmp.pathAppended(*dllName)))
|
||||
librarySeachPaths.append(tmp);
|
||||
|
||||
// Libraries often have their import libs in ../lib and the
|
||||
// actual dll files in ../bin on windows. Qt is one example of that.
|
||||
if (tmp.fileName() == "lib" && buildDir.osType() == OsTypeWindows) {
|
||||
if (tmp.fileName() == "lib") {
|
||||
const FilePath path = tmp.parentDir().pathAppended("bin");
|
||||
if (path.isDir() && path.pathAppended(*dllName).exists())
|
||||
if (path.isDir() && validPath(path.pathAppended(*dllName)))
|
||||
librarySeachPaths.append(path);
|
||||
}
|
||||
}
|
||||
@@ -367,12 +371,17 @@ static QList<CMakeBuildTarget> generateBuildTargets(const QFuture<void> &cancelF
|
||||
const FilePath &buildDirectory,
|
||||
bool relativeLibs)
|
||||
{
|
||||
QSet<FilePath> artifacts;
|
||||
for (const TargetDetails &t : input.targetDetails)
|
||||
for (const FilePath &p: t.artifacts)
|
||||
artifacts.insert(buildDirectory.resolvePath(p));
|
||||
|
||||
QList<CMakeBuildTarget> result;
|
||||
result.reserve(input.targetDetails.size());
|
||||
for (const TargetDetails &t : input.targetDetails) {
|
||||
if (cancelFuture.isCanceled())
|
||||
return {};
|
||||
result.append(toBuildTarget(t, sourceDirectory, buildDirectory, relativeLibs));
|
||||
result.append(toBuildTarget(t, sourceDirectory, buildDirectory, relativeLibs, artifacts));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user