cmAddDefinitionsCommand.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 cmAddDefinitionsCommand_h
  14. #define cmAddDefinitionsCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmAddDefinitionsCommand
  17. * \brief Specify a list of compiler defines
  18. *
  19. * cmAddDefinitionsCommand specifies a list of compiler defines. These defines
  20. * will be added to the compile command.
  21. */
  22. class cmAddDefinitionsCommand : public cmCommand
  23. {
  24. public:
  25. /**
  26. * This is a virtual constructor for the command.
  27. */
  28. virtual cmCommand* Clone()
  29. {
  30. return new cmAddDefinitionsCommand;
  31. }
  32. /**
  33. * This is called when the command is first encountered in
  34. * the CMakeLists.txt file.
  35. */
  36. virtual bool InitialPass(std::vector<std::string> const& args,
  37. cmExecutionStatus &status);
  38. /**
  39. * The name of the command as specified in CMakeList.txt.
  40. */
  41. virtual const char* GetName() {return "add_definitions";}
  42. /**
  43. * Succinct documentation.
  44. */
  45. virtual const char* GetTerseDocumentation()
  46. {
  47. return "Adds -D define flags to the compilation of source files.";
  48. }
  49. /**
  50. * More documentation.
  51. */
  52. virtual const char* GetFullDocumentation()
  53. {
  54. return
  55. " add_definitions(-DFOO -DBAR ...)\n"
  56. "Adds flags to the compiler command line for sources in the current "
  57. "directory and below. This command can be used to add any flags, "
  58. "but it was originally intended to add preprocessor definitions. "
  59. "Flags beginning in -D or /D that look like preprocessor definitions "
  60. "are automatically added to the COMPILE_DEFINITIONS property for "
  61. "the current directory. Definitions with non-trival values may be "
  62. "left in the set of flags instead of being converted for reasons of "
  63. "backwards compatibility. See documentation of the directory, "
  64. "target, and source file COMPILE_DEFINITIONS properties for details "
  65. "on adding preprocessor definitions to specific scopes and "
  66. "configurations."
  67. ;
  68. }
  69. cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
  70. private:
  71. bool ParseDefinition(std::string const& def);
  72. };
  73. #endif