CMake/Source/QtDialog/QCMake.h

146 lines
4.4 KiB
C
Raw Normal View History

2007-11-02 18:55:57 +03:00
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
2007-11-02 18:50:17 +03:00
#ifndef __QCMake_h
#define __QCMake_h
#ifdef _MSC_VER
#pragma warning ( disable : 4127 )
#pragma warning ( disable : 4512 )
#endif
2007-11-02 18:50:17 +03:00
#include <QObject>
#include <QString>
#include <QVariant>
2007-11-02 18:50:17 +03:00
#include <QList>
#include <QStringList>
2007-11-02 18:50:17 +03:00
#include <QMetaType>
class cmake;
/// struct to represent cache properties in Qt
/// Value is of type String or Bool
2007-11-02 18:50:17 +03:00
struct QCMakeCacheProperty
{
enum PropertyType { BOOL, PATH, FILEPATH, STRING };
QString Key;
QVariant Value;
2007-11-02 18:50:17 +03:00
QString Help;
PropertyType Type;
bool Advanced;
bool operator==(const QCMakeCacheProperty& other) const
{
return this->Key == other.Key;
}
bool operator<(const QCMakeCacheProperty& other) const
{
return this->Key < other.Key;
}
2007-11-02 18:50:17 +03:00
};
// 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..
2007-11-02 18:50:17 +03:00
class QCMake : public QObject
{
Q_OBJECT
public:
QCMake(QObject* p=0);
~QCMake();
void SetSuppressDevWarnings(bool value);
2007-11-02 18:50:17 +03:00
public slots:
/// load the cache file in a directory
2007-11-02 18:50:17 +03:00
void loadCache(const QString& dir);
/// set the source directory containing the source
2007-11-02 18:50:17 +03:00
void setSourceDirectory(const QString& dir);
/// set the binary directory to build in
2007-11-02 18:50:17 +03:00
void setBinaryDirectory(const QString& dir);
/// set the desired generator to use
2007-11-02 18:50:17 +03:00
void setGenerator(const QString& generator);
/// do the configure step
2007-11-02 18:50:17 +03:00
void configure();
/// generate the files
2007-11-02 18:50:17 +03:00
void generate();
/// set the property values
2007-11-02 18:50:17 +03:00
void setProperties(const QCMakeCachePropertyList&);
/// interrupt the configure or generate process
2007-11-02 18:50:17 +03:00
void interrupt();
/// delete the cache in binary directory
void deleteCache();
/// reload the cache in binary directory
void reloadCache();
/// set whether to do debug output
void setDebugOutput(bool);
2007-11-02 18:50:17 +03:00
public:
/// get the list of cache properties
QCMakeCachePropertyList properties() const;
/// get the current binary directory
QString binaryDirectory() const;
/// get the current source directory
QString sourceDirectory() const;
/// get the current generator
QString generator() const;
/// get the available generators
QStringList availableGenerators() const;
/// get whether to do debug output
bool getDebugOutput() const;
2007-11-02 18:50:17 +03:00
signals:
/// signal when properties change (during read from disk or configure process)
2007-11-02 18:50:17 +03:00
void propertiesChanged(const QCMakeCachePropertyList& vars);
/// signal when the generator changes
2007-11-02 18:50:17 +03:00
void generatorChanged(const QString& gen);
/// 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);
/// signal when the binary directory changes
void binaryDirChanged(const QString& dir);
/// signal for progress events
2007-11-02 18:50:17 +03:00
void progressChanged(const QString& msg, float percent);
/// signal when configure is done
2007-11-02 18:50:17 +03:00
void configureDone(int error);
/// signal when generate is done
2007-11-02 18:50:17 +03:00
void generateDone(int error);
/// signal when there is an output message
void outputMessage(const QString& msg);
/// signal when there is an error message
void errorMessage(const QString& msg);
/// signal when debug output changes
void debugOutputChanged(bool);
2007-11-02 18:50:17 +03:00
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);
bool SuppressDevWarnings;
2007-11-02 18:50:17 +03:00
QString SourceDirectory;
QString BinaryDirectory;
QString Generator;
QStringList AvailableGenerators;
2007-11-02 18:50:17 +03:00
QString CMakeExecutable;
};
#endif // __QCMake_h