diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-24 21:20:10 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-28 13:46:35 (GMT) |
commit | 85f5009d2786349a6576d19bf6b605f825775b44 (patch) | |
tree | 355e8130c4be0d6135a26dca355ac22b40316115 /Source/QtDialog/QCMake.cxx | |
parent | d6c051c126a8cba8adec39b6ae3ae09cc773633f (diff) | |
download | CMake-85f5009d2786349a6576d19bf6b605f825775b44.zip CMake-85f5009d2786349a6576d19bf6b605f825775b44.tar.gz CMake-85f5009d2786349a6576d19bf6b605f825775b44.tar.bz2 |
CMake GUI: Add environment editor
Diffstat (limited to 'Source/QtDialog/QCMake.cxx')
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 6090256..974c545 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -19,10 +19,12 @@ QCMake::QCMake(QObject* p) : QObject(p) + , Environment(QProcessEnvironment::systemEnvironment()) { this->WarnUninitializedMode = false; qRegisterMetaType<QCMakeProperty>(); qRegisterMetaType<QCMakePropertyList>(); + qRegisterMetaType<QProcessEnvironment>(); cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); @@ -151,34 +153,46 @@ void QCMake::setToolset(const QString& toolset) } } +void QCMake::setEnvironment(const QProcessEnvironment& environment) +{ + this->Environment = environment; +} + void QCMake::configure() { + int err; + { + cmSystemTools::SaveRestoreEnvironment restoreEnv; + this->setUpEnvironment(); + #ifdef Q_OS_WIN - UINT lastErrorMode = SetErrorMode(0); + UINT lastErrorMode = SetErrorMode(0); #endif - this->CMakeInstance->SetHomeDirectory( - this->SourceDirectory.toLocal8Bit().data()); - this->CMakeInstance->SetHomeOutputDirectory( - this->BinaryDirectory.toLocal8Bit().data()); - 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->CMakeInstance->LoadCache(); - this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); - this->CMakeInstance->PreLoadCMakeFiles(); - - InterruptFlag = 0; - cmSystemTools::ResetErrorOccuredFlag(); - - int err = this->CMakeInstance->Configure(); + this->CMakeInstance->SetHomeDirectory( + this->SourceDirectory.toLocal8Bit().data()); + this->CMakeInstance->SetHomeOutputDirectory( + this->BinaryDirectory.toLocal8Bit().data()); + 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->CMakeInstance->LoadCache(); + this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); + this->CMakeInstance->PreLoadCMakeFiles(); + + InterruptFlag = 0; + cmSystemTools::ResetErrorOccuredFlag(); + + err = this->CMakeInstance->Configure(); #ifdef Q_OS_WIN - SetErrorMode(lastErrorMode); + SetErrorMode(lastErrorMode); #endif + } emit this->propertiesChanged(this->properties()); emit this->configureDone(err); @@ -186,18 +200,24 @@ void QCMake::configure() void QCMake::generate() { + int err; + { + cmSystemTools::SaveRestoreEnvironment restoreEnv; + this->setUpEnvironment(); + #ifdef Q_OS_WIN - UINT lastErrorMode = SetErrorMode(0); + UINT lastErrorMode = SetErrorMode(0); #endif - InterruptFlag = 0; - cmSystemTools::ResetErrorOccuredFlag(); + InterruptFlag = 0; + cmSystemTools::ResetErrorOccuredFlag(); - int err = this->CMakeInstance->Generate(); + err = this->CMakeInstance->Generate(); #ifdef Q_OS_WIN - SetErrorMode(lastErrorMode); + SetErrorMode(lastErrorMode); #endif + } emit this->generateDone(err); checkOpenPossible(); @@ -373,6 +393,18 @@ void QCMake::stderrCallback(std::string const& msg) QCoreApplication::processEvents(); } +void QCMake::setUpEnvironment() const +{ + auto env = QProcessEnvironment::systemEnvironment(); + for (auto const& key : env.keys()) { + cmSystemTools::UnsetEnv(key.toLocal8Bit().data()); + } + + for (auto const& var : this->Environment.toStringList()) { + cmSystemTools::PutEnv(var.toLocal8Bit().data()); + } +} + QString QCMake::binaryDirectory() const { return this->BinaryDirectory; @@ -388,6 +420,11 @@ QString QCMake::generator() const return this->Generator; } +QProcessEnvironment QCMake::environment() const +{ + return this->Environment; +} + std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const { return AvailableGenerators; |