CMake: Replace parseCMakeCacheDotTxt() function

... by direct use of  CMakeConfig::fromFile(). It was only duplicating
checks that are done on the user side already.

Change-Id: Iaf5e89c924c2b0a9080db9fe160970bbf6e33154
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
hjk
2022-05-05 15:51:11 +02:00
parent 0c7ab75ba8
commit ba97c741c8
5 changed files with 5 additions and 24 deletions

View File

@@ -830,14 +830,14 @@ void CMakeBuildSystem::wireUpConnections()
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to build directory change";
const BuildDirParameters parameters(this);
const FilePath cmakeCacheTxt = parameters.buildDirectory.pathAppended("CMakeCache.txt");
const bool hasCMakeCache = QFile::exists(cmakeCacheTxt.toString());
const bool hasCMakeCache = cmakeCacheTxt.exists();
const auto options = ReparseParameters(
hasCMakeCache
? REPARSE_DEFAULT
: (REPARSE_FORCE_INITIAL_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN));
if (hasCMakeCache) {
QString errorMessage;
const CMakeConfig config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage);
const CMakeConfig config = CMakeConfig::fromFile(cmakeCacheTxt, &errorMessage);
if (!config.isEmpty() && errorMessage.isEmpty()) {
QString cmakeBuildTypeName = config.stringValueOf("CMAKE_BUILD_TYPE");
setCMakeBuildType(cmakeBuildTypeName, true);
@@ -1039,20 +1039,6 @@ const QList<CMakeBuildTarget> &CMakeBuildSystem::buildTargets() const
return m_buildTargets;
}
CMakeConfig CMakeBuildSystem::parseCMakeCacheDotTxt(const Utils::FilePath &cacheFile,
QString *errorMessage)
{
if (!cacheFile.exists()) {
if (errorMessage)
*errorMessage = tr("CMakeCache.txt file not found.");
return {};
}
CMakeConfig result = CMakeConfig::fromFile(cacheFile, errorMessage);
if (!errorMessage->isEmpty())
return {};
return result;
}
bool CMakeBuildSystem::filteredOutTarget(const CMakeBuildTarget &target)
{
return target.title.endsWith("_autogen") ||