cmGeneratorTarget.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. std::string 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,
  28. const std::string& config) const;
  29. void GetObjectSources(std::vector<cmSourceFile const*> &,
  30. const std::string& config) const;
  31. const std::string& GetObjectName(cmSourceFile const* file);
  32. bool HasExplicitObjectName(cmSourceFile const* file) const;
  33. void AddExplicitObjectName(cmSourceFile const* sf);
  34. void GetResxSources(std::vector<cmSourceFile const*>&,
  35. const std::string& config) const;
  36. void GetIDLSources(std::vector<cmSourceFile const*>&,
  37. const std::string& config) const;
  38. void GetExternalObjects(std::vector<cmSourceFile const*>&,
  39. const std::string& config) const;
  40. void GetHeaderSources(std::vector<cmSourceFile const*>&,
  41. const std::string& config) const;
  42. void GetExtraSources(std::vector<cmSourceFile const*>&,
  43. const std::string& config) const;
  44. void GetCustomCommands(std::vector<cmSourceFile const*>&,
  45. const std::string& config) const;
  46. void GetExpectedResxHeaders(std::set<std::string>&,
  47. const std::string& config) const;
  48. void GetAppManifest(std::vector<cmSourceFile const*>&,
  49. const std::string& config) const;
  50. void GetCertificates(std::vector<cmSourceFile const*>&,
  51. const std::string& config) const;
  52. void GetXamlSources(std::vector<cmSourceFile const*>&,
  53. const std::string& config) const;
  54. void GetExpectedXamlHeaders(std::set<std::string>&,
  55. const std::string& config) const;
  56. void GetExpectedXamlSources(std::set<std::string>&,
  57. const std::string& config) const;
  58. void ComputeObjectMapping();
  59. const char* GetFeature(const std::string& feature,
  60. const std::string& config) const;
  61. bool GetFeatureAsBool(const std::string& feature,
  62. const std::string& config) const;
  63. cmTarget* Target;
  64. cmMakefile* Makefile;
  65. cmLocalGenerator* LocalGenerator;
  66. cmGlobalGenerator const* GlobalGenerator;
  67. std::string GetModuleDefinitionFile(const std::string& config) const;
  68. /** Full path with trailing slash to the top-level directory
  69. holding object files for this target. Includes the build
  70. time config name placeholder if needed for the generator. */
  71. std::string ObjectDirectory;
  72. void UseObjectLibraries(std::vector<std::string>& objs,
  73. const std::string& config) const;
  74. void GetAppleArchs(const std::string& config,
  75. std::vector<std::string>& archVec) const;
  76. /** Return the rule variable used to create this type of target. */
  77. std::string GetCreateRuleVariable(std::string const& lang,
  78. std::string const& config) const;
  79. /** Get the include directories for this target. */
  80. std::vector<std::string> GetIncludeDirectories(
  81. const std::string& config, const std::string& lang) const;
  82. bool IsSystemIncludeDirectory(const std::string& dir,
  83. const std::string& config) const;
  84. /** Add the target output files to the global generator manifest. */
  85. void GenerateTargetManifest(const std::string& config) const;
  86. /**
  87. * Trace through the source files in this target and add al source files
  88. * that they depend on, used by all generators
  89. */
  90. void TraceDependencies();
  91. /** Get sources that must be built before the given source. */
  92. std::vector<cmSourceFile*> const*
  93. GetSourceDepends(cmSourceFile const* sf) const;
  94. /**
  95. * Flags for a given source file as used in this target. Typically assigned
  96. * via SET_TARGET_PROPERTIES when the property is a list of source files.
  97. */
  98. enum SourceFileType
  99. {
  100. SourceFileTypeNormal,
  101. SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
  102. SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
  103. SourceFileTypeResource, // is in "RESOURCE" target property *or*
  104. // has MACOSX_PACKAGE_LOCATION=="Resources"
  105. SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
  106. };
  107. struct SourceFileFlags
  108. {
  109. SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
  110. SourceFileFlags(SourceFileFlags const& r):
  111. Type(r.Type), MacFolder(r.MacFolder) {}
  112. SourceFileType Type;
  113. const char* MacFolder; // location inside Mac content folders
  114. };
  115. struct SourceFileFlags
  116. GetTargetSourceFileFlags(const cmSourceFile* sf) const;
  117. struct ResxData {
  118. mutable std::set<std::string> ExpectedResxHeaders;
  119. mutable std::vector<cmSourceFile const*> ResxSources;
  120. };
  121. struct XamlData {
  122. std::set<std::string> ExpectedXamlHeaders;
  123. std::set<std::string> ExpectedXamlSources;
  124. std::vector<cmSourceFile const*> XamlSources;
  125. };
  126. private:
  127. friend class cmTargetTraceDependencies;
  128. struct SourceEntry { std::vector<cmSourceFile*> Depends; };
  129. typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
  130. SourceEntriesType SourceEntries;
  131. mutable std::map<cmSourceFile const*, std::string> Objects;
  132. std::set<cmSourceFile const*> ExplicitObjectName;
  133. mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
  134. void ConstructSourceFileFlags() const;
  135. mutable bool SourceFileFlagsConstructed;
  136. mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
  137. cmGeneratorTarget(cmGeneratorTarget const&);
  138. void operator=(cmGeneratorTarget const&);
  139. };
  140. struct cmStrictTargetComparison {
  141. bool operator()(cmTarget const* t1, cmTarget const* t2) const;
  142. };
  143. typedef std::map<cmTarget const*,
  144. cmGeneratorTarget*,
  145. cmStrictTargetComparison> cmGeneratorTargetsType;
  146. #endif