CMakeProjectManager: Make backup of CMake configuration before starting CMake

CMake's fileapi functionality will save the project structure in json
files in the .cmake/api/v1/reply directory.

When issuing a cmake command with -D variables CMake will update its
CMakeCache.txt file even if cmake will fail.

This commit will rename .cmake/api/v1/reply as .cmake/api/v1/reply.prev
and make a copy of CMakeCache.txt before starting CMake, and if
something fails, replace the existing files with the previous values.

Also make sure the changed values are not dissappearing when the
old .cmake/api/v1/reply gets parsed.

Fixes: QTCREATORBUG-24593
Change-Id: I82141786fea7068699e0f761a8978ba1f3203e47
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2021-02-04 16:22:40 +01:00
parent 2fb9d08082
commit fc411cd0d1
7 changed files with 83 additions and 26 deletions

View File

@@ -59,7 +59,7 @@ BuildDirParameters::BuildDirParameters(CMakeBuildConfiguration *bc)
});
initialCMakeArguments = Utils::filtered(expandedArguments,
[](const QString &s) { return !s.isEmpty(); });
extraCMakeArguments = Utils::transform(bc->extraCMakeArguments(),
extraCMakeArguments = Utils::transform(bc->configurationChangesArguments(),
[expander](const QString &s) {
return expander->expand(s);
});