QCMake.h 4.4 KB

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