Merge remote-tracking branch 'origin/10.0'

Conflicts:
	src/plugins/android/androidrunnerworker.cpp
	src/plugins/qtsupport/exampleslistmodel.cpp

Change-Id: I1628528dbc0ffe874b49bbe022da5933b1348057
This commit is contained in:
Eike Ziller
2023-04-18 12:53:45 +02:00
15 changed files with 247 additions and 120 deletions

View File

@@ -1256,6 +1256,12 @@ static void addCMakeConfigurePresetToInitialArguments(QStringList &initialArgume
const QString presetItemArg = presetItem.toArgument();
const QString presetItemArgNoType = presetItemArg.left(presetItemArg.indexOf(":"));
static QSet<QByteArray> defaultKitMacroValues{"CMAKE_C_COMPILER",
"CMAKE_CXX_COMPILER",
"QT_QMAKE_EXECUTABLE",
"QT_HOST_PATH",
"CMAKE_PROJECT_INCLUDE_BEFORE"};
auto it = std::find_if(initialArguments.begin(),
initialArguments.end(),
[presetItemArgNoType](const QString &arg) {
@@ -1266,6 +1272,11 @@ static void addCMakeConfigurePresetToInitialArguments(QStringList &initialArgume
QString &arg = *it;
CMakeConfigItem argItem = CMakeConfigItem::fromString(arg.mid(2)); // skip -D
// These values have Qt Creator macro names pointing to the Kit values
// which are preset expanded values used when the Kit was created
if (defaultKitMacroValues.contains(argItem.key) && argItem.value.startsWith("%{"))
continue;
// For multi value path variables append the non Qt path
if (argItem.key == "CMAKE_PREFIX_PATH" || argItem.key == "CMAKE_FIND_ROOT_PATH") {
QStringList presetValueList = presetItem.expandedValue(k).split(";");
@@ -1276,7 +1287,7 @@ static void addCMakeConfigurePresetToInitialArguments(QStringList &initialArgume
QStringList argItemPaths = argItemExpandedValue.split(";");
for (const QString &argPath : argItemPaths) {
const FilePath argFilePath = FilePath::fromString(argPath);
const FilePath presetFilePath = FilePath::fromString(presetPath);
const FilePath presetFilePath = FilePath::fromUserInput(presetPath);
if (argFilePath == presetFilePath)
return true;
@@ -1291,12 +1302,10 @@ static void addCMakeConfigurePresetToInitialArguments(QStringList &initialArgume
}
arg = argItem.toArgument();
} else if (argItem.key == "CMAKE_C_COMPILER" || argItem.key == "CMAKE_CXX_COMPILER"
|| argItem.key == "QT_QMAKE_EXECUTABLE" || argItem.key == "QT_HOST_PATH"
|| argItem.key == "CMAKE_PROJECT_INCLUDE_BEFORE"
|| argItem.key == "CMAKE_TOOLCHAIN_FILE") {
} else if (argItem.key == "CMAKE_TOOLCHAIN_FILE") {
const FilePath argFilePath = FilePath::fromString(argItem.expandedValue(k));
const FilePath presetFilePath = FilePath::fromUtf8(presetItem.value);
const FilePath presetFilePath = FilePath::fromUserInput(
QString::fromUtf8(presetItem.value));
if (argFilePath != presetFilePath)
arg = presetItem.toArgument();

View File

@@ -103,7 +103,9 @@ Internal::PresetsData CMakeProject::combinePresets(Internal::PresetsData &cmakeP
auto resolveInherits = [](auto &presetsHash, auto &presetsList) {
Utils::sort(presetsList, [](const auto &left, const auto &right) {
if (!left.inherits || left.inherits.value().contains(right.name))
const bool sameInheritance = left.inherits && right.inherits
&& left.inherits.value() == right.inherits.value();
if (!left.inherits || left.inherits.value().contains(right.name) || sameInheritance)
return false;
return true;
});

View File

@@ -209,23 +209,11 @@ static CMakeConfig configurationFromPresetProbe(
? configurePreset.cacheVariables.value()
: CMakeConfig();
auto expandCacheValue =
[configurePreset, env, sourceDirectory, cache](const QString &key) -> QString {
QString result = cache.stringValueOf(key.toUtf8());
CMakePresets::Macros::expand(configurePreset, env, sourceDirectory, result);
// all usages involve file paths, so make sure they are cleaned up
const FilePaths paths = transform(result.split(";"), &FilePath::fromUserInput);
result = transform(paths, &FilePath::path).join(";");
return result;
};
const QString cmakeMakeProgram = expandCacheValue("CMAKE_MAKE_PROGRAM");
const QString toolchainFile = expandCacheValue("CMAKE_TOOLCHAIN_FILE");
const QString prefixPath = expandCacheValue("CMAKE_PREFIX_PATH");
const QString findRootPath = expandCacheValue("CMAKE_FIND_ROOT_PATH");
const QString qtHostPath = expandCacheValue("QT_HOST_PATH");
const QString cmakeMakeProgram = cache.stringValueOf("CMAKE_MAKE_PROGRAM");
const QString toolchainFile = cache.stringValueOf("CMAKE_TOOLCHAIN_FILE");
const QString prefixPath = cache.stringValueOf("CMAKE_PREFIX_PATH");
const QString findRootPath = cache.stringValueOf("CMAKE_FIND_ROOT_PATH");
const QString qtHostPath = cache.stringValueOf("QT_HOST_PATH");
if (!cmakeMakeProgram.isEmpty()) {
args.emplace_back(
@@ -662,6 +650,8 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
projectDirectory(),
data->buildDirectory);
CMakePresets::Macros::updateCacheVariables(configurePreset, env, projectDirectory());
const CMakeConfig cache = configurePreset.cacheVariables
? configurePreset.cacheVariables.value()
: CMakeConfig();
@@ -710,10 +700,7 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
data->cmakePresetDefaultConfigHash
= CMakeConfigurationKitAspect::computeDefaultConfigHash(config, data->cmakeBinary);
QString cmakeBuildType = QString::fromUtf8(cache.valueOf("CMAKE_BUILD_TYPE"));
CMakePresets::Macros::expand(configurePreset, env, projectDirectory(), cmakeBuildType);
QByteArrayList buildConfigurationTypes = {cmakeBuildType.toUtf8()};
QByteArrayList buildConfigurationTypes = {cache.valueOf("CMAKE_BUILD_TYPE")};
if (buildConfigurationTypes.front().isEmpty()) {
buildConfigurationTypes.clear();
QByteArray buildConfigurationTypesString = cache.valueOf("CMAKE_CONFIGURATION_TYPES");

View File

@@ -4,6 +4,7 @@
#include "presetsmacros.h"
#include "presetsparser.h"
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/filepath.h>
#include <utils/hostosinfo.h>
@@ -295,6 +296,47 @@ void updateInstallDir(PresetsDetails::ConfigurePreset &configurePreset,
}
void updateCacheVariables(PresetsDetails::ConfigurePreset &configurePreset,
const Utils::Environment &env,
const Utils::FilePath &sourceDirectory)
{
using namespace Utils;
if (!configurePreset.cacheVariables)
return;
CMakeConfig cache = configurePreset.cacheVariables.value();
static const QSet<QByteArray> pathKeys{"CMAKE_C_COMPILER",
"CMAKE_CXX_COMPILER",
"CMAKE_PREFIX_PATH",
"CMAKE_FIND_ROOT_PATH",
"CMAKE_MAKE_PROGRAM",
"CMAKE_TOOLCHAIN_FILE",
"QT_HOST_PATH",
"QT_QMAKE_EXECUTABLE",
"CMAKE_SYSROOT"};
auto expandCacheValue =
[configurePreset, env, sourceDirectory, cache](const QByteArray &key) {
QString result = cache.stringValueOf(key);
CMakePresets::Macros::expand(configurePreset, env, sourceDirectory, result);
if (pathKeys.contains(key)) {
const FilePaths paths = transform(result.split(";"), &FilePath::fromUserInput);
result = transform(paths, &FilePath::path).join(";");
}
return result.toUtf8();
};
for (auto &item : cache)
item.value = expandCacheValue(item.key);
configurePreset.cacheVariables = cache;
}
template<class PresetType>
void expandConditionValues(const PresetType &preset,
const Utils::Environment &env,

View File

@@ -60,6 +60,14 @@ void updateToolchainFile(PresetsDetails::ConfigurePreset &configurePreset,
void updateInstallDir(PresetsDetails::ConfigurePreset &configurePreset,
const Utils::Environment &env,
const Utils::FilePath &sourceDirectory);
/**
* Updates the cacheVariables parameter of the configurePreset with the expanded prameter values.
* Including macro expansion and relative paths resolving.
*/
void updateCacheVariables(PresetsDetails::ConfigurePreset &configurePreset,
const Utils::Environment &env,
const Utils::FilePath &sourceDirectory);
/**
* Expands the condition values and then evaluates the condition object of the preset and returns
* the boolean result.