1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMake.h,v $
6 Date: $Date: 2007/11/09 20:18:49 $
7 Version: $Revision: 1.8 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
21 #pragma warning ( disable : 4127 )
22 #pragma warning ( disable : 4512 )
29 #include <QStringList>
34 /// struct to represent cache properties in Qt
35 /// Value is of type String or Bool
36 struct QCMakeCacheProperty
38 enum PropertyType
{ BOOL
, PATH
, FILEPATH
, STRING
};
44 bool operator==(const QCMakeCacheProperty
& other
) const
46 return this->Key
== other
.Key
;
48 bool operator<(const QCMakeCacheProperty
& other
) const
50 return this->Key
< other
.Key
;
54 // make types usable with QVariant
55 Q_DECLARE_METATYPE(QCMakeCacheProperty
)
56 typedef QList
<QCMakeCacheProperty
> QCMakeCachePropertyList
;
57 Q_DECLARE_METATYPE(QCMakeCachePropertyList
)
59 /// Qt API for CMake library.
60 /// Wrapper like class allows for easier integration with
61 /// Qt features such as, signal/slot connections, multi-threading, etc..
62 class QCMake
: public QObject
70 /// load the cache file in a directory
71 void loadCache(const QString
& dir
);
72 /// set the source directory containing the source
73 void setSourceDirectory(const QString
& dir
);
74 /// set the binary directory to build in
75 void setBinaryDirectory(const QString
& dir
);
76 /// set the desired generator to use
77 void setGenerator(const QString
& generator
);
78 /// do the configure step
80 /// generate the files
82 /// set the property values
83 void setProperties(const QCMakeCachePropertyList
&);
84 /// interrupt the configure or generate process
86 /// delete the cache in binary directory
88 /// reload the cache in binary directory
92 /// get the list of cache properties
93 QCMakeCachePropertyList
properties() const;
94 /// get the current binary directory
95 QString
binaryDirectory() const;
96 /// get the current source directory
97 QString
sourceDirectory() const;
98 /// get the current generator
99 QString
generator() const;
100 /// get the available generators
101 QStringList
availableGenerators() const;
104 /// signal when properties change (during read from disk or configure process)
105 void propertiesChanged(const QCMakeCachePropertyList
& vars
);
106 /// signal when the generator changes
107 void generatorChanged(const QString
& gen
);
108 /// signal when the source directory changes (binary directory already
109 /// containing a CMakeCache.txt file)
110 void sourceDirChanged(const QString
& dir
);
111 /// signal for progress events
112 void progressChanged(const QString
& msg
, float percent
);
113 /// signal when configure is done
114 void configureDone(int error
);
115 /// signal when generate is done
116 void generateDone(int error
);
117 /// signal when there is an output message
118 void outputMessage(const QString
& msg
);
119 /// signal when there is an error message
120 void errorMessage(const QString
& msg
);
123 cmake
* CMakeInstance
;
125 static void progressCallback(const char* msg
, float percent
, void* cd
);
126 static void errorCallback(const char* msg
, const char* title
,
129 QString SourceDirectory
;
130 QString BinaryDirectory
;
132 QStringList AvailableGenerators
;
133 QString CMakeExecutable
;