QCMake.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 cache properties in Qt
  27. /// Value is of type String or Bool
  28. struct QCMakeCacheProperty
  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 QCMakeCacheProperty& other) const
  37. {
  38. return this->Key == other.Key;
  39. }
  40. bool operator<(const QCMakeCacheProperty& other) const
  41. {
  42. return this->Key < other.Key;
  43. }
  44. };
  45. // make types usable with QVariant
  46. Q_DECLARE_METATYPE(QCMakeCacheProperty)
  47. typedef QList<QCMakeCacheProperty> QCMakeCachePropertyList;
  48. Q_DECLARE_METATYPE(QCMakeCachePropertyList)
  49. /// Qt API for CMake library.
  50. /// Wrapper like class allows for easier integration with
  51. /// Qt features such as, signal/slot connections, multi-threading, etc..
  52. class QCMake : public QObject
  53. {
  54. Q_OBJECT
  55. public:
  56. QCMake(QObject* p=0);
  57. ~QCMake();
  58. void SetSuppressDevWarnings(bool value);
  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 QCMakeCachePropertyList&);
  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. public:
  83. /// get the list of cache properties
  84. QCMakeCachePropertyList 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 QCMakeCachePropertyList& 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 for progress events
  104. void progressChanged(const QString& msg, float percent);
  105. /// signal when configure is done
  106. void configureDone(int error);
  107. /// signal when generate is done
  108. void generateDone(int error);
  109. /// signal when there is an output message
  110. void outputMessage(const QString& msg);
  111. /// signal when there is an error message
  112. void errorMessage(const QString& msg);
  113. /// signal when debug output changes
  114. void debugOutputChanged(bool);
  115. protected:
  116. cmake* CMakeInstance;
  117. static void progressCallback(const char* msg, float percent, void* cd);
  118. static void errorCallback(const char* msg, const char* title,
  119. bool&, void* cd);
  120. bool SuppressDevWarnings;
  121. QString SourceDirectory;
  122. QString BinaryDirectory;
  123. QString Generator;
  124. QStringList AvailableGenerators;
  125. QString CMakeExecutable;
  126. };
  127. #endif // __QCMake_h