cmGeneratorTarget.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2012 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 cmGeneratorTarget_h
  11. #define cmGeneratorTarget_h
  12. #include "cmStandardIncludes.h"
  13. class cmCustomCommand;
  14. class cmGlobalGenerator;
  15. class cmLocalGenerator;
  16. class cmMakefile;
  17. class cmSourceFile;
  18. class cmTarget;
  19. class cmGeneratorTarget
  20. {
  21. public:
  22. cmGeneratorTarget(cmTarget*);
  23. int GetType() const;
  24. const char *GetName() const;
  25. const char *GetProperty(const std::string& prop) const;
  26. bool GetPropertyAsBool(const std::string& prop) const;
  27. void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
  28. void GetObjectSources(std::vector<cmSourceFile*> &) const;
  29. const std::string& GetObjectName(cmSourceFile const* file);
  30. void AddObject(cmSourceFile *sf, std::string const&name);
  31. bool HasExplicitObjectName(cmSourceFile const* file) const;
  32. void AddExplicitObjectName(cmSourceFile* sf);
  33. void GetResxSources(std::vector<cmSourceFile*>&) const;
  34. void GetIDLSources(std::vector<cmSourceFile*>&) const;
  35. void GetExternalObjects(std::vector<cmSourceFile*>&) const;
  36. void GetHeaderSources(std::vector<cmSourceFile*>&) const;
  37. void GetExtraSources(std::vector<cmSourceFile*>&) const;
  38. void GetCustomCommands(std::vector<cmSourceFile*>&) const;
  39. void GetExpectedResxHeaders(std::set<std::string>&) const;
  40. cmTarget* Target;
  41. cmMakefile* Makefile;
  42. cmLocalGenerator* LocalGenerator;
  43. cmGlobalGenerator const* GlobalGenerator;
  44. std::string GetModuleDefinitionFile() const;
  45. /** Full path with trailing slash to the top-level directory
  46. holding object files for this target. Includes the build
  47. time config name placeholder if needed for the generator. */
  48. std::string ObjectDirectory;
  49. void UseObjectLibraries(std::vector<std::string>& objs) const;
  50. void GetAppleArchs(const char* config,
  51. std::vector<std::string>& archVec) const;
  52. ///! Return the rule variable used to create this type of target,
  53. // need to add CMAKE_(LANG) for full name.
  54. const char* GetCreateRuleVariable() const;
  55. /** Get the include directories for this target. */
  56. std::vector<std::string> GetIncludeDirectories(const char *config) const;
  57. bool IsSystemIncludeDirectory(const char *dir, const char *config) const;
  58. /** Add the target output files to the global generator manifest. */
  59. void GenerateTargetManifest(const char* config) const;
  60. /**
  61. * Trace through the source files in this target and add al source files
  62. * that they depend on, used by all generators
  63. */
  64. void TraceDependencies();
  65. void LookupObjectLibraries();
  66. /** Get sources that must be built before the given source. */
  67. std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const;
  68. /**
  69. * Flags for a given source file as used in this target. Typically assigned
  70. * via SET_TARGET_PROPERTIES when the property is a list of source files.
  71. */
  72. enum SourceFileType
  73. {
  74. SourceFileTypeNormal,
  75. SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
  76. SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
  77. SourceFileTypeResource, // is in "RESOURCE" target property *or*
  78. // has MACOSX_PACKAGE_LOCATION=="Resources"
  79. SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
  80. };
  81. struct SourceFileFlags
  82. {
  83. SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
  84. SourceFileFlags(SourceFileFlags const& r):
  85. Type(r.Type), MacFolder(r.MacFolder) {}
  86. SourceFileType Type;
  87. const char* MacFolder; // location inside Mac content folders
  88. };
  89. struct SourceFileFlags
  90. GetTargetSourceFileFlags(const cmSourceFile* sf) const;
  91. struct ResxData {
  92. mutable std::set<std::string> ExpectedResxHeaders;
  93. mutable std::vector<cmSourceFile*> ResxSources;
  94. };
  95. private:
  96. friend class cmTargetTraceDependencies;
  97. struct SourceEntry { std::vector<cmSourceFile*> Depends; };
  98. typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
  99. SourceEntriesType SourceEntries;
  100. std::map<cmSourceFile const*, std::string> Objects;
  101. std::set<cmSourceFile const*> ExplicitObjectName;
  102. mutable std::vector<cmSourceFile*> ObjectSources;
  103. std::vector<cmTarget*> ObjectLibraries;
  104. mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
  105. void ConstructSourceFileFlags() const;
  106. mutable bool SourceFileFlagsConstructed;
  107. mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
  108. cmGeneratorTarget(cmGeneratorTarget const&);
  109. void operator=(cmGeneratorTarget const&);
  110. };
  111. struct cmStrictTargetComparison {
  112. bool operator()(cmTarget const* t1, cmTarget const* t2) const;
  113. };
  114. typedef std::map<cmTarget const*,
  115. cmGeneratorTarget*,
  116. cmStrictTargetComparison> cmGeneratorTargetsType;
  117. #endif