cmGeneratorTarget.h 6.8 KB

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