mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-07 06:40:16 -05:00
cmake-gui: Support non-ASCII chars on Windows with Qt6
Since commit baead1e2a8 (Encoding: Remove option to use ANSI code page
internally, 2016-11-01, v3.8.0-rc1~358^2), we always use UTF-8 strings
internally. Using fromLocal8Bit/toLocal8Bit + QTextCodec is no longer
needed. Convert to fromStdString/toStdString instead, which should work
both with Qt5 and Qt6.
Fixes: #23565
This commit is contained in:
committed by
Brad King
parent
efbbae9705
commit
497397bd17
@@ -10,15 +10,6 @@
|
||||
#include <QTranslator>
|
||||
#include <QtPlugin>
|
||||
|
||||
// FIXME(#23565): Qt6 has QTextCodec in Core5Compat, but using its
|
||||
// `setCodecForLocale` does not make cmake-gui support non-ASCII chars
|
||||
// on Windows. For now we only support them with Qt5. How do we support
|
||||
// them with Qt6, preferably without Core5Compat?
|
||||
#if defined(Q_OS_WIN) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
# include <QTextCodec>
|
||||
# define CMAKE_HAVE_QTEXTCODEC
|
||||
#endif
|
||||
|
||||
#include "cmsys/CommandLineArguments.hxx"
|
||||
#include "cmsys/Encoding.hxx"
|
||||
#include "cmsys/SystemTools.hxx"
|
||||
@@ -133,11 +124,6 @@ int main(int argc, char** argv)
|
||||
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
#ifdef CMAKE_HAVE_QTEXTCODEC
|
||||
QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
|
||||
QTextCodec::setCodecForLocale(utf8_codec);
|
||||
#endif
|
||||
|
||||
// tell the cmake library where cmake is
|
||||
QDir cmExecDir(QApplication::applicationDirPath());
|
||||
#if defined(Q_OS_MAC)
|
||||
@@ -146,7 +132,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// pick up translation files if they exists in the data directory
|
||||
QDir translationsDir = cmExecDir;
|
||||
translationsDir.cd(QString::fromLocal8Bit(".." CMAKE_DATA_DIR));
|
||||
translationsDir.cd(".." CMAKE_DATA_DIR);
|
||||
translationsDir.cd("i18n");
|
||||
QTranslator translator;
|
||||
if (translator.load(QLocale(), "cmake", "_", translationsDir.path())) {
|
||||
@@ -185,8 +171,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
sourceDirectory =
|
||||
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
|
||||
sourceDirectory = cmSystemTools::CollapseFullPath(path.toStdString());
|
||||
cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
|
||||
} else if (arg.startsWith("-B")) {
|
||||
QString path = arg.mid(2);
|
||||
@@ -203,8 +188,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
binaryDirectory =
|
||||
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
|
||||
binaryDirectory = cmSystemTools::CollapseFullPath(path.toStdString());
|
||||
cmSystemTools::ConvertToUnixSlashes(binaryDirectory);
|
||||
} else if (arg.startsWith("--preset=")) {
|
||||
QString preset = arg.mid(cmStrLen("--preset="));
|
||||
@@ -212,7 +196,7 @@ int main(int argc, char** argv)
|
||||
std::cerr << "No preset specified for --preset" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
presetName = preset.toLocal8Bit().data();
|
||||
presetName = preset.toStdString();
|
||||
} else if (arg == "--browse-manual") {
|
||||
OpenReferenceManual();
|
||||
return 0;
|
||||
@@ -220,21 +204,20 @@ int main(int argc, char** argv)
|
||||
}
|
||||
if (!sourceDirectory.empty() &&
|
||||
(!binaryDirectory.empty() || !presetName.empty())) {
|
||||
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
|
||||
dialog.setSourceDirectory(QString::fromStdString(sourceDirectory));
|
||||
if (!binaryDirectory.empty()) {
|
||||
dialog.setBinaryDirectory(
|
||||
QString::fromLocal8Bit(binaryDirectory.c_str()));
|
||||
dialog.setBinaryDirectory(QString::fromStdString(binaryDirectory));
|
||||
if (!presetName.empty()) {
|
||||
dialog.setStartupBinaryDirectory(true);
|
||||
}
|
||||
}
|
||||
if (!presetName.empty()) {
|
||||
dialog.setDeferredPreset(QString::fromLocal8Bit(presetName.c_str()));
|
||||
dialog.setDeferredPreset(QString::fromStdString(presetName));
|
||||
}
|
||||
} else {
|
||||
if (args.count() == 2) {
|
||||
std::string filePath =
|
||||
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
|
||||
cmSystemTools::CollapseFullPath(args[1].toStdString());
|
||||
|
||||
// check if argument is a directory containing CMakeCache.txt
|
||||
std::string buildFilePath = cmStrCat(filePath, "/CMakeCache.txt");
|
||||
@@ -249,12 +232,12 @@ int main(int argc, char** argv)
|
||||
std::string srcFilePath = cmStrCat(filePath, "/CMakeLists.txt");
|
||||
|
||||
if (cmSystemTools::FileExists(buildFilePath.c_str())) {
|
||||
dialog.setBinaryDirectory(QString::fromLocal8Bit(
|
||||
cmSystemTools::GetFilenamePath(buildFilePath).c_str()));
|
||||
dialog.setBinaryDirectory(QString::fromStdString(
|
||||
cmSystemTools::GetFilenamePath(buildFilePath)));
|
||||
} else if (cmSystemTools::FileExists(srcFilePath.c_str())) {
|
||||
dialog.setSourceDirectory(QString::fromLocal8Bit(filePath.c_str()));
|
||||
dialog.setBinaryDirectory(QString::fromLocal8Bit(
|
||||
cmSystemTools::CollapseFullPath(".").c_str()));
|
||||
dialog.setSourceDirectory(QString::fromStdString(filePath));
|
||||
dialog.setBinaryDirectory(
|
||||
QString::fromStdString(cmSystemTools::CollapseFullPath(".")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void OpenReferenceManual()
|
||||
|
||||
if (!cmSystemTools::GetHTMLDoc().empty()) {
|
||||
url = QUrl::fromLocalFile(
|
||||
QDir(QString::fromLocal8Bit(cmSystemTools::GetHTMLDoc().data()))
|
||||
QDir(QString::fromStdString(cmSystemTools::GetHTMLDoc()))
|
||||
.filePath("index.html"));
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ void CMakeSetupDialog::showPresetLoadError(
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, "Error Reading CMake Presets",
|
||||
QString::fromLocal8Bit("Could not read presets from %1: %2")
|
||||
QString("Could not read presets from %1: %2")
|
||||
.arg(dir, cmCMakePresetsGraph::ResultToString(result)));
|
||||
}
|
||||
|
||||
|
||||
@@ -107,22 +107,21 @@ void StartCompilerSetup::setGenerators(
|
||||
QStringList generator_list;
|
||||
|
||||
for (cmake::GeneratorInfo const& gen : gens) {
|
||||
generator_list.append(QString::fromLocal8Bit(gen.name.c_str()));
|
||||
generator_list.append(QString::fromStdString(gen.name));
|
||||
|
||||
if (gen.supportsPlatform) {
|
||||
this->GeneratorsSupportingPlatform.append(
|
||||
QString::fromLocal8Bit(gen.name.c_str()));
|
||||
QString::fromStdString(gen.name));
|
||||
|
||||
this
|
||||
->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] =
|
||||
QString::fromLocal8Bit(gen.defaultPlatform.c_str());
|
||||
this->GeneratorDefaultPlatform[QString::fromStdString(gen.name)] =
|
||||
QString::fromStdString(gen.defaultPlatform);
|
||||
|
||||
auto platformIt = gen.supportedPlatforms.cbegin();
|
||||
while (platformIt != gen.supportedPlatforms.cend()) {
|
||||
|
||||
this->GeneratorSupportedPlatforms.insert(
|
||||
QString::fromLocal8Bit(gen.name.c_str()),
|
||||
QString::fromLocal8Bit((*platformIt).c_str()));
|
||||
QString::fromStdString(gen.name),
|
||||
QString::fromStdString((*platformIt)));
|
||||
|
||||
platformIt++;
|
||||
}
|
||||
@@ -130,7 +129,7 @@ void StartCompilerSetup::setGenerators(
|
||||
|
||||
if (gen.supportsToolset) {
|
||||
this->GeneratorsSupportingToolset.append(
|
||||
QString::fromLocal8Bit(gen.name.c_str()));
|
||||
QString::fromStdString(gen.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+56
-62
@@ -70,7 +70,7 @@ QCMake::QCMake(QObject* p)
|
||||
this->loadPresets();
|
||||
if (!this->PresetName.isEmpty() &&
|
||||
this->CMakePresetsGraph.ConfigurePresets.find(
|
||||
std::string(this->PresetName.toLocal8Bit())) ==
|
||||
std::string(this->PresetName.toStdString())) ==
|
||||
this->CMakePresetsGraph.ConfigurePresets.end()) {
|
||||
this->setPreset(QString{});
|
||||
}
|
||||
@@ -87,8 +87,8 @@ void QCMake::loadCache(const QString& dir)
|
||||
|
||||
void QCMake::setSourceDirectory(const QString& _dir)
|
||||
{
|
||||
QString dir = QString::fromLocal8Bit(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
|
||||
QString dir = QString::fromStdString(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
|
||||
if (this->SourceDirectory != dir) {
|
||||
this->SourceDirectory = QDir::fromNativeSeparators(dir);
|
||||
emit this->sourceDirChanged(this->SourceDirectory);
|
||||
@@ -99,8 +99,8 @@ void QCMake::setSourceDirectory(const QString& _dir)
|
||||
|
||||
void QCMake::setBinaryDirectory(const QString& _dir)
|
||||
{
|
||||
QString dir = QString::fromLocal8Bit(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
|
||||
QString dir = QString::fromStdString(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
|
||||
if (this->BinaryDirectory != dir) {
|
||||
this->BinaryDirectory = QDir::fromNativeSeparators(dir);
|
||||
emit this->binaryDirChanged(this->BinaryDirectory);
|
||||
@@ -108,8 +108,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
|
||||
this->setGenerator(QString());
|
||||
this->setToolset(QString());
|
||||
this->setPlatform(QString());
|
||||
if (!this->CMakeInstance->LoadCache(
|
||||
this->BinaryDirectory.toLocal8Bit().data())) {
|
||||
if (!this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString())) {
|
||||
QDir testDir(this->BinaryDirectory);
|
||||
if (testDir.exists("CMakeCache.txt")) {
|
||||
cmSystemTools::Error(
|
||||
@@ -124,7 +123,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
|
||||
emit this->propertiesChanged(props);
|
||||
cmValue homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
|
||||
if (homeDir) {
|
||||
setSourceDirectory(QString::fromLocal8Bit(homeDir->c_str()));
|
||||
setSourceDirectory(QString(homeDir->c_str()));
|
||||
}
|
||||
cmValue gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
|
||||
if (gen) {
|
||||
@@ -133,17 +132,17 @@ void QCMake::setBinaryDirectory(const QString& _dir)
|
||||
std::string curGen =
|
||||
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*gen,
|
||||
*extraGen);
|
||||
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
|
||||
this->setGenerator(QString::fromStdString(curGen));
|
||||
}
|
||||
|
||||
cmValue platform = state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
|
||||
if (platform) {
|
||||
this->setPlatform(QString::fromLocal8Bit(platform->c_str()));
|
||||
this->setPlatform(QString(platform->c_str()));
|
||||
}
|
||||
|
||||
cmValue toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
|
||||
if (toolset) {
|
||||
this->setToolset(QString::fromLocal8Bit(toolset->c_str()));
|
||||
this->setToolset(QString(toolset->c_str()));
|
||||
}
|
||||
|
||||
checkOpenPossible();
|
||||
@@ -157,13 +156,13 @@ void QCMake::setPreset(const QString& name, bool setBinary)
|
||||
emit this->presetChanged(this->PresetName);
|
||||
|
||||
if (!name.isNull()) {
|
||||
std::string presetName(name.toLocal8Bit());
|
||||
std::string presetName(name.toStdString());
|
||||
auto const& expandedPreset =
|
||||
this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded;
|
||||
if (expandedPreset) {
|
||||
if (setBinary && !expandedPreset->BinaryDir.empty()) {
|
||||
QString binaryDir =
|
||||
QString::fromLocal8Bit(expandedPreset->BinaryDir.data());
|
||||
QString::fromStdString(expandedPreset->BinaryDir);
|
||||
this->setBinaryDirectory(binaryDir);
|
||||
}
|
||||
if (expandedPreset->WarnDev) {
|
||||
@@ -190,8 +189,8 @@ void QCMake::setPreset(const QString& name, bool setBinary)
|
||||
this->Environment = this->StartEnvironment;
|
||||
for (auto const& v : expandedPreset->Environment) {
|
||||
if (v.second) {
|
||||
this->Environment.insert(QString::fromLocal8Bit(v.first.data()),
|
||||
QString::fromLocal8Bit(v.second->data()));
|
||||
this->Environment.insert(QString::fromStdString(v.first),
|
||||
QString::fromStdString(v.second.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,17 +239,14 @@ void QCMake::configure()
|
||||
UINT lastErrorMode = SetErrorMode(0);
|
||||
#endif
|
||||
|
||||
this->CMakeInstance->SetHomeDirectory(
|
||||
this->SourceDirectory.toLocal8Bit().data());
|
||||
this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toStdString());
|
||||
this->CMakeInstance->SetHomeOutputDirectory(
|
||||
this->BinaryDirectory.toLocal8Bit().data());
|
||||
this->BinaryDirectory.toStdString());
|
||||
this->CMakeInstance->SetGlobalGenerator(
|
||||
this->CMakeInstance->CreateGlobalGenerator(
|
||||
this->Generator.toLocal8Bit().data()));
|
||||
this->CMakeInstance->SetGeneratorPlatform(
|
||||
this->Platform.toLocal8Bit().data());
|
||||
this->CMakeInstance->SetGeneratorToolset(
|
||||
this->Toolset.toLocal8Bit().data());
|
||||
this->Generator.toStdString()));
|
||||
this->CMakeInstance->SetGeneratorPlatform(this->Platform.toStdString());
|
||||
this->CMakeInstance->SetGeneratorToolset(this->Toolset.toStdString());
|
||||
this->CMakeInstance->LoadCache();
|
||||
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
|
||||
this->CMakeInstance->PreLoadCMakeFiles();
|
||||
@@ -303,8 +299,8 @@ void QCMake::open()
|
||||
InterruptFlag = 0;
|
||||
cmSystemTools::ResetErrorOccuredFlag();
|
||||
|
||||
auto successful = this->CMakeInstance->Open(
|
||||
this->BinaryDirectory.toLocal8Bit().data(), false);
|
||||
auto successful =
|
||||
this->CMakeInstance->Open(this->BinaryDirectory.toStdString(), false);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
SetErrorMode(lastErrorMode);
|
||||
@@ -329,10 +325,10 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
|
||||
}
|
||||
|
||||
QCMakeProperty prop;
|
||||
prop.Key = QString::fromLocal8Bit(key.c_str());
|
||||
prop.Key = QString::fromStdString(key);
|
||||
int idx = props.indexOf(prop);
|
||||
if (idx == -1) {
|
||||
toremove.append(QString::fromLocal8Bit(key.c_str()));
|
||||
toremove.append(QString::fromStdString(key));
|
||||
} else {
|
||||
prop = props[idx];
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
@@ -343,8 +339,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
|
||||
if (isBool) {
|
||||
state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
|
||||
} else {
|
||||
state->SetCacheEntryValue(key,
|
||||
prop.Value.toString().toLocal8Bit().data());
|
||||
state->SetCacheEntryValue(key, prop.Value.toString().toStdString());
|
||||
}
|
||||
props.removeAt(idx);
|
||||
}
|
||||
@@ -352,35 +347,35 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
|
||||
|
||||
// remove some properties
|
||||
foreach (QString const& s, toremove) {
|
||||
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
|
||||
this->CMakeInstance->UnwatchUnusedCli(s.toStdString());
|
||||
|
||||
state->RemoveCacheEntry(s.toLocal8Bit().data());
|
||||
state->RemoveCacheEntry(s.toStdString());
|
||||
}
|
||||
|
||||
// add some new properties
|
||||
foreach (QCMakeProperty const& s, props) {
|
||||
this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
|
||||
this->CMakeInstance->WatchUnusedCli(s.Key.toStdString());
|
||||
|
||||
if (s.Type == QCMakeProperty::BOOL) {
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF",
|
||||
s.Help.toLocal8Bit().data(), cmStateEnums::BOOL);
|
||||
s.Key.toStdString(), s.Value.toBool() ? "ON" : "OFF",
|
||||
s.Help.toStdString().c_str(), cmStateEnums::BOOL);
|
||||
} else if (s.Type == QCMakeProperty::STRING) {
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
|
||||
s.Help.toLocal8Bit().data(), cmStateEnums::STRING);
|
||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||
s.Help.toStdString().c_str(), cmStateEnums::STRING);
|
||||
} else if (s.Type == QCMakeProperty::PATH) {
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
|
||||
s.Help.toLocal8Bit().data(), cmStateEnums::PATH);
|
||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||
s.Help.toStdString().c_str(), cmStateEnums::PATH);
|
||||
} else if (s.Type == QCMakeProperty::FILEPATH) {
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
|
||||
s.Help.toLocal8Bit().data(), cmStateEnums::FILEPATH);
|
||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||
s.Help.toStdString().c_str(), cmStateEnums::FILEPATH);
|
||||
}
|
||||
}
|
||||
|
||||
this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
|
||||
this->CMakeInstance->SaveCache(this->BinaryDirectory.toStdString());
|
||||
}
|
||||
|
||||
QCMakePropertyList QCMake::properties() const
|
||||
@@ -399,11 +394,11 @@ QCMakePropertyList QCMake::properties() const
|
||||
cmValue cachedValue = state->GetCacheEntryValue(key);
|
||||
|
||||
QCMakeProperty prop;
|
||||
prop.Key = QString::fromLocal8Bit(key.c_str());
|
||||
prop.Key = QString::fromStdString(key);
|
||||
if (cmValue hs = state->GetCacheEntryProperty(key, "HELPSTRING")) {
|
||||
prop.Help = QString::fromLocal8Bit(hs->c_str());
|
||||
prop.Help = QString(hs->c_str());
|
||||
}
|
||||
prop.Value = QString::fromLocal8Bit(cachedValue->c_str());
|
||||
prop.Value = QString(cachedValue->c_str());
|
||||
prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
|
||||
if (t == cmStateEnums::BOOL) {
|
||||
prop.Type = QCMakeProperty::BOOL;
|
||||
@@ -416,8 +411,7 @@ QCMakePropertyList QCMake::properties() const
|
||||
prop.Type = QCMakeProperty::STRING;
|
||||
cmValue stringsProperty = state->GetCacheEntryProperty(key, "STRINGS");
|
||||
if (stringsProperty) {
|
||||
prop.Strings =
|
||||
QString::fromLocal8Bit(stringsProperty->c_str()).split(";");
|
||||
prop.Strings = QString(stringsProperty->c_str()).split(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,7 +419,7 @@ QCMakePropertyList QCMake::properties() const
|
||||
}
|
||||
|
||||
if (!this->PresetName.isNull()) {
|
||||
std::string presetName(this->PresetName.toLocal8Bit());
|
||||
std::string presetName(this->PresetName.toStdString());
|
||||
auto const& p =
|
||||
this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded;
|
||||
if (p) {
|
||||
@@ -434,8 +428,8 @@ QCMakePropertyList QCMake::properties() const
|
||||
continue;
|
||||
}
|
||||
QCMakeProperty prop;
|
||||
prop.Key = QString::fromLocal8Bit(v.first.data());
|
||||
prop.Value = QString::fromLocal8Bit(v.second->Value.data());
|
||||
prop.Key = QString::fromStdString(v.first);
|
||||
prop.Value = QString::fromStdString(v.second->Value);
|
||||
prop.Type = QCMakeProperty::STRING;
|
||||
if (!v.second->Type.empty()) {
|
||||
auto type = cmState::StringToCacheEntryType(v.second->Type);
|
||||
@@ -523,18 +517,18 @@ void QCMake::setUpEnvironment() const
|
||||
{
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
for (auto const& key : env.keys()) {
|
||||
cmSystemTools::UnsetEnv(key.toLocal8Bit().data());
|
||||
cmSystemTools::UnsetEnv(key.toStdString().c_str());
|
||||
}
|
||||
|
||||
for (auto const& var : this->Environment.toStringList()) {
|
||||
cmSystemTools::PutEnv(var.toLocal8Bit().data());
|
||||
cmSystemTools::PutEnv(var.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
void QCMake::loadPresets()
|
||||
{
|
||||
auto result = this->CMakePresetsGraph.ReadProjectPresets(
|
||||
this->SourceDirectory.toLocal8Bit().data(), true);
|
||||
this->SourceDirectory.toStdString(), true);
|
||||
if (result != this->LastLoadPresetsResult &&
|
||||
result != cmCMakePresetsGraph::ReadFileResult::READ_OK) {
|
||||
emit this->presetLoadError(this->SourceDirectory, result);
|
||||
@@ -550,14 +544,14 @@ void QCMake::loadPresets()
|
||||
}
|
||||
|
||||
QCMakePreset preset;
|
||||
preset.name = QString::fromLocal8Bit(p.Name.data());
|
||||
preset.displayName = QString::fromLocal8Bit(p.DisplayName.data());
|
||||
preset.description = QString::fromLocal8Bit(p.Description.data());
|
||||
preset.generator = QString::fromLocal8Bit(p.Generator.data());
|
||||
preset.architecture = QString::fromLocal8Bit(p.Architecture.data());
|
||||
preset.name = QString::fromStdString(p.Name);
|
||||
preset.displayName = QString::fromStdString(p.DisplayName);
|
||||
preset.description = QString::fromStdString(p.Description);
|
||||
preset.generator = QString::fromStdString(p.Generator);
|
||||
preset.architecture = QString::fromStdString(p.Architecture);
|
||||
preset.setArchitecture = !p.ArchitectureStrategy ||
|
||||
p.ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set;
|
||||
preset.toolset = QString::fromLocal8Bit(p.Toolset.data());
|
||||
preset.toolset = QString::fromStdString(p.Toolset);
|
||||
preset.setToolset = !p.ToolsetStrategy ||
|
||||
p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set;
|
||||
preset.enabled = it.Expanded && it.Expanded->ConditionResult &&
|
||||
@@ -599,9 +593,9 @@ std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const
|
||||
void QCMake::deleteCache()
|
||||
{
|
||||
// delete cache
|
||||
this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
|
||||
this->CMakeInstance->DeleteCache(this->BinaryDirectory.toStdString());
|
||||
// reload to make our cache empty
|
||||
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
|
||||
this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString());
|
||||
// emit no generator and no properties
|
||||
this->setGenerator(QString());
|
||||
this->setToolset(QString());
|
||||
@@ -615,7 +609,7 @@ void QCMake::reloadCache()
|
||||
QCMakePropertyList props;
|
||||
emit this->propertiesChanged(props);
|
||||
// reload
|
||||
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
|
||||
this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString());
|
||||
// emit new cache properties
|
||||
props = this->properties();
|
||||
emit this->propertiesChanged(props);
|
||||
@@ -681,7 +675,7 @@ void QCMake::setWarnUninitializedMode(bool value)
|
||||
|
||||
void QCMake::checkOpenPossible()
|
||||
{
|
||||
std::string data = this->BinaryDirectory.toLocal8Bit().data();
|
||||
std::string data = this->BinaryDirectory.toStdString();
|
||||
auto possible = this->CMakeInstance->Open(data, true);
|
||||
emit openPossible(possible);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
|
||||
// AccessibleDescriptionRole. This was determined by looking at
|
||||
// QComboBoxDelegate::isSeparator() (located in qcombobox_p.h.)
|
||||
if (index.internalId() == SEPARATOR_INDEX) {
|
||||
return QString::fromLocal8Bit("separator");
|
||||
return QString("separator");
|
||||
}
|
||||
return QString{};
|
||||
case Qt::DisplayRole: {
|
||||
if (index.internalId() == CUSTOM_INDEX) {
|
||||
return QString::fromLocal8Bit("<custom>");
|
||||
return QString("<custom>");
|
||||
}
|
||||
if (index.internalId() == SEPARATOR_INDEX) {
|
||||
return QVariant{};
|
||||
@@ -32,7 +32,7 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
if (index.internalId() == CUSTOM_INDEX) {
|
||||
return QString::fromLocal8Bit("Specify all settings manually");
|
||||
return QString("Specify all settings manually");
|
||||
}
|
||||
if (index.internalId() == SEPARATOR_INDEX) {
|
||||
return QVariant{};
|
||||
|
||||
Reference in New Issue
Block a user