From c9053256d3fab8fc0e4c34446e6deb4a56aa11b7 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 23 Mar 2021 12:28:09 +0100 Subject: [PATCH] CMakePM: Better error message when CMake file-api config is missing Now the available configuration list is displayed, alongside with the hint that CMAKE_BUILD_TYPE or CMAKE_CONFIGURATION_TYPES needs to match / contain the "Build type" field. In order to test this just clear (or set a random value) in the "Build type" field and click "Re-configure with initial parameters" button. Fixes: QTCREATORBUG-25506 Change-Id: I44558c45c7050d03e72a3a0b9ce2c8d89bd6e4bc Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/fileapiparser.cpp | 16 +++++++++++++++- src/plugins/cmakeprojectmanager/fileapiparser.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/fileapiparser.cpp b/src/plugins/cmakeprojectmanager/fileapiparser.cpp index 1e2ccfb0114..909636c2dfc 100644 --- a/src/plugins/cmakeprojectmanager/fileapiparser.cpp +++ b/src/plugins/cmakeprojectmanager/fileapiparser.cpp @@ -896,7 +896,21 @@ FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QStri return QString::compare(cfg.name, cmakeBuildType, Qt::CaseInsensitive) == 0; }); if (it == codeModels.cend()) { - errorMessage = QString("No '%1' CMake configuration found!").arg(cmakeBuildType); + QStringList buildTypes; + for (const Configuration &cfg: codeModels) + buildTypes << cfg.name; + + if (result.replyFile.isMultiConfig) { + errorMessage = tr("No \"%1\" CMake configuration found. Available configurations: \"%2\".\n" + "Make sure that CMAKE_CONFIGURATION_TYPES variable contains the \"Build type\" field.") + .arg(cmakeBuildType) + .arg(buildTypes.join(", ")); + } else { + errorMessage = tr("No \"%1\" CMake configuration found. Available configuration: \"%2\".\n" + "Make sure that CMAKE_BUILD_TYPE variable matches the \"Build type\" field.") + .arg(cmakeBuildType) + .arg(buildTypes.join(", ")); + } qWarning() << errorMessage; return result; } diff --git a/src/plugins/cmakeprojectmanager/fileapiparser.h b/src/plugins/cmakeprojectmanager/fileapiparser.h index b790251db66..6650d5e75ae 100644 --- a/src/plugins/cmakeprojectmanager/fileapiparser.h +++ b/src/plugins/cmakeprojectmanager/fileapiparser.h @@ -245,6 +245,7 @@ public: class FileApiParser { + Q_DECLARE_TR_FUNCTIONS(FileApiParser) public: static FileApiData parseData(const QFileInfo &replyFileInfo, const QString& cmakeBuildType, QString &errorMessage);