CMake: Remove magic configuration from CMake

Get rid of magic configuration handling in the CMakeProjectManager.

* Use CMakeCache.txt as the sole source of truth, do not keep
  a shadow copy of configuration in the .user file
* Have initial CMake arguments that are easy to edit in batch
  (Fixes: QTCREATORBUG-18179) used whenever no CMakeCache.txt
  file is in the build directory. These allow for any thing that
  can be passed to CMake on the command line.
  (Fixes: QTCREATORBUG-16296)
* Ask when changes to CMake configuration were not applied
  (Fixes: QTCREATORBUG-18504)
* Run cmake with arguments effecting its configuration only when
  the CMake settings are changed in the UI, run CMake without any
  special arguments in all other cases.
* Get rid of the confusing dialog used to keep settings in sync between
  what is in CMakeCache.txt and Creator (Fixes: QTCREATORBUG-23218)

Change-Id: I26d55be7df733f084f5691ecf7d7b4352f58b8e7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Tobias Hunger
2020-04-02 14:49:05 +02:00
parent c02a0037d5
commit 01b0d4f8f5
18 changed files with 433 additions and 505 deletions

View File

@@ -284,6 +284,54 @@ static QByteArrayList splitCMakeCacheLine(const QByteArray &line) {
<< line.mid(equalPos + 1);
}
static CMakeConfigItem setItemFromString(const QString &input)
{
return CMakeConfigItem::fromString(input);
}
static CMakeConfigItem unsetItemFromString(const QString &input)
{
CMakeConfigItem item(input.toUtf8(), QByteArray());
item.isUnset = true;
return item;
}
QList<CMakeConfigItem> CMakeConfigItem::itemsFromArguments(const QStringList &list)
{
CMakeConfig result;
bool inSet = false;
bool inUnset = false;
for (const QString &i : list) {
if (inSet) {
inSet = false;
result.append(setItemFromString(i));
continue;
}
if (inUnset) {
inUnset = false;
result.append(unsetItemFromString(i));
continue;
}
if (i == "-U") {
inUnset = true;
continue;
}
if (i == "-D") {
inSet = true;
continue;
}
if (i.startsWith("-U")) {
result.append(unsetItemFromString(i.mid(2)));
continue;
}
if (i.startsWith("-D")) {
result.append(setItemFromString(i.mid(2)));
}
// ignore everything else as that does not define a configuration option
}
return result;
}
QList<CMakeConfigItem> CMakeConfigItem::itemsFromFile(const Utils::FilePath &cacheFile, QString *errorMessage)
{
CMakeConfig result;