cmIDEOptions.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 cmIDEOptions_h
  11. #define cmIDEOptions_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmIDEFlagTable.h"
  14. /** \class cmIDEOptions
  15. * \brief Superclass for IDE option processing
  16. */
  17. class cmIDEOptions
  18. {
  19. public:
  20. cmIDEOptions();
  21. virtual ~cmIDEOptions();
  22. // Store definitions and flags.
  23. void AddDefine(const std::string& define);
  24. void AddDefines(const char* defines);
  25. void AddDefines(const std::vector<std::string> &defines);
  26. void AddFlag(const char* flag, const char* value);
  27. void AddFlag(const char* flag, std::vector<std::string> const& value);
  28. void AppendFlag(std::string const& flag, std::string const& value);
  29. void RemoveFlag(const char* flag);
  30. const char* GetFlag(const char* flag);
  31. protected:
  32. // create a map of xml tags to the values they should have in the output
  33. // for example, "BufferSecurityCheck" = "TRUE"
  34. // first fill this table with the values for the configuration
  35. // Debug, Release, etc,
  36. // Then parse the command line flags specified in CMAKE_CXX_FLAGS
  37. // and CMAKE_C_FLAGS
  38. // and overwrite or add new values to this map
  39. class FlagValue: public std::vector<std::string>
  40. {
  41. typedef std::vector<std::string> derived;
  42. public:
  43. FlagValue& operator=(std::string const& r)
  44. {
  45. this->resize(1);
  46. this->operator[](0) = r;
  47. return *this;
  48. }
  49. FlagValue& operator=(std::vector<std::string> const& r)
  50. {
  51. this->derived::operator=(r);
  52. return *this;
  53. }
  54. };
  55. std::map<std::string, FlagValue > FlagMap;
  56. // Preprocessor definitions.
  57. std::vector<std::string> Defines;
  58. // Unrecognized flags that get no special handling.
  59. std::string FlagString;
  60. bool DoingDefine;
  61. bool AllowDefine;
  62. bool AllowSlash;
  63. cmIDEFlagTable const* DoingFollowing;
  64. enum { FlagTableCount = 16 };
  65. cmIDEFlagTable const* FlagTable[FlagTableCount];
  66. void HandleFlag(const char* flag);
  67. bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
  68. bool& flag_handled);
  69. void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
  70. virtual void StoreUnknownFlag(const char* flag) = 0;
  71. };
  72. #endif