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 <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2023-07-05 15:31:25 +02:00
parent a0f0f9c69b
commit fe8c276d11

View File

@@ -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());
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<void *> 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();