| 286 | } |
| 287 | |
| 288 | QString cmakeExecutableVersion(const QString& cmakeExecutable) |
| 289 | { |
| 290 | QProcess p; |
| 291 | p.setProcessChannelMode(QProcess::ForwardedErrorChannel); |
| 292 | p.start(cmakeExecutable, {QStringLiteral("--version")}); |
| 293 | if (!p.waitForFinished()) { |
| 294 | qCWarning(CMAKE) << "failed to read cmake version for executable" << cmakeExecutable << p.errorString(); |
| 295 | return {}; |
| 296 | } |
| 297 | |
| 298 | static const QRegularExpression pattern(QStringLiteral("cmake version (\\d\\.\\d+(?:\\.\\d+)?).*")); |
| 299 | const auto output = QString::fromLocal8Bit(p.readAll()); |
| 300 | const auto match = pattern.match(output); |
| 301 | if (!match.hasMatch()) { |
| 302 | qCWarning(CMAKE) << "failed to read cmake version for executable" << cmakeExecutable << output; |
| 303 | return {}; |
| 304 | } |
| 305 | |
| 306 | const auto version = match.captured(1); |
| 307 | qCDebug(CMAKE) << "cmake version for executable" << cmakeExecutable << version; |
| 308 | return version; |
| 309 | } |
| 310 | |
| 311 | KDevelop::Path currentCMakeExecutable(KDevelop::IProject* project, int builddir) |
| 312 | { |