QCMake.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef __QCMake_h
  14. #define __QCMake_h
  15. #ifdef _MSC_VER
  16. #pragma warning ( disable : 4127 )
  17. #pragma warning ( disable : 4512 )
  18. #endif
  19. #include <QObject>
  20. #include <QString>
  21. #include <QVariant>
  22. #include <QList>
  23. #include <QStringList>
  24. #include <QMetaType>
  25. class cmake;
  26. /// struct to represent cmake properties in Qt
  27. /// Value is of type String or Bool
  28. struct QCMakeProperty
  29. {
  30. enum PropertyType { BOOL, PATH, FILEPATH, STRING };
  31. QString Key;
  32. QVariant Value;
  33. QString Help;
  34. PropertyType Type;
  35. bool Advanced;
  36. bool operator==(const QCMakeProperty& other) const
  37. {
  38. return this->Key == other.Key;
  39. }
  40. bool operator<(const QCMakeProperty& other) const
  41. {
  42. return this->Key < other.Key;
  43. }
  44. };
  45. // list of properties
  46. typedef QList<QCMakeProperty> QCMakePropertyList;
  47. // allow QVariant to be a property or list of properties
  48. Q_DECLARE_METATYPE(QCMakeProperty)
  49. Q_DECLARE_METATYPE(QCMakePropertyList)
  50. /// Qt API for CMake library.
  51. /// Wrapper like class allows for easier integration with
  52. /// Qt features such as, signal/slot connections, multi-threading, etc..
  53. class QCMake : public QObject
  54. {
  55. Q_OBJECT
  56. public:
  57. QCMake(QObject* p=0);
  58. ~QCMake();
  59. public slots:
  60. /// load the cache file in a directory
  61. void loadCache(const QString& dir);
  62. /// set the source directory containing the source
  63. void setSourceDirectory(const QString& dir);
  64. /// set the binary directory to build in
  65. void setBinaryDirectory(const QString& dir);
  66. /// set the desired generator to use
  67. void setGenerator(const QString& generator);
  68. /// do the configure step
  69. void configure();
  70. /// generate the files
  71. void generate();
  72. /// set the property values
  73. void setProperties(const QCMakePropertyList&);
  74. /// interrupt the configure or generate process
  75. void interrupt();
  76. /// delete the cache in binary directory
  77. void deleteCache();
  78. /// reload the cache in binary directory
  79. void reloadCache();
  80. /// set whether to do debug output
  81. void setDebugOutput(bool);
  82. /// set whether to do suppress dev warnings
  83. void setSuppressDevWarnings(bool value);
  84. public:
  85. /// get the list of cache properties
  86. QCMakePropertyList properties() const;
  87. /// get the current binary directory
  88. QString binaryDirectory() const;
  89. /// get the current source directory
  90. QString sourceDirectory() const;
  91. /// get the current generator
  92. QString generator() const;
  93. /// get the available generators
  94. QStringList availableGenerators() const;
  95. /// get whether to do debug output
  96. bool getDebugOutput() const;
  97. signals:
  98. /// signal when properties change (during read from disk or configure process)
  99. void propertiesChanged(const QCMakePropertyList& vars);
  100. /// signal when the generator changes
  101. void generatorChanged(const QString& gen);
  102. /// signal when the source directory changes (binary directory already
  103. /// containing a CMakeCache.txt file)
  104. void sourceDirChanged(const QString& dir);
  105. /// signal when the binary directory changes
  106. void binaryDirChanged(const QString& dir);
  107. /// signal for progress events
  108. void progressChanged(const QString& msg, float percent);
  109. /// signal when configure is done
  110. void configureDone(int error);
  111. /// signal when generate is done
  112. void generateDone(int error);
  113. /// signal when there is an output message
  114. void outputMessage(const QString& msg);
  115. /// signal when there is an error message
  116. void errorMessage(const QString& msg);
  117. /// signal when debug output changes
  118. void debugOutputChanged(bool);
  119. protected:
  120. cmake* CMakeInstance;
  121. static void progressCallback(const char* msg, float percent, void* cd);
  122. static void errorCallback(const char* msg, const char* title,
  123. bool&, void* cd);
  124. bool SuppressDevWarnings;
  125. QString SourceDirectory;
  126. QString BinaryDirectory;
  127. QString Generator;
  128. QStringList AvailableGenerators;
  129. QString CMakeExecutable;
  130. };
  131. #endif // __QCMake_h