aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Adam <[email protected]>2023-02-07 18:15:58 +0100
committerCristian Adam <[email protected]>2023-02-08 16:17:49 +0000
commita6ccfb09e588f3500a34b6f240350d77d3403a29 (patch)
tree78f00caca1316e6005dd575fc8d92652c96ead3a
parentf5bd33027756e77890677e32a31f6796ca44481d (diff)
CMakePM: Copy auto package-manager to ${buildDir}/.qtc/ directory
By copying the ${IDE:ResourcePath}/package-manager to ${buildDir}/.qtc/ the problem with hardcoding paths to old an Qt Creator version can no longer occur. This also fixes the issue with remote projects by reffering to the code residing on the host. With the above issues fixed, enable "Package manager auto setup" by default. Change-Id: Ia49654a3b9059f83886e64d065019b2d55e9299c Reviewed-by: <[email protected]> Reviewed-by: Marcus Tillmanns <[email protected]>
-rw-r--r--src/plugins/cmakeprojectmanager/builddirparameters.cpp9
-rw-r--r--src/plugins/cmakeprojectmanager/builddirparameters.h4
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp12
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp3
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprocess.cpp12
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectconstants.h2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp2
7 files changed, 31 insertions, 13 deletions
diff --git a/src/plugins/cmakeprojectmanager/builddirparameters.cpp b/src/plugins/cmakeprojectmanager/builddirparameters.cpp
index 84cfdd3a023..ef7c7f40ca4 100644
--- a/src/plugins/cmakeprojectmanager/builddirparameters.cpp
+++ b/src/plugins/cmakeprojectmanager/builddirparameters.cpp
@@ -14,6 +14,7 @@
#include <projectexplorer/toolchain.h>
#include <utils/algorithm.h>
+#include <utils/macroexpander.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
@@ -28,20 +29,20 @@ BuildDirParameters::BuildDirParameters(CMakeBuildSystem *buildSystem)
auto bc = buildSystem->cmakeBuildConfiguration();
QTC_ASSERT(bc, return);
- const Utils::MacroExpander *expander = bc->macroExpander();
+ expander = bc->macroExpander();
const QStringList expandedArguments = Utils::transform(buildSystem->initialCMakeArguments(),
- [expander](const QString &s) {
+ [this](const QString &s) {
return expander->expand(s);
});
initialCMakeArguments = Utils::filtered(expandedArguments,
[](const QString &s) { return !s.isEmpty(); });
configurationChangesArguments = Utils::transform(buildSystem->configurationChangesArguments(),
- [expander](const QString &s) {
+ [this](const QString &s) {
return expander->expand(s);
});
additionalCMakeArguments = Utils::transform(buildSystem->additionalCMakeArguments(),
- [expander](const QString &s) {
+ [this](const QString &s) {
return expander->expand(s);
});
const Target *t = bc->target();
diff --git a/src/plugins/cmakeprojectmanager/builddirparameters.h b/src/plugins/cmakeprojectmanager/builddirparameters.h
index 1e2c84c2d23..bc5cccddd35 100644
--- a/src/plugins/cmakeprojectmanager/builddirparameters.h
+++ b/src/plugins/cmakeprojectmanager/builddirparameters.h
@@ -8,6 +8,8 @@
#include <utils/environment.h>
#include <utils/filepath.h>
+namespace Utils { class MacroExpander; }
+
namespace CMakeProjectManager::Internal {
class CMakeBuildSystem;
@@ -34,6 +36,8 @@ public:
QStringList initialCMakeArguments;
QStringList configurationChangesArguments;
QStringList additionalCMakeArguments;
+
+ Utils::MacroExpander* expander = nullptr;
};
} // CMakeProjectManager::Internal
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
index e6857822483..10256fc5dc2 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
@@ -1126,13 +1126,11 @@ static CommandLine defaultInitialCMakeCommand(const Kit *k, const QString buildT
if (!buildType.isEmpty() && !CMakeGeneratorKitAspect::isMultiConfigGenerator(k))
cmd.addArg("-DCMAKE_BUILD_TYPE:STRING=" + buildType);
- auto settings = Internal::CMakeSpecificSettings::instance();
-
- // Package manager auto setup. The file auto-setup.cmake resides on the host,
- // so it's not accessible for remotely running cmakes. We need to exclude that case.
- if (!cmd.executable().needsDevice() && settings->packageManagerAutoSetup.value()) {
- cmd.addArg("-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="
- "%{IDE:ResourcePath}/package-manager/auto-setup.cmake");
+ // Package manager auto setup
+ if (Internal::CMakeSpecificSettings::instance()->packageManagerAutoSetup.value()) {
+ cmd.addArg(QString("-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="
+ "%{buildDir}/%1/auto-setup.cmake")
+ .arg(Constants::PACKAGE_MANAGER_DIR));
}
// Cross-compilation settings:
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp
index b7080a03c7f..33d5cc67e5e 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp
@@ -467,7 +467,8 @@ void CMakeBuildSystem::clearCMakeCache()
m_parameters.buildDirectory / "CMakeCache.txt.prev",
m_parameters.buildDirectory / "CMakeFiles",
m_parameters.buildDirectory / ".cmake/api/v1/reply",
- m_parameters.buildDirectory / ".cmake/api/v1/reply.prev"
+ m_parameters.buildDirectory / ".cmake/api/v1/reply.prev",
+ m_parameters.buildDirectory / Constants::PACKAGE_MANAGER_DIR
};
for (const FilePath &path : pathsToDelete)
diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp
index 3ac06675f19..7a14143a4b9 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp
@@ -5,7 +5,9 @@
#include "builddirparameters.h"
#include "cmakeparser.h"
+#include "cmakeprojectconstants.h"
#include "cmakeprojectmanagertr.h"
+#include "cmakespecificsettings.h"
#include <coreplugin/progressmanager/processprogress.h>
#include <projectexplorer/buildsystem.h>
@@ -87,6 +89,16 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
}
}
+ // Copy the "package-manager" CMake code from the ${IDE:ResourcePath} to the build directory
+ if (Internal::CMakeSpecificSettings::instance()->packageManagerAutoSetup.value()) {
+ const FilePath localPackageManagerDir = buildDirectory.pathAppended(Constants::PACKAGE_MANAGER_DIR);
+ const FilePath idePackageManagerDir = FilePath::fromString(
+ parameters.expander->expand(QStringLiteral("%{IDE:ResourcePath}/package-manager")));
+
+ if (!localPackageManagerDir.exists() && idePackageManagerDir.exists())
+ idePackageManagerDir.copyRecursively(localPackageManagerDir);
+ }
+
const auto parser = new CMakeParser;
parser->setSourceDirectory(parameters.sourceDirectory);
m_parser.addLineParser(parser);
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
index 2d4cd089a0c..cbaa6487266 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
@@ -23,6 +23,8 @@ const char CMAKEFORMATTER_GENERAL_GROUP[] = "General";
const char CMAKEFORMATTER_ACTION_ID[] = "CMakeFormatter.Action";
const char CMAKEFORMATTER_MENU_ID[] = "CMakeFormatter.Menu";
+const char PACKAGE_MANAGER_DIR[] = ".qtc/package-manager";
+
// Project
const char CMAKE_PROJECT_ID[] = "CMakeProjectManager.CMakeProject";
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp
index fd80369ec0f..b29351d1752 100644
--- a/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp
@@ -48,7 +48,7 @@ CMakeSpecificSettings::CMakeSpecificSettings()
registerAspect(&packageManagerAutoSetup);
packageManagerAutoSetup.setSettingsKey("PackageManagerAutoSetup");
- packageManagerAutoSetup.setDefaultValue(false);
+ packageManagerAutoSetup.setDefaultValue(true);
packageManagerAutoSetup.setLabelText(::CMakeProjectManager::Tr::tr("Package manager auto setup"));
packageManagerAutoSetup.setToolTip(::CMakeProjectManager::Tr::tr("Add the CMAKE_PROJECT_INCLUDE_BEFORE variable "
"pointing to a CMake script that will install dependencies from the conanfile.txt, "