File indexing completed on 2024-05-05 04:39:26
0001 /* 0002 SPDX-FileCopyrightText: 2017 Aleix Pol <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "cmakeprojectdata.h" 0008 #include "cmakeutils.h" 0009 0010 #include <QTextStream> 0011 0012 void CMakeFile::addDefine(const QString& define) 0013 { 0014 if (define.isEmpty()) 0015 return; 0016 const int eqIdx = define.indexOf(QLatin1Char('=')); 0017 if (eqIdx < 0) { 0018 defines[define] = QString(); 0019 } else { 0020 defines[define.left(eqIdx)] = define.mid(eqIdx + 1); 0021 } 0022 } 0023 0024 void CMakeFilesCompilationData::rebuildFileForFolderMapping() 0025 { 0026 missingFiles.clear(); 0027 0028 fileForFolder.clear(); 0029 // iterate over files and add all direct folders 0030 for (auto it = files.constBegin(), end = files.constEnd(); it != end; ++it) { 0031 const auto file = it.key(); 0032 const auto folder = file.parent(); 0033 if (fileForFolder.contains(folder)) 0034 continue; 0035 fileForFolder.insert(folder, it.key()); 0036 } 0037 // now also add the parents of these folders 0038 const auto copy = fileForFolder; 0039 for (auto it = copy.begin(), end = copy.end(); it != end; ++it) { 0040 auto folder = it.key(); 0041 while (folder.hasParent()) { 0042 folder = folder.parent(); 0043 if (fileForFolder.contains(folder)) { 0044 break; 0045 } 0046 fileForFolder.insert(folder, it.key()); 0047 } 0048 } 0049 } 0050 0051 CMakeTarget::Type CMakeTarget::typeToEnum(const QString& value) 0052 { 0053 static const QHash<QString, CMakeTarget::Type> s_types = { 0054 {QStringLiteral("EXECUTABLE"), CMakeTarget::Executable}, 0055 {QStringLiteral("STATIC_LIBRARY"), CMakeTarget::Library}, 0056 {QStringLiteral("MODULE_LIBRARY"), CMakeTarget::Library}, 0057 {QStringLiteral("SHARED_LIBRARY"), CMakeTarget::Library}, 0058 {QStringLiteral("OBJECT_LIBRARY"), CMakeTarget::Library}, 0059 {QStringLiteral("INTERFACE_LIBRARY"), CMakeTarget::Library} 0060 }; 0061 return s_types.value(value, CMakeTarget::Custom); 0062 } 0063 0064 QDebug operator<<(QDebug debug, PrintLastModified p) 0065 { 0066 const QDebugStateSaver saver(debug); 0067 debug.noquote().nospace(); 0068 if (p.whatWasModified) { 0069 // Align the printed timestamps to facilitate comparison. 0070 debug << "last modified " << qSetFieldWidth(21) << p.whatWasModified << qSetFieldWidth(0) << ": "; 0071 } 0072 debug << p.lastModified.toString(Qt::ISODateWithMs); 0073 return debug; 0074 } 0075 0076 #include "moc_cmakeprojectdata.cpp"