cmGeneratorTarget.h 7.1 KB

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