From ac97ab1abf9bf073088925755a46f08f38721090 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 8 Apr 2024 13:43:13 +0200 Subject: [PATCH] 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 --- .../fileapidataextractor.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index 99d37e6c83b..a4e94e334a2 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -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 &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 generateBuildTargets(const QFuture &cancelF const FilePath &buildDirectory, bool relativeLibs) { + QSet artifacts; + for (const TargetDetails &t : input.targetDetails) + for (const FilePath &p: t.artifacts) + artifacts.insert(buildDirectory.resolvePath(p)); + QList 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; }