From fe8c276d11f8385ae65da831a3041d1214577833 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 5 Jul 2023 15:31:25 +0200 Subject: [PATCH] CMakePM: Auto detect generator when not specified in presets Qt Creator would do a compiler probe for CMake presets when the compiler was not set. But the same needs to be done when the generator is not set. Otherwise Qt Creator would set a different generator by default. On Windows is "Ninja". This is different from what CMake does from command line. Task-number: QTCREATORBUG-28693 Change-Id: I96e917b11561a042f9476bad302f3f153e37bafd Reviewed-by: Alessandro Portale --- .../cmakeprojectmanager/cmakeprojectimporter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 4fef3bda467..00948899f1e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -379,8 +379,10 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config, args.push_back(qtcQMakeProbeDir.path().path()); args.push_back("-B"); args.push_back(qtcQMakeProbeDir.filePath("build").path()); - args.push_back("-G"); - args.push_back(cmakeGenerator); + if (!cmakeGenerator.isEmpty()) { + args.push_back("-G"); + args.push_back(cmakeGenerator); + } if (!cmakeGeneratorPlatform.isEmpty()) { args.push_back("-A"); args.push_back(cmakeGeneratorPlatform); @@ -708,8 +710,9 @@ QList CMakeProjectImporter::examineDirectory(const FilePath &importPath, data->sysroot = cache.filePathValueOf("CMAKE_SYSROOT"); CMakeConfig config; - if (cache.valueOf("CMAKE_C_COMPILER").isEmpty() - && cache.valueOf("CMAKE_CXX_COMPILER").isEmpty()) { + const bool noCompilers = cache.valueOf("CMAKE_C_COMPILER").isEmpty() + && cache.valueOf("CMAKE_CXX_COMPILER").isEmpty(); + if (noCompilers || !configurePreset.generator) { QApplication::setOverrideCursor(Qt::WaitCursor); config = configurationFromPresetProbe(importPath, projectDirectory(), configurePreset); QApplication::restoreOverrideCursor();