1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMake.h,v $
6 Date: $Date: 2008-04-02 21:41:24 $
7 Version: $Revision: 1.10 $
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
68 void SetSuppressDevWarnings(bool value
);
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
90 /// set whether to do debug output
91 void setDebugOutput(bool);
94 /// get the list of cache properties
95 QCMakeCachePropertyList
properties() const;
96 /// get the current binary directory
97 QString
binaryDirectory() const;
98 /// get the current source directory
99 QString
sourceDirectory() const;
100 /// get the current generator
101 QString
generator() const;
102 /// get the available generators
103 QStringList
availableGenerators() const;
104 /// get whether to do debug output
105 bool getDebugOutput() const;
108 /// signal when properties change (during read from disk or configure process)
109 void propertiesChanged(const QCMakeCachePropertyList
& vars
);
110 /// signal when the generator changes
111 void generatorChanged(const QString
& gen
);
112 /// signal when the source directory changes (binary directory already
113 /// containing a CMakeCache.txt file)
114 void sourceDirChanged(const QString
& dir
);
115 /// signal for progress events
116 void progressChanged(const QString
& msg
, float percent
);
117 /// signal when configure is done
118 void configureDone(int error
);
119 /// signal when generate is done
120 void generateDone(int error
);
121 /// signal when there is an output message
122 void outputMessage(const QString
& msg
);
123 /// signal when there is an error message
124 void errorMessage(const QString
& msg
);
125 /// signal when debug output changes
126 void debugOutputChanged(bool);
129 cmake
* CMakeInstance
;
131 static void progressCallback(const char* msg
, float percent
, void* cd
);
132 static void errorCallback(const char* msg
, const char* title
,
134 bool SuppressDevWarnings
;
135 QString SourceDirectory
;
136 QString BinaryDirectory
;
138 QStringList AvailableGenerators
;
139 QString CMakeExecutable
;