forked from qt-creator/qt-creator
CMake: Do not run GUI CMake tool on macOS
We may neither run "/some/path/CMake.app" nor "/some/path/CMake.app/Contents/MacOS/CMake", so add a missing workaround for the latter, and use the "resolved" executable path for the retrieval of version info and capabilities. Change-Id: I6fed8cc478c0d0b9946a934fd83126e157bde992 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
@@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
void updateErrorFlags()
|
void updateErrorFlags()
|
||||||
{
|
{
|
||||||
const QFileInfo fi = m_executable.toFileInfo();
|
const QFileInfo fi = CMakeTool::cmakeExecutable(m_executable).toFileInfo();
|
||||||
m_pathExists = fi.exists();
|
m_pathExists = fi.exists();
|
||||||
m_pathIsFile = fi.isFile();
|
m_pathIsFile = fi.isFile();
|
||||||
m_pathIsExecutable = fi.isExecutable();
|
m_pathIsExecutable = fi.isExecutable();
|
||||||
|
@@ -217,7 +217,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, bool m
|
|||||||
cmake.setProcessEnvironment(env.toProcessEnvironment());
|
cmake.setProcessEnvironment(env.toProcessEnvironment());
|
||||||
cmake.setTimeOutMessageBoxEnabled(false);
|
cmake.setTimeOutMessageBoxEnabled(false);
|
||||||
|
|
||||||
Utils::SynchronousProcessResponse response = cmake.runBlocking({m_executable, args});
|
Utils::SynchronousProcessResponse response = cmake.runBlocking({cmakeExecutable(), args});
|
||||||
m_introspection->m_didAttemptToRun = true;
|
m_introspection->m_didAttemptToRun = true;
|
||||||
m_introspection->m_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished);
|
m_introspection->m_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished);
|
||||||
return response;
|
return response;
|
||||||
@@ -240,12 +240,27 @@ QVariantMap CMakeTool::toMap() const
|
|||||||
|
|
||||||
Utils::FilePath CMakeTool::cmakeExecutable() const
|
Utils::FilePath CMakeTool::cmakeExecutable() const
|
||||||
{
|
{
|
||||||
if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) {
|
return cmakeExecutable(m_executable);
|
||||||
const Utils::FilePath toTest = m_executable.pathAppended("Contents/bin/cmake");
|
}
|
||||||
|
|
||||||
|
Utils::FilePath CMakeTool::cmakeExecutable(const Utils::FilePath &path)
|
||||||
|
{
|
||||||
|
if (Utils::HostOsInfo::isMacHost()) {
|
||||||
|
const QString executableString = path.toString();
|
||||||
|
const int appIndex = executableString.lastIndexOf(".app");
|
||||||
|
const int appCutIndex = appIndex + 4;
|
||||||
|
const bool endsWithApp = appIndex >= 0 && appCutIndex >= executableString.size();
|
||||||
|
const bool containsApp = appIndex >= 0 && !endsWithApp
|
||||||
|
&& executableString.at(appCutIndex) == '/';
|
||||||
|
if (endsWithApp || containsApp) {
|
||||||
|
const Utils::FilePath toTest = Utils::FilePath::fromString(
|
||||||
|
executableString.left(appCutIndex))
|
||||||
|
.pathAppended("Contents/bin/cmake");
|
||||||
if (toTest.exists())
|
if (toTest.exists())
|
||||||
return toTest.canonicalPath();
|
return toTest.canonicalPath();
|
||||||
}
|
}
|
||||||
return m_executable.canonicalPath();
|
}
|
||||||
|
return path.canonicalPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMakeTool::isAutoRun() const
|
bool CMakeTool::isAutoRun() const
|
||||||
|
@@ -95,6 +95,7 @@ public:
|
|||||||
void setFilePath(const Utils::FilePath &executable);
|
void setFilePath(const Utils::FilePath &executable);
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
Utils::FilePath cmakeExecutable() const;
|
Utils::FilePath cmakeExecutable() const;
|
||||||
|
static Utils::FilePath cmakeExecutable(const Utils::FilePath &path);
|
||||||
bool isAutoRun() const;
|
bool isAutoRun() const;
|
||||||
bool autoCreateBuildDirectory() const;
|
bool autoCreateBuildDirectory() const;
|
||||||
QList<Generator> supportedGenerators() const;
|
QList<Generator> supportedGenerators() const;
|
||||||
|
Reference in New Issue
Block a user