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 <QProcess>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -61,5 +62,37 @@ namespace O3DE::ProjectManager
|
||||
|
||||
return AZ::Success(xcodeBuilderVersionNumber);
|
||||
}
|
||||
|
||||
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath)
|
||||
{
|
||||
const QString cmakeHelp = QObject::tr("Please verify you've installed CMake.app from "
|
||||
"<a href=\"https://cmake.org\">cmake.org</a> or, if using HomeBrew, "
|
||||
"have installed it with <pre>brew install --cask cmake</pre>");
|
||||
QString cmakeAppPath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "CMake.app", QStandardPaths::LocateDirectory);
|
||||
if (cmakeAppPath.isEmpty())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake.app not found.") + cmakeHelp);
|
||||
}
|
||||
|
||||
QString projectBuildPath = QDir(projectPath).filePath(ProjectBuildPathPostfix);
|
||||
AZ::Outcome result = GetProjectBuildPath(projectPath);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
projectBuildPath = result.GetValue();
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
|
||||
// if the project build path is relative, it should be relative to the project path
|
||||
process.setWorkingDirectory(projectPath);
|
||||
process.setProgram("open");
|
||||
process.setArguments({"-a", "CMake", "--args", "-S", projectPath, "-B", projectBuildPath});
|
||||
if(!process.startDetached())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake.app failed to open.") + cmakeHelp);
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
} // namespace ProjectUtils
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user