cmGeneratorTarget.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 cmComputeLinkInformation;
  20. class cmGeneratorTarget
  21. {
  22. public:
  23. cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg);
  24. ~cmGeneratorTarget();
  25. cmLocalGenerator* GetLocalGenerator() const;
  26. bool IsImported() const;
  27. const char *GetLocation(const std::string& config) const;
  28. /** Get the location of the target in the build tree with a placeholder
  29. referencing the configuration in the native build system. This
  30. location is suitable for use as the LOCATION target property. */
  31. const char* GetLocationForBuild() const;
  32. cmComputeLinkInformation*
  33. GetLinkInformation(const std::string& config) const;
  34. int GetType() const;
  35. std::string GetName() const;
  36. const char *GetProperty(const std::string& prop) const;
  37. bool GetPropertyAsBool(const std::string& prop) const;
  38. void GetSourceFiles(std::vector<cmSourceFile*>& files,
  39. const std::string& config) const;
  40. void GetObjectSources(std::vector<cmSourceFile const*> &,
  41. const std::string& config) const;
  42. const std::string& GetObjectName(cmSourceFile const* file);
  43. bool HasExplicitObjectName(cmSourceFile const* file) const;
  44. void AddExplicitObjectName(cmSourceFile const* sf);
  45. void GetResxSources(std::vector<cmSourceFile const*>&,
  46. const std::string& config) const;
  47. void GetIDLSources(std::vector<cmSourceFile const*>&,
  48. const std::string& config) const;
  49. void GetExternalObjects(std::vector<cmSourceFile const*>&,
  50. const std::string& config) const;
  51. void GetHeaderSources(std::vector<cmSourceFile const*>&,
  52. const std::string& config) const;
  53. void GetExtraSources(std::vector<cmSourceFile const*>&,
  54. const std::string& config) const;
  55. void GetCustomCommands(std::vector<cmSourceFile const*>&,
  56. const std::string& config) const;
  57. void GetExpectedResxHeaders(std::set<std::string>&,
  58. const std::string& config) const;
  59. void GetAppManifest(std::vector<cmSourceFile const*>&,
  60. const std::string& config) const;
  61. void GetCertificates(std::vector<cmSourceFile const*>&,
  62. const std::string& config) const;
  63. void GetXamlSources(std::vector<cmSourceFile const*>&,
  64. const std::string& config) const;
  65. void GetExpectedXamlHeaders(std::set<std::string>&,
  66. const std::string& config) const;
  67. void GetExpectedXamlSources(std::set<std::string>&,
  68. const std::string& config) const;
  69. void ComputeObjectMapping();
  70. const char* GetFeature(const std::string& feature,
  71. const std::string& config) const;
  72. bool GetFeatureAsBool(const std::string& feature,
  73. const std::string& config) const;
  74. bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
  75. const std::string& config) const;
  76. bool IsLinkInterfaceDependentStringProperty(const std::string &p,
  77. const std::string& config) const;
  78. bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
  79. const std::string& config) const;
  80. bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
  81. const std::string& config) const;
  82. /** Get the full path to the target according to the settings in its
  83. makefile and the configuration type. */
  84. std::string GetFullPath(const std::string& config="", bool implib = false,
  85. bool realname = false) const;
  86. std::string NormalGetFullPath(const std::string& config, bool implib,
  87. bool realname) const;
  88. std::string NormalGetRealName(const std::string& config) const;
  89. /** Get the soname of the target. Allowed only for a shared library. */
  90. std::string GetSOName(const std::string& config) const;
  91. cmTarget* Target;
  92. cmMakefile* Makefile;
  93. cmLocalGenerator* LocalGenerator;
  94. cmGlobalGenerator const* GlobalGenerator;
  95. std::string GetModuleDefinitionFile(const std::string& config) const;
  96. /** Full path with trailing slash to the top-level directory
  97. holding object files for this target. Includes the build
  98. time config name placeholder if needed for the generator. */
  99. std::string ObjectDirectory;
  100. void UseObjectLibraries(std::vector<std::string>& objs,
  101. const std::string& config) const;
  102. void GetAppleArchs(const std::string& config,
  103. std::vector<std::string>& archVec) const;
  104. /** Return the rule variable used to create this type of target. */
  105. std::string GetCreateRuleVariable(std::string const& lang,
  106. std::string const& config) const;
  107. /** Get the include directories for this target. */
  108. std::vector<std::string> GetIncludeDirectories(
  109. const std::string& config, const std::string& lang) const;
  110. bool IsSystemIncludeDirectory(const std::string& dir,
  111. const std::string& config) const;
  112. /** Add the target output files to the global generator manifest. */
  113. void GenerateTargetManifest(const std::string& config) const;
  114. /**
  115. * Trace through the source files in this target and add al source files
  116. * that they depend on, used by all generators
  117. */
  118. void TraceDependencies();
  119. /** Get sources that must be built before the given source. */
  120. std::vector<cmSourceFile*> const*
  121. GetSourceDepends(cmSourceFile const* sf) const;
  122. /**
  123. * Flags for a given source file as used in this target. Typically assigned
  124. * via SET_TARGET_PROPERTIES when the property is a list of source files.
  125. */
  126. enum SourceFileType
  127. {
  128. SourceFileTypeNormal,
  129. SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
  130. SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
  131. SourceFileTypeResource, // is in "RESOURCE" target property *or*
  132. // has MACOSX_PACKAGE_LOCATION=="Resources"
  133. SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
  134. };
  135. struct SourceFileFlags
  136. {
  137. SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
  138. SourceFileFlags(SourceFileFlags const& r):
  139. Type(r.Type), MacFolder(r.MacFolder) {}
  140. SourceFileType Type;
  141. const char* MacFolder; // location inside Mac content folders
  142. };
  143. void GetAutoUicOptions(std::vector<std::string> &result,
  144. const std::string& config) const;
  145. struct SourceFileFlags
  146. GetTargetSourceFileFlags(const cmSourceFile* sf) const;
  147. struct ResxData {
  148. mutable std::set<std::string> ExpectedResxHeaders;
  149. mutable std::vector<cmSourceFile const*> ResxSources;
  150. };
  151. struct XamlData {
  152. std::set<std::string> ExpectedXamlHeaders;
  153. std::set<std::string> ExpectedXamlSources;
  154. std::vector<cmSourceFile const*> XamlSources;
  155. };
  156. private:
  157. friend class cmTargetTraceDependencies;
  158. struct SourceEntry { std::vector<cmSourceFile*> Depends; };
  159. typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
  160. SourceEntriesType SourceEntries;
  161. mutable std::map<cmSourceFile const*, std::string> Objects;
  162. std::set<cmSourceFile const*> ExplicitObjectName;
  163. mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
  164. void ConstructSourceFileFlags() const;
  165. mutable bool SourceFileFlagsConstructed;
  166. mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
  167. struct CompatibleInterfacesBase
  168. {
  169. std::set<std::string> PropsBool;
  170. std::set<std::string> PropsString;
  171. std::set<std::string> PropsNumberMax;
  172. std::set<std::string> PropsNumberMin;
  173. };
  174. CompatibleInterfacesBase const&
  175. GetCompatibleInterfaces(std::string const& config) const;
  176. struct CompatibleInterfaces: public CompatibleInterfacesBase
  177. {
  178. CompatibleInterfaces(): Done(false) {}
  179. bool Done;
  180. };
  181. mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
  182. typedef std::map<std::string, cmComputeLinkInformation*>
  183. cmTargetLinkInformationMap;
  184. mutable cmTargetLinkInformationMap LinkInformation;
  185. void CheckPropertyCompatibility(cmComputeLinkInformation *info,
  186. const std::string& config) const;
  187. cmGeneratorTarget(cmGeneratorTarget const&);
  188. void operator=(cmGeneratorTarget const&);
  189. };
  190. struct cmStrictTargetComparison {
  191. bool operator()(cmTarget const* t1, cmTarget const* t2) const;
  192. };
  193. typedef std::map<cmTarget const*,
  194. cmGeneratorTarget*,
  195. cmStrictTargetComparison> cmGeneratorTargetsType;
  196. #endif