diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-08-12 15:24:15 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-08-12 13:52:25 +0000 |
commit | dbfa55f5fc52827609b591c5e0a8abb7353dab24 (patch) | |
tree | c654843cf7d2eb21720e45ca44782c0692ef1307 /src/plugins/cmakeprojectmanager/cmaketool.cpp | |
parent | 42ea10892c3e010e1b64f62d786f1cea9e9714a3 (diff) | |
download | qt-creator-dbfa55f5fc52827609b591c5e0a8abb7353dab24.tar.gz |
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>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmaketool.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmaketool.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 0311f96772..0ed1d50513 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -217,7 +217,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, bool m cmake.setProcessEnvironment(env.toProcessEnvironment()); 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_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished); return response; @@ -240,12 +240,27 @@ QVariantMap CMakeTool::toMap() const Utils::FilePath CMakeTool::cmakeExecutable() const { - if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) { - const Utils::FilePath toTest = m_executable.pathAppended("Contents/bin/cmake"); - if (toTest.exists()) - return toTest.canonicalPath(); + return cmakeExecutable(m_executable); +} + +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()) + return toTest.canonicalPath(); + } } - return m_executable.canonicalPath(); + return path.canonicalPath(); } bool CMakeTool::isAutoRun() const |