Open CMake GUI from Project Manager (#4360)
This provides a fast way for engineers who want to configure -> generate -> open project in IDE -> build & run to do so without waiting for a potentially lengthy Project Manager build. Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <ProjectUtils.h>
|
||||
#include <ProjectManagerDefs.h>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QDir>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -18,7 +19,10 @@ namespace O3DE::ProjectManager
|
||||
|
||||
AZ::Outcome<QProcessEnvironment, QString> GetCommandLineProcessEnvironment()
|
||||
{
|
||||
return AZ::Success(QProcessEnvironment(QProcessEnvironment::systemEnvironment()));
|
||||
QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
currentEnvironment.insert("CC", "clang-12");
|
||||
currentEnvironment.insert("CXX", "clang++-12");
|
||||
return AZ::Success(currentEnvironment);
|
||||
}
|
||||
|
||||
AZ::Outcome<QString, QString> FindSupportedCompilerForPlatform()
|
||||
@@ -27,7 +31,7 @@ namespace O3DE::ProjectManager
|
||||
auto whichCMakeResult = ProjectUtils::ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}, QProcessEnvironment::systemEnvironment());
|
||||
if (!whichCMakeResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake not found. \n\n"
|
||||
return AZ::Failure(QObject::tr("CMake not found. <br><br>"
|
||||
"Make sure that the minimum version of CMake is installed and available from the command prompt. "
|
||||
"Refer to the <a href='https://o3de.org/docs/welcome-guide/setup/requirements/#cmake'>O3DE requirements</a> page for more information."));
|
||||
}
|
||||
@@ -45,10 +49,42 @@ namespace O3DE::ProjectManager
|
||||
return AZ::Success(supportClangCommand);
|
||||
}
|
||||
}
|
||||
return AZ::Failure(QObject::tr("Clang not found. \n\n"
|
||||
return AZ::Failure(QObject::tr("Clang not found. <br><br>"
|
||||
"Make sure that the clang is installed and available from the command prompt. "
|
||||
"Refer to the <a href='https://o3de.org/docs/welcome-guide/setup/requirements/#cmake'>O3DE requirements</a> page for more information."));
|
||||
}
|
||||
|
||||
|
||||
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath)
|
||||
{
|
||||
AZ::Outcome processEnvResult = GetCommandLineProcessEnvironment();
|
||||
if (!processEnvResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(processEnvResult.GetError());
|
||||
}
|
||||
|
||||
QString projectBuildPath = QDir(projectPath).filePath(ProjectBuildPathPostfix);
|
||||
AZ::Outcome projectBuildPathResult = GetProjectBuildPath(projectPath);
|
||||
if (projectBuildPathResult.IsSuccess())
|
||||
{
|
||||
projectBuildPath = projectBuildPathResult.GetValue();
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
process.setProcessEnvironment(processEnvResult.GetValue());
|
||||
|
||||
// if the project build path is relative, it should be relative to the project path
|
||||
process.setWorkingDirectory(projectPath);
|
||||
|
||||
process.setProgram("cmake-gui");
|
||||
process.setArguments({ "-S", projectPath, "-B", projectBuildPath });
|
||||
if(!process.startDetached())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("Failed to start CMake GUI"));
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
} // namespace ProjectUtils
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user