cmLocalUnixMakefileGenerator2.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 cmLocalUnixMakefileGenerator2_h
  14. #define cmLocalUnixMakefileGenerator2_h
  15. #include "cmLocalUnixMakefileGenerator.h"
  16. class cmDependInformation;
  17. class cmMakeDepend;
  18. class cmTarget;
  19. class cmSourceFile;
  20. /** \class cmLocalUnixMakefileGenerator2
  21. * \brief Write a LocalUnix makefiles.
  22. *
  23. * cmLocalUnixMakefileGenerator2 produces a LocalUnix makefile from its
  24. * member m_Makefile.
  25. */
  26. class cmLocalUnixMakefileGenerator2 : public cmLocalUnixMakefileGenerator
  27. {
  28. public:
  29. ///! Set cache only and recurse to false by default.
  30. cmLocalUnixMakefileGenerator2();
  31. virtual ~cmLocalUnixMakefileGenerator2();
  32. /**
  33. * Generate the makefile for this directory. fromTheTop indicates if this
  34. * is being invoked as part of a global Generate or specific to this
  35. * directory. The difference is that when done from the Top we might skip
  36. * some steps to save time, such as dependency generation for the
  37. * makefiles. This is done by a direct invocation from make.
  38. */
  39. virtual void Generate(bool fromTheTop);
  40. /** Called from command-line hook to scan dependencies. */
  41. static bool ScanDependencies(std::vector<std::string> const& args);
  42. protected:
  43. void GenerateMakefile();
  44. void GenerateCMakefile();
  45. void GenerateTargetRuleFile(const cmTarget& target);
  46. void GenerateObjectRuleFile(const cmTarget& target,
  47. const cmSourceFile& source);
  48. void WriteDisclaimer(std::ostream& os);
  49. void WriteExecutableRule(std::ostream& ruleFileStream,
  50. const char* ruleFileName,
  51. const cmTarget& target,
  52. std::vector<std::string>& objects);
  53. void WriteStaticLibraryRule(std::ostream& ruleFileStream,
  54. const char* ruleFileName,
  55. const cmTarget& target,
  56. std::vector<std::string>& objects);
  57. void WriteSharedLibraryRule(std::ostream& ruleFileStream,
  58. const char* ruleFileName,
  59. const cmTarget& target,
  60. std::vector<std::string>& objects);
  61. void WriteModuleLibraryRule(std::ostream& ruleFileStream,
  62. const char* ruleFileName,
  63. const cmTarget& target,
  64. std::vector<std::string>& objects);
  65. void WriteLibraryRule(std::ostream& ruleFileStream,
  66. const char* ruleFileName,
  67. const cmTarget& target,
  68. std::vector<std::string>& objects,
  69. const char* linkRuleVar,
  70. const char* extraLinkFlags);
  71. std::string GetTargetDirectory(const cmTarget& target);
  72. std::string GetObjectFileName(const cmTarget& target,
  73. const cmSourceFile& source);
  74. const char* GetSourceFileLanguage(const cmSourceFile& source);
  75. std::string ConvertToFullPath(const std::string& localPath);
  76. void AddLanguageFlags(std::string& flags, const char* lang);
  77. void AddSharedFlags(std::string& flags, const char* lang, bool shared);
  78. void AddConfigVariableFlags(std::string& flags, const char* var);
  79. void AppendFlags(std::string& flags, const char* newFlags);
  80. void AppendLibDepend(std::vector<std::string>& depends, const char* name);
  81. void AppendRecursiveMake(std::string& cmd, const char* file, const char* tgt);
  82. void WriteJumpAndBuildRules(std::ostream& makefileStream);
  83. static bool ScanDependenciesC(const char* objFile, const char* srcFile,
  84. std::vector<std::string> const& includes);
  85. private:
  86. // Map from target name to build directory containing it for
  87. // jump-and-build targets.
  88. struct RemoteTarget
  89. {
  90. std::string m_BuildDirectory;
  91. std::string m_FilePath;
  92. };
  93. std::map<cmStdString, RemoteTarget> m_JumpAndBuild;
  94. };
  95. #endif