forked from qt-creator/qt-creator
CMakeProjectManager: Add lib and app binaries to project tree
Task-number: QTCREATORBUG-28815 Change-Id: I58ebcd2a6935eb4b6746b5fd58e6ab8b97fdef43 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -198,6 +198,10 @@ void CMakeTargetNode::setTargetInformation(const QList<FilePath> &artifacts, con
|
||||
m_tooltip += Tr::tr("Build artifacts:") + "<br>" + tmp.join("<br>");
|
||||
m_artifact = artifacts.first();
|
||||
}
|
||||
if (type == "EXECUTABLE")
|
||||
setProductType(ProductType::App);
|
||||
else if (type == "SHARED_LIBRARY" || type == "STATIC_LIBRARY")
|
||||
setProductType(ProductType::Lib);
|
||||
}
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -605,6 +605,28 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
std::move(otherFileNodes));
|
||||
}
|
||||
|
||||
static void addGeneratedFilesNode(ProjectNode *targetRoot, const FilePath &topLevelBuildDir,
|
||||
const TargetDetails &td)
|
||||
{
|
||||
if (td.artifacts.isEmpty())
|
||||
return;
|
||||
FileType type = FileType::Unknown;
|
||||
if (td.type == "EXECUTABLE")
|
||||
type = FileType::App;
|
||||
else if (td.type == "SHARED_LIBRARY" || td.type == "STATIC_LIBRARY")
|
||||
type = FileType::Lib;
|
||||
if (type == FileType::Unknown)
|
||||
return;
|
||||
std::vector<std::unique_ptr<FileNode>> nodes;
|
||||
const FilePath buildDir = topLevelBuildDir.resolvePath(td.buildDir);
|
||||
for (const FilePath &artifact : td.artifacts) {
|
||||
nodes.emplace_back(new FileNode(buildDir.resolvePath(artifact), type));
|
||||
type = FileType::Unknown;
|
||||
nodes.back()->setIsGenerated(true);
|
||||
}
|
||||
addCMakeVFolder(targetRoot, buildDir, 10, Tr::tr("<Generated Files>"), std::move(nodes));
|
||||
}
|
||||
|
||||
void addTargets(const QHash<Utils::FilePath, ProjectExplorer::ProjectNode *> &cmakeListsNodes,
|
||||
const Configuration &config,
|
||||
const std::vector<TargetDetails> &targetDetails,
|
||||
@@ -635,6 +657,7 @@ void addTargets(const QHash<Utils::FilePath, ProjectExplorer::ProjectNode *> &cm
|
||||
tNode->setBuildDirectory(directoryBuildDir(config, buildDir, t.directory));
|
||||
|
||||
addCompileGroups(tNode, sourceDir, dir, tNode->buildDirectory(), td);
|
||||
addGeneratedFilesNode(tNode, buildDir, td);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,8 @@ public:
|
||||
const QString &batchFile,
|
||||
const QString &batchArgs,
|
||||
QMap<QString, QString> &envPairs);
|
||||
bool environmentInitialized() const { return !m_environmentModifications.isEmpty(); }
|
||||
|
||||
protected:
|
||||
class WarningFlagAdder
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "environmentaspect.h"
|
||||
#include "kit.h"
|
||||
#include "kitinformation.h"
|
||||
#include "msvctoolchain.h"
|
||||
#include "projectexplorer.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorertr.h"
|
||||
@@ -20,6 +21,7 @@
|
||||
#include "runconfigurationaspects.h"
|
||||
#include "target.h"
|
||||
#include "taskhub.h"
|
||||
#include "toolchainmanager.h"
|
||||
#include "userfileaccessor.h"
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
@@ -1514,10 +1516,20 @@ void ProjectExplorerPlugin::testSourceToBinaryMapping()
|
||||
{
|
||||
// Find suitable kit.
|
||||
Kit * const kit = findOr(KitManager::kits(), nullptr, [](const Kit *k) {
|
||||
return k->isValid();
|
||||
return k->isValid() && ToolChainKitAspect::cxxToolChain(k);
|
||||
});
|
||||
if (!kit)
|
||||
QSKIP("The test requires at least one valid kit.");
|
||||
QSKIP("The test requires at least one kit with a toolchain.");
|
||||
|
||||
const auto toolchain = ToolChainKitAspect::cxxToolChain(kit);
|
||||
QVERIFY(toolchain);
|
||||
if (const auto msvcToolchain = dynamic_cast<Internal::MsvcToolChain *>(toolchain)) {
|
||||
while (!msvcToolchain->environmentInitialized()) {
|
||||
QSignalSpy parsingFinishedSpy(ToolChainManager::instance(),
|
||||
&ToolChainManager::toolChainUpdated);
|
||||
QVERIFY(parsingFinishedSpy.wait(10000));
|
||||
}
|
||||
}
|
||||
|
||||
// Copy project from qrc.
|
||||
QTemporaryDir * const tempDir = TemporaryDirectory::masterTemporaryDirectory();
|
||||
@@ -1569,7 +1581,6 @@ void ProjectExplorerPlugin::testSourceToBinaryMapping()
|
||||
const auto binariesForSource = [&](const QString &fileName) {
|
||||
return theProject.project()->binariesForSourceFile(projectDir.pathAppended(fileName));
|
||||
};
|
||||
QEXPECT_FAIL("cmake", "QTCREATORBUG-28815", Abort);
|
||||
QCOMPARE(binariesForSource("multi-target-project-main.cpp").size(), 1);
|
||||
QCOMPARE(binariesForSource("multi-target-project-lib.cpp").size(), 1);
|
||||
QCOMPARE(binariesForSource("multi-target-project-shared.h").size(), 2);
|
||||
|
||||
Reference in New Issue
Block a user