File indexing completed on 2024-05-19 04:48:24

0001 #include "cmakedata.h"
0002 
0003 #include <MauiKit3/FileBrowsing/fmstatic.h>
0004 
0005 #include <QDebug>
0006 #include <QDir>
0007 #include <QUrl>
0008 
0009 void CMakeFile::addDefine(const QString& define)
0010 {
0011     if (define.isEmpty())
0012         return;
0013     const int eqIdx = define.indexOf(QLatin1Char('='));
0014     if (eqIdx < 0) {
0015         defines[define] = QString();
0016     } else {
0017         defines[define.left(eqIdx)] = define.mid(eqIdx + 1);
0018     }
0019 }
0020 
0021 void CMakeFilesCompilationData::rebuildFileForFolderMapping()
0022 {
0023     fileForFolder.clear();
0024     // iterate over files and add all direct folders
0025     for (auto it = files.constBegin(), end = files.constEnd(); it != end; ++it)
0026     {
0027         const auto file = it.key();
0028         const auto folder = FMStatic::fileDir(file);
0029 
0030         if (fileForFolder.contains(folder))
0031             continue;
0032 
0033         fileForFolder.insert(folder, it.key());
0034     }
0035     // now also add the parents of these folders
0036     const auto copy = fileForFolder;
0037     for (auto it = copy.begin(), end = copy.end(); it != end; ++it)
0038     {
0039         auto folder = it.key();
0040         QDir dir(folder.toLocalFile());
0041         while (dir.cdUp())
0042         {
0043             //            folder = FMStatic::parentDir(folder);
0044             if (fileForFolder.contains(dir.absolutePath()))
0045             {
0046                 break;
0047             }
0048 
0049             fileForFolder.insert(dir.absolutePath(), it.key());
0050         }
0051     }
0052 }
0053 
0054 CMakeTarget::Type CMakeTarget::typeToEnum(const QString& value)
0055 {
0056     static const QHash<QString, CMakeTarget::Type> s_types = {
0057         {QStringLiteral("EXECUTABLE"), CMakeTarget::Executable},
0058         {QStringLiteral("STATIC_LIBRARY"), CMakeTarget::Library},
0059         {QStringLiteral("MODULE_LIBRARY"), CMakeTarget::Library},
0060         {QStringLiteral("SHARED_LIBRARY"), CMakeTarget::Library},
0061         {QStringLiteral("OBJECT_LIBRARY"), CMakeTarget::Library},
0062         {QStringLiteral("INTERFACE_LIBRARY"), CMakeTarget::Library}
0063     };
0064     return s_types.value(value, CMakeTarget::Custom);
0065 }