cmMakefileTargetGenerator.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 cmMakefileTargetGenerator_h
  14. #define cmMakefileTargetGenerator_h
  15. #include "cmLocalUnixMakefileGenerator3.h"
  16. class cmCustomCommand;
  17. class cmDependInformation;
  18. class cmDepends;
  19. class cmGeneratedFileStream;
  20. class cmGlobalGenerator;
  21. class cmLocalUnixMakefileGenerator3;
  22. class cmMakeDepend;
  23. class cmMakefile;
  24. class cmTarget;
  25. class cmSourceFile;
  26. /** \class cmMakefileTargetGenerator
  27. * \brief Support Routines for writing makefiles
  28. *
  29. */
  30. class cmMakefileTargetGenerator
  31. {
  32. public:
  33. // constructor to set the ivars
  34. cmMakefileTargetGenerator();
  35. virtual ~cmMakefileTargetGenerator() {};
  36. // construct using this factory call
  37. static cmMakefileTargetGenerator *New(cmLocalUnixMakefileGenerator3 *lg,
  38. cmStdString tgtName,
  39. cmTarget *tgt);
  40. /* the main entry point for this class. Writes the Makefiles associated
  41. with this target */
  42. virtual void WriteRuleFiles() = 0;
  43. protected:
  44. // create the file and directory etc
  45. void CreateRuleFile();
  46. // outputs the rules for any custom commands used by this target
  47. void WriteCustomCommandsForTarget();
  48. // write some common code at the top of build.make
  49. void WriteCommonCodeRules();
  50. // write the provide require rules for this target
  51. void WriteTargetRequiresRules();
  52. // write the clean rules for this target
  53. void WriteTargetCleanRules();
  54. // write the depend rules for this target
  55. void WriteTargetDependRules();
  56. // write the rules for an object
  57. void WriteObjectRuleFiles(cmSourceFile& source);
  58. // write the build rule for an object
  59. void WriteObjectBuildFile(std::string &obj,
  60. const char *lang,
  61. cmSourceFile& source,
  62. std::vector<std::string>& depends);
  63. // write the depend.make file for an object
  64. void WriteObjectDependRules(cmSourceFile& source,
  65. std::vector<std::string>& depends);
  66. // this is responsible for writing all of the rules for all this
  67. // directories custom commands (but not utility targets)
  68. void WriteCustomCommands();
  69. void GenerateCustomRuleFile(const cmCustomCommand& cc);
  70. // write out the variable that lists the objects for this target
  71. void WriteObjectsVariable(std::string& variableName,
  72. std::string& variableNameExternal);
  73. // Return the a string with -F flags on apple
  74. std::string GetFrameworkFlags();
  75. // append intertarget dependencies
  76. void AppendTargetDepends(std::vector<std::string>& depends);
  77. virtual void CloseFileStreams();
  78. void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
  79. std::string& linkFlags);
  80. cmStdString TargetName;
  81. cmTarget *Target;
  82. cmLocalUnixMakefileGenerator3 *LocalGenerator;
  83. cmGlobalGenerator *GlobalGenerator;
  84. cmMakefile *Makefile;
  85. // the full path to the build file
  86. std::string BuildFileName;
  87. std::string BuildFileNameFull;
  88. // the path to the directory the build file is in
  89. std::string TargetBuildDirectory;
  90. std::string TargetBuildDirectoryFull;
  91. // the stream for the build file
  92. cmGeneratedFileStream *BuildFileStream;
  93. // the stream for the flag file
  94. std::string FlagFileNameFull;
  95. cmGeneratedFileStream *FlagFileStream;
  96. // the stream for the info file
  97. std::string InfoFileNameFull;
  98. cmGeneratedFileStream *InfoFileStream;
  99. // files to clean
  100. std::vector<std::string> CleanFiles;
  101. // objects used by this target
  102. std::vector<std::string> Objects;
  103. std::vector<std::string> ExternalObjects;
  104. std::set<std::string> ExtraContent;
  105. // Set of object file names that will be built in this directory.
  106. std::set<cmStdString> ObjectFiles;
  107. //==================================================================
  108. // Convenience routines that do nothing more than forward to
  109. // implementaitons
  110. std::string Convert(const char* source,
  111. cmLocalGenerator::RelativeRoot relative,
  112. cmLocalGenerator::OutputFormat output =
  113. cmLocalGenerator::UNCHANGED,
  114. bool optional = false)
  115. {
  116. return this->LocalGenerator->Convert(source, relative, output, optional);
  117. }
  118. };
  119. #endif