cmGeneratorTarget.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
  83. const std::string& config) const;
  84. const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
  85. const std::string& config) const;
  86. const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
  87. const std::string& config) const;
  88. const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
  89. const std::string& config) const;
  90. /** Get the full path to the target according to the settings in its
  91. makefile and the configuration type. */
  92. std::string GetFullPath(const std::string& config="", bool implib = false,
  93. bool realname = false) const;
  94. std::string NormalGetFullPath(const std::string& config, bool implib,
  95. bool realname) const;
  96. std::string NormalGetRealName(const std::string& config) const;
  97. /** Get the soname of the target. Allowed only for a shared library. */
  98. std::string GetSOName(const std::string& config) const;
  99. cmTarget* Target;
  100. cmMakefile* Makefile;
  101. cmLocalGenerator* LocalGenerator;
  102. cmGlobalGenerator const* GlobalGenerator;
  103. std::string GetModuleDefinitionFile(const std::string& config) const;
  104. /** Full path with trailing slash to the top-level directory
  105. holding object files for this target. Includes the build
  106. time config name placeholder if needed for the generator. */
  107. std::string ObjectDirectory;
  108. void UseObjectLibraries(std::vector<std::string>& objs,
  109. const std::string& config) const;
  110. void GetAppleArchs(const std::string& config,
  111. std::vector<std::string>& archVec) const;
  112. /** Return the rule variable used to create this type of target. */
  113. std::string GetCreateRuleVariable(std::string const& lang,
  114. std::string const& config) const;
  115. /** Get the include directories for this target. */
  116. std::vector<std::string> GetIncludeDirectories(
  117. const std::string& config, const std::string& lang) const;
  118. bool IsSystemIncludeDirectory(const std::string& dir,
  119. const std::string& config) const;
  120. /** Add the target output files to the global generator manifest. */
  121. void GenerateTargetManifest(const std::string& config) const;
  122. /**
  123. * Trace through the source files in this target and add al source files
  124. * that they depend on, used by all generators
  125. */
  126. void TraceDependencies();
  127. /** Get sources that must be built before the given source. */
  128. std::vector<cmSourceFile*> const*
  129. GetSourceDepends(cmSourceFile const* sf) const;
  130. /**
  131. * Flags for a given source file as used in this target. Typically assigned
  132. * via SET_TARGET_PROPERTIES when the property is a list of source files.
  133. */
  134. enum SourceFileType
  135. {
  136. SourceFileTypeNormal,
  137. SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
  138. SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
  139. SourceFileTypeResource, // is in "RESOURCE" target property *or*
  140. // has MACOSX_PACKAGE_LOCATION=="Resources"
  141. SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
  142. };
  143. struct SourceFileFlags
  144. {
  145. SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
  146. SourceFileFlags(SourceFileFlags const& r):
  147. Type(r.Type), MacFolder(r.MacFolder) {}
  148. SourceFileType Type;
  149. const char* MacFolder; // location inside Mac content folders
  150. };
  151. void GetAutoUicOptions(std::vector<std::string> &result,
  152. const std::string& config) const;
  153. struct SourceFileFlags
  154. GetTargetSourceFileFlags(const cmSourceFile* sf) const;
  155. struct ResxData {
  156. mutable std::set<std::string> ExpectedResxHeaders;
  157. mutable std::vector<cmSourceFile const*> ResxSources;
  158. };
  159. struct XamlData {
  160. std::set<std::string> ExpectedXamlHeaders;
  161. std::set<std::string> ExpectedXamlSources;
  162. std::vector<cmSourceFile const*> XamlSources;
  163. };
  164. private:
  165. friend class cmTargetTraceDependencies;
  166. struct SourceEntry { std::vector<cmSourceFile*> Depends; };
  167. typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
  168. SourceEntriesType SourceEntries;
  169. mutable std::map<cmSourceFile const*, std::string> Objects;
  170. std::set<cmSourceFile const*> ExplicitObjectName;
  171. mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
  172. void ConstructSourceFileFlags() const;
  173. mutable bool SourceFileFlagsConstructed;
  174. mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
  175. struct CompatibleInterfacesBase
  176. {
  177. std::set<std::string> PropsBool;
  178. std::set<std::string> PropsString;
  179. std::set<std::string> PropsNumberMax;
  180. std::set<std::string> PropsNumberMin;
  181. };
  182. CompatibleInterfacesBase const&
  183. GetCompatibleInterfaces(std::string const& config) const;
  184. struct CompatibleInterfaces: public CompatibleInterfacesBase
  185. {
  186. CompatibleInterfaces(): Done(false) {}
  187. bool Done;
  188. };
  189. mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
  190. typedef std::map<std::string, cmComputeLinkInformation*>
  191. cmTargetLinkInformationMap;
  192. mutable cmTargetLinkInformationMap LinkInformation;
  193. void CheckPropertyCompatibility(cmComputeLinkInformation *info,
  194. const std::string& config) const;
  195. cmGeneratorTarget(cmGeneratorTarget const&);
  196. void operator=(cmGeneratorTarget const&);
  197. };
  198. struct cmStrictTargetComparison {
  199. bool operator()(cmTarget const* t1, cmTarget const* t2) const;
  200. };
  201. typedef std::map<cmTarget const*,
  202. cmGeneratorTarget*,
  203. cmStrictTargetComparison> cmGeneratorTargetsType;
  204. #endif