cmGlobalUnixMakefileGenerator3.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator3
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2005 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 cmGlobalUnixMakefileGenerator3_h
  14. #define cmGlobalUnixMakefileGenerator3_h
  15. #include "cmGlobalGenerator.h"
  16. class cmGeneratedFileStream;
  17. class cmLocalUnixMakefileGenerator3;
  18. /** \class cmGlobalUnixMakefileGenerator3
  19. * \brief Write a Unix makefiles.
  20. *
  21. * cmGlobalUnixMakefileGenerator3 manages UNIX build process for a tree
  22. The basic approach of this generator is to produce Makefiles that will all
  23. be run with the current working directory set to the Home Output
  24. directory. The one exception to this is the subdirectory Makefiles which are
  25. created as a convenience and just cd up to the Home Output directory and
  26. invoke the main Makefiles.
  27. The make process starts with Makefile. Makefile should only contain the
  28. targets the user is likely to invoke directly from a make command line. No
  29. internal targets should be in this file. Makefile2 contains the internal
  30. targets that are required to make the process work.
  31. Makefile2 in turn will recursively make targets in the correct order. Each
  32. target has its own directory <target>.dir and its own makefile build.make in
  33. that directory. Also in that directory is a couple makefiles per source file
  34. used by the target. Typically these are named source.obj.build.make and
  35. source.obj.build.depend.make. The source.obj.build.make contains the rules
  36. for building, cleaning, and computing dependencies for the given source
  37. file. The build.depend.make contains additional dependencies that were
  38. computed during dependency scanning. An additional file called
  39. source.obj.depend is used as a marker to indicate when dependencies must be
  40. rescanned.
  41. Rules for custom commands follow the same model as rules for source files.
  42. */
  43. class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
  44. {
  45. public:
  46. cmGlobalUnixMakefileGenerator3();
  47. static cmGlobalGenerator* New() { return new cmGlobalUnixMakefileGenerator3; }
  48. ///! Get the name for the generator.
  49. virtual const char* GetName() const {
  50. return cmGlobalUnixMakefileGenerator3::GetActualName();}
  51. static const char* GetActualName() {return "Unix Makefiles";}
  52. /** Get the documentation entry for this generator. */
  53. virtual void GetDocumentation(cmDocumentationEntry& entry) const;
  54. ///! Create a local generator appropriate to this Global Generator3
  55. virtual cmLocalGenerator *CreateLocalGenerator();
  56. /**
  57. * Try to determine system infomation such as shared library
  58. * extension, pthreads, byte order etc.
  59. */
  60. virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
  61. /**
  62. * Generate the all required files for building this project/tree. This
  63. * basically creates a series of LocalGenerators for each directory and
  64. * requests that they Generate.
  65. */
  66. virtual void Generate();
  67. void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
  68. std::vector<cmLocalGenerator *> &);
  69. protected:
  70. void WriteMainMakefile();
  71. void WriteMainMakefile2();
  72. void WriteMainCMakefile();
  73. void WriteAllRules(cmLocalUnixMakefileGenerator3 *lg,
  74. std::ostream& makefileStream);
  75. void WriteHelpRule(std::ostream& ruleFileStream);
  76. void WriteConvenienceRules(std::ostream& ruleFileStream,
  77. cmLocalUnixMakefileGenerator3 *,
  78. std::set<cmStdString> &emitted);
  79. void WriteConvenienceRules2(std::ostream& ruleFileStream,
  80. cmLocalUnixMakefileGenerator3 *,
  81. bool exclude);
  82. void WriteDirectoryRules(std::ostream& ruleFileStream,
  83. cmLocalUnixMakefileGenerator3 *lg);
  84. void WriteDirectoryRules2(std::ostream& ruleFileStream,
  85. cmLocalUnixMakefileGenerator3 *lg);
  86. void AppendGlobalTargetDepends(std::vector<std::string>& depends,
  87. cmTarget& target);
  88. void AppendAnyGlobalDepend(std::vector<std::string>& depends,
  89. const char* name, std::set<cmStdString>& emitted);
  90. // does this generator need a requires step for any of its targets
  91. bool NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg, const char *);
  92. };
  93. #endif