1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
/* KDevelop CMake Support
*
* Copyright 2013-2017 Aleix Pol <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef CMAKEPROJECTDATA_H
#define CMAKEPROJECTDATA_H
#include <QSharedPointer>
#include <QStringList>
#include <QHash>
#include <util/path.h>
#include <QDebug>
#include <cmakecommonexport.h>
class CMakeServer;
/**
* Represents any file in a cmake project that has been added
* to the project.
*
* Contains the required information to compile it properly
*/
struct KDEVCMAKECOMMON_EXPORT CMakeFile
{
KDevelop::Path::List includes;
KDevelop::Path::List frameworkDirectories;
QString compileFlags;
QString language;
QHash<QString, QString> defines;
void addDefine(const QString& define);
bool isEmpty() const
{
return includes.isEmpty() && frameworkDirectories.isEmpty()
&& compileFlags.isEmpty() && defines.isEmpty();
}
};
Q_DECLARE_TYPEINFO(CMakeFile, Q_MOVABLE_TYPE);
inline QDebug &operator<<(QDebug debug, const CMakeFile& file)
{
debug << "CMakeFile(-I" << file.includes << ", -F" << file.frameworkDirectories << ", -D" << file.defines << ", " << file.language << ")";
return debug.maybeSpace();
}
struct KDEVCMAKECOMMON_EXPORT CMakeFilesCompilationData
{
QHash<KDevelop::Path, CMakeFile> files;
bool isValid = false;
/// lookup table to quickly find a file path for a given folder path
/// this greatly speeds up fallback searching for information on untracked files
/// based on their folder path
QHash<KDevelop::Path, KDevelop::Path> fileForFolder;
void rebuildFileForFolderMapping();
};
struct KDEVCMAKECOMMON_EXPORT CMakeTarget
{
Q_GADGET
public:
enum Type { Library, Executable, Custom };
Q_ENUM(Type)
static Type typeToEnum(const QString& target);
Type type;
QString name;
KDevelop::Path::List artifacts;
KDevelop::Path::List sources;
// see https://cmake.org/cmake/help/latest/prop_tgt/FOLDER.html
QString folder;
};
Q_DECLARE_TYPEINFO(CMakeTarget, Q_MOVABLE_TYPE);
inline QDebug &operator<<(QDebug debug, const CMakeTarget& target) {
debug << target.type << ':' << target.name; return debug.maybeSpace();
}
inline bool operator==(const CMakeTarget& lhs, const CMakeTarget& rhs)
{
return lhs.type == rhs.type
&& lhs.name == rhs.name
&& lhs.artifacts == rhs.artifacts;
}
struct KDEVCMAKECOMMON_EXPORT CMakeTest
{
QString name;
QString executable;
QStringList arguments;
QHash<QString, QString> properties;
};
Q_DECLARE_TYPEINFO(CMakeTest, Q_MOVABLE_TYPE);
struct KDEVCMAKECOMMON_EXPORT CMakeProjectData
{
CMakeFilesCompilationData compilationData;
QHash<KDevelop::Path, QVector<CMakeTarget>> targets;
QVector<CMakeTest> testSuites;
struct CMakeFileFlags
{
bool isGenerated = false;
bool isExternal = false;
bool isCMake = false;
};
QHash<KDevelop::Path, CMakeFileFlags> cmakeFiles;
};
#endif
|