summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMake.h
blob: 1e4b6614ff620eec8720e9f4a6d0649fededcf19 (plain)
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

#ifndef __QCMake_h
#define __QCMake_h

#include <QObject>
#include <QString>
#include <QList>
#include <QMetaType>

class cmake;

// struct to represent cache properties in Qt
struct QCMakeCacheProperty
{
  enum PropertyType { BOOL, PATH, FILEPATH, STRING };
  QString Key;
  QString Value;
  QString Help;
  PropertyType Type;
  bool Advanced;
};

// make types usable with QVariant
Q_DECLARE_METATYPE(QCMakeCacheProperty)
typedef QList<QCMakeCacheProperty> QCMakeCachePropertyList;
Q_DECLARE_METATYPE(QCMakeCachePropertyList)

// Qt API for CMake library.
// Wrapper like class allows for easier integration with 
// Qt features such as, signal/slot connections, multi-threading, etc..
class QCMake : public QObject
{
  Q_OBJECT
public:
  QCMake(QObject* p=0);
  ~QCMake();

public slots:
  void loadCache(const QString& dir);
  void setSourceDirectory(const QString& dir);
  void setBinaryDirectory(const QString& dir);
  void setGenerator(const QString& generator);
  void configure();
  void generate();
  void setProperties(const QCMakeCachePropertyList&);
  void interrupt();

public:
  QCMakeCachePropertyList properties();
  QString binaryDirectory();
  QString sourceDirectory();
  QString generator();

signals:
  void propertiesChanged(const QCMakeCachePropertyList& vars);
  void generatorChanged(const QString& gen);
  void error(const QString& title, const QString& message, bool*);
  void sourceDirChanged(const QString& dir);
  void progressChanged(const QString& msg, float percent);
  void configureDone(int error);
  void generateDone(int error);
  void configureReady();
  void generateReady();

protected:
  cmake* CMakeInstance;

  static void progressCallback(const char* msg, float percent, void* cd);
  static void errorCallback(const char* msg, const char* title, bool&, void* cd);

  QString SourceDirectory;
  QString BinaryDirectory;
  QString Generator;
  QString CMakeExecutable;
};

#endif // __QCMake_h