2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2014-12-11 21:10:03 +03:00
|
|
|
#ifndef QCMake_h
|
|
|
|
#define QCMake_h
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-09-05 23:12:36 +03:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
2016-04-29 16:40:20 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
|
2007-11-03 19:50:02 +03:00
|
|
|
#ifdef _MSC_VER
|
2016-05-16 17:34:04 +03:00
|
|
|
#pragma warning(disable : 4127)
|
|
|
|
#pragma warning(disable : 4512)
|
2007-11-03 19:50:02 +03:00
|
|
|
#endif
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2015-02-15 22:17:54 +03:00
|
|
|
#include <vector>
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QAtomicInt>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMetaType>
|
2007-11-02 18:50:17 +03:00
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2007-11-05 21:20:54 +03:00
|
|
|
#include <QStringList>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QVariant>
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
/// struct to represent cmake properties in Qt
|
2007-11-03 17:30:52 +03:00
|
|
|
/// Value is of type String or Bool
|
2008-05-16 03:21:01 +04:00
|
|
|
struct QCMakeProperty
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
enum PropertyType
|
|
|
|
{
|
|
|
|
BOOL,
|
|
|
|
PATH,
|
|
|
|
FILEPATH,
|
|
|
|
STRING
|
|
|
|
};
|
2007-11-02 18:50:17 +03:00
|
|
|
QString Key;
|
2007-11-03 17:30:52 +03:00
|
|
|
QVariant Value;
|
2009-03-12 18:19:27 +03:00
|
|
|
QStringList Strings;
|
2007-11-02 18:50:17 +03:00
|
|
|
QString Help;
|
|
|
|
PropertyType Type;
|
|
|
|
bool Advanced;
|
2012-08-13 21:42:58 +04:00
|
|
|
bool operator==(const QCMakeProperty& other) const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2007-11-05 21:20:54 +03:00
|
|
|
return this->Key == other.Key;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
bool operator<(const QCMakeProperty& other) const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2007-11-05 21:20:54 +03:00
|
|
|
return this->Key < other.Key;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
};
|
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
// list of properties
|
|
|
|
typedef QList<QCMakeProperty> QCMakePropertyList;
|
|
|
|
|
|
|
|
// allow QVariant to be a property or list of properties
|
|
|
|
Q_DECLARE_METATYPE(QCMakeProperty)
|
|
|
|
Q_DECLARE_METATYPE(QCMakePropertyList)
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2007-11-03 17:30:52 +03:00
|
|
|
/// Qt API for CMake library.
|
2012-08-13 21:42:58 +04:00
|
|
|
/// Wrapper like class allows for easier integration with
|
2007-11-03 17:30:52 +03:00
|
|
|
/// Qt features such as, signal/slot connections, multi-threading, etc..
|
2007-11-02 18:50:17 +03:00
|
|
|
class QCMake : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-09-05 23:12:36 +03:00
|
|
|
QCMake(QObject* p = CM_NULLPTR);
|
2007-11-02 18:50:17 +03:00
|
|
|
~QCMake();
|
|
|
|
public slots:
|
2007-11-03 17:30:52 +03:00
|
|
|
/// load the cache file in a directory
|
2007-11-02 18:50:17 +03:00
|
|
|
void loadCache(const QString& dir);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// set the source directory containing the source
|
2007-11-02 18:50:17 +03:00
|
|
|
void setSourceDirectory(const QString& dir);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// set the binary directory to build in
|
2007-11-02 18:50:17 +03:00
|
|
|
void setBinaryDirectory(const QString& dir);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// set the desired generator to use
|
2007-11-02 18:50:17 +03:00
|
|
|
void setGenerator(const QString& generator);
|
2015-02-15 22:17:54 +03:00
|
|
|
/// set the desired generator to use
|
|
|
|
void setToolset(const QString& toolset);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// do the configure step
|
2007-11-02 18:50:17 +03:00
|
|
|
void configure();
|
2007-11-03 17:30:52 +03:00
|
|
|
/// generate the files
|
2007-11-02 18:50:17 +03:00
|
|
|
void generate();
|
2007-11-03 17:30:52 +03:00
|
|
|
/// set the property values
|
2008-05-16 03:21:01 +04:00
|
|
|
void setProperties(const QCMakePropertyList&);
|
2016-05-16 17:34:04 +03:00
|
|
|
/// interrupt the configure or generate process (if connecting, make a direct
|
|
|
|
/// connection)
|
2007-11-02 18:50:17 +03:00
|
|
|
void interrupt();
|
2007-11-06 09:16:11 +03:00
|
|
|
/// delete the cache in binary directory
|
|
|
|
void deleteCache();
|
|
|
|
/// reload the cache in binary directory
|
|
|
|
void reloadCache();
|
2008-04-03 01:41:24 +04:00
|
|
|
/// set whether to do debug output
|
|
|
|
void setDebugOutput(bool);
|
2015-12-06 15:33:13 +03:00
|
|
|
/// get whether to do suppress dev warnings
|
|
|
|
bool getSuppressDevWarnings();
|
2008-05-16 03:21:01 +04:00
|
|
|
/// set whether to do suppress dev warnings
|
|
|
|
void setSuppressDevWarnings(bool value);
|
2015-12-06 15:33:13 +03:00
|
|
|
/// get whether to do suppress deprecated warnings
|
|
|
|
bool getSuppressDeprecatedWarnings();
|
|
|
|
/// set whether to do suppress deprecated warnings
|
|
|
|
void setSuppressDeprecatedWarnings(bool value);
|
2015-12-26 19:04:13 +03:00
|
|
|
/// get whether to treat developer (author) warnings as errors
|
|
|
|
bool getDevWarningsAsErrors();
|
|
|
|
/// set whether to treat developer (author) warnings as errors
|
|
|
|
void setDevWarningsAsErrors(bool value);
|
|
|
|
/// get whether to treat deprecated warnings as errors
|
|
|
|
bool getDeprecatedWarningsAsErrors();
|
|
|
|
/// set whether to treat deprecated warnings as errors
|
|
|
|
void setDeprecatedWarningsAsErrors(bool value);
|
2010-08-25 20:35:40 +04:00
|
|
|
/// set whether to run cmake with warnings about uninitialized variables
|
|
|
|
void setWarnUninitializedMode(bool value);
|
2010-08-25 20:43:02 +04:00
|
|
|
/// set whether to run cmake with warnings about unused variables
|
|
|
|
void setWarnUnusedMode(bool value);
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
public:
|
2007-11-03 17:30:52 +03:00
|
|
|
/// get the list of cache properties
|
2008-05-16 03:21:01 +04:00
|
|
|
QCMakePropertyList properties() const;
|
2007-11-03 17:30:52 +03:00
|
|
|
/// get the current binary directory
|
2007-11-05 21:20:54 +03:00
|
|
|
QString binaryDirectory() const;
|
2007-11-03 17:30:52 +03:00
|
|
|
/// get the current source directory
|
2007-11-05 21:20:54 +03:00
|
|
|
QString sourceDirectory() const;
|
2007-11-03 17:30:52 +03:00
|
|
|
/// get the current generator
|
2007-11-05 21:20:54 +03:00
|
|
|
QString generator() const;
|
2007-11-03 17:30:52 +03:00
|
|
|
/// get the available generators
|
2015-02-15 22:17:54 +03:00
|
|
|
std::vector<cmake::GeneratorInfo> const& availableGenerators() const;
|
2008-04-03 01:41:24 +04:00
|
|
|
/// get whether to do debug output
|
|
|
|
bool getDebugOutput() const;
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
signals:
|
2016-05-16 17:34:04 +03:00
|
|
|
/// signal when properties change (during read from disk or configure
|
|
|
|
/// process)
|
2008-05-16 03:21:01 +04:00
|
|
|
void propertiesChanged(const QCMakePropertyList& vars);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal when the generator changes
|
2007-11-02 18:50:17 +03:00
|
|
|
void generatorChanged(const QString& gen);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal when the source directory changes (binary directory already
|
|
|
|
/// containing a CMakeCache.txt file)
|
2007-11-02 18:50:17 +03:00
|
|
|
void sourceDirChanged(const QString& dir);
|
2008-04-08 03:19:50 +04:00
|
|
|
/// signal when the binary directory changes
|
|
|
|
void binaryDirChanged(const QString& dir);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal for progress events
|
2007-11-02 18:50:17 +03:00
|
|
|
void progressChanged(const QString& msg, float percent);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal when configure is done
|
2007-11-02 18:50:17 +03:00
|
|
|
void configureDone(int error);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal when generate is done
|
2007-11-02 18:50:17 +03:00
|
|
|
void generateDone(int error);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// signal when there is an output message
|
|
|
|
void outputMessage(const QString& msg);
|
2007-11-09 23:18:49 +03:00
|
|
|
/// signal when there is an error message
|
|
|
|
void errorMessage(const QString& msg);
|
2008-04-03 01:41:24 +04:00
|
|
|
/// signal when debug output changes
|
|
|
|
void debugOutputChanged(bool);
|
2015-02-15 22:17:54 +03:00
|
|
|
/// signal when the toolset changes
|
|
|
|
void toolsetChanged(const QString& toolset);
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
cmake* CMakeInstance;
|
|
|
|
|
2012-01-02 22:07:43 +04:00
|
|
|
static bool interruptCallback(void*);
|
2007-11-02 18:50:17 +03:00
|
|
|
static void progressCallback(const char* msg, float percent, void* cd);
|
2016-05-16 17:34:04 +03:00
|
|
|
static void messageCallback(const char* msg, const char* title, bool&,
|
|
|
|
void* cd);
|
2014-05-15 17:47:25 +04:00
|
|
|
static void stdoutCallback(const char* msg, size_t len, void* cd);
|
|
|
|
static void stderrCallback(const char* msg, size_t len, void* cd);
|
2010-08-25 20:35:40 +04:00
|
|
|
bool WarnUninitializedMode;
|
2010-08-25 20:43:02 +04:00
|
|
|
bool WarnUnusedMode;
|
|
|
|
bool WarnUnusedAllMode;
|
2007-11-02 18:50:17 +03:00
|
|
|
QString SourceDirectory;
|
|
|
|
QString BinaryDirectory;
|
|
|
|
QString Generator;
|
2015-02-15 22:17:54 +03:00
|
|
|
QString Toolset;
|
|
|
|
std::vector<cmake::GeneratorInfo> AvailableGenerators;
|
2007-11-02 18:50:17 +03:00
|
|
|
QString CMakeExecutable;
|
2012-01-02 22:07:43 +04:00
|
|
|
QAtomicInt InterruptFlag;
|
2007-11-02 18:50:17 +03:00
|
|
|
};
|
|
|
|
|
2014-12-11 21:10:03 +03:00
|
|
|
#endif // QCMake_h
|