From 5a156395c4df7c84d514a7a794668c380550bac2 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 21 Sep 2022 12:50:27 +0200 Subject: [PATCH] CMakePM: configure presets review fixes Amends 2ab1e76ca9def75c3f273c336fe6b19d86a55b7f Change-Id: Id10f0d4da6a60223d68af3cea6c5263f7c8c62f2 Reviewed-by: Reviewed-by: hjk --- .../cmakeprojectimporter.cpp | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index c487edda481..3628ec5c316 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -124,10 +124,9 @@ QStringList CMakeProjectImporter::importCandidates() if (configPreset.hidden.value()) continue; - const QString presetDirName = m_presetsTempDir.filePath(configPreset.name).toString(); - const QDir presetDir; - presetDir.mkpath(presetDirName); - candidates << presetDirName; + const FilePath configPresetDir = m_presetsTempDir.filePath(configPreset.name); + configPresetDir.createDir(); + candidates << configPresetDir.toString(); } const QStringList finalists = Utils::filteredUnique(candidates); @@ -138,16 +137,11 @@ QStringList CMakeProjectImporter::importCandidates() static CMakeConfig configurationFromPresetProbe( const FilePath &importPath, const PresetsDetails::ConfigurePreset &configurePreset) { - QFile cmakeListTxt(importPath.pathAppended("CMakeLists.txt").toString()); - if (!cmakeListTxt.open(QIODevice::WriteOnly)) { - return {}; - } - - cmakeListTxt.write(QByteArray("cmake_minimum_required(VERSION 3.15)\n" - "\n" - "project(preset-probe)\n" - "\n")); - cmakeListTxt.close(); + const FilePath cmakeListTxt = importPath / "CMakeLists.txt"; + cmakeListTxt.writeFileContents(QByteArray("cmake_minimum_required(VERSION 3.15)\n" + "\n" + "project(preset-probe)\n" + "\n")); QtcProcess cmake; cmake.setTimeoutS(30);