| 209 | } |
| 210 | |
| 211 | QHash<KDevelop::Path, QStringList> enumerateTargets(const KDevelop::Path& targetsFilePath, const QString& sourceDir, const KDevelop::Path &buildDir) |
| 212 | { |
| 213 | const QString buildPath = buildDir.toLocalFile(); |
| 214 | QHash<KDevelop::Path, QStringList> targets; |
| 215 | QFile targetsFile(targetsFilePath.toLocalFile()); |
| 216 | if (!targetsFile.open(QIODevice::ReadOnly)) { |
| 217 | qCDebug(CMAKE) << "Couldn't find the Targets file in" << targetsFile.fileName(); |
| 218 | } |
| 219 | |
| 220 | QTextStream targetsFileStream(&targetsFile); |
| 221 | const QRegularExpression rx(QStringLiteral("^(.*)/CMakeFiles/(.*).dir$")); |
| 222 | while (!targetsFileStream.atEnd()) { |
| 223 | const QString line = targetsFileStream.readLine(); |
| 224 | auto match = rx.match(line); |
| 225 | if (!match.hasMatch()) { |
| 226 | qCDebug(CMAKE) << "CMakeFiles regex: no match for" << line; |
| 227 | continue; |
| 228 | } |
| 229 | const QString sourcePath = match.captured(1).replace(buildPath, sourceDir); |
| 230 | targets[KDevelop::Path(sourcePath)].append(match.captured(2)); |
| 231 | } |
| 232 | return targets; |
| 233 | } |
| 234 | |
| 235 | KDevelop::Path projectRoot(KDevelop::IProject* project) |
| 236 | { |