cmTarget.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 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 cmTarget_h
  11. #define cmTarget_h
  12. #include "cmCustomCommand.h"
  13. #include "cmPropertyMap.h"
  14. #include "cmPolicies.h"
  15. #include "cmListFileCache.h"
  16. #include <cmsys/auto_ptr.hxx>
  17. #define CM_FOR_EACH_TARGET_POLICY(F) \
  18. F(CMP0003) \
  19. F(CMP0004) \
  20. F(CMP0008) \
  21. F(CMP0020) \
  22. F(CMP0021) \
  23. F(CMP0022) \
  24. F(CMP0027) \
  25. F(CMP0038) \
  26. F(CMP0041) \
  27. F(CMP0042) \
  28. F(CMP0046)
  29. class cmake;
  30. class cmMakefile;
  31. class cmSourceFile;
  32. class cmGlobalGenerator;
  33. class cmComputeLinkInformation;
  34. class cmListFileBacktrace;
  35. class cmTarget;
  36. class cmGeneratorTarget;
  37. class cmTargetTraceDependencies;
  38. struct cmTargetLinkInformationMap:
  39. public std::map<std::pair<cmTarget const* , std::string>,
  40. cmComputeLinkInformation*>
  41. {
  42. typedef std::map<std::pair<cmTarget const* , std::string>,
  43. cmComputeLinkInformation*> derived;
  44. cmTargetLinkInformationMap() {}
  45. cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r);
  46. ~cmTargetLinkInformationMap();
  47. };
  48. class cmTargetInternals;
  49. class cmTargetInternalPointer
  50. {
  51. public:
  52. cmTargetInternalPointer();
  53. cmTargetInternalPointer(cmTargetInternalPointer const& r);
  54. ~cmTargetInternalPointer();
  55. cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r);
  56. cmTargetInternals* operator->() const { return this->Pointer; }
  57. cmTargetInternals* Get() const { return this->Pointer; }
  58. private:
  59. cmTargetInternals* Pointer;
  60. };
  61. /** \class cmTarget
  62. * \brief Represent a library or executable target loaded from a makefile.
  63. *
  64. * cmTarget represents a target loaded from
  65. * a makefile.
  66. */
  67. class cmTarget
  68. {
  69. public:
  70. cmTarget();
  71. enum TargetType { EXECUTABLE, STATIC_LIBRARY,
  72. SHARED_LIBRARY, MODULE_LIBRARY,
  73. OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET,
  74. INTERFACE_LIBRARY,
  75. UNKNOWN_LIBRARY};
  76. static const char* GetTargetTypeName(TargetType targetType);
  77. enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
  78. /**
  79. * Return the type of target.
  80. */
  81. TargetType GetType() const
  82. {
  83. return this->TargetTypeValue;
  84. }
  85. /**
  86. * Set the target type
  87. */
  88. void SetType(TargetType f, const std::string& name);
  89. void MarkAsImported();
  90. ///! Set/Get the name of the target
  91. const std::string& GetName() const {return this->Name;}
  92. std::string GetExportName() const;
  93. ///! Set the cmMakefile that owns this target
  94. void SetMakefile(cmMakefile *mf);
  95. cmMakefile *GetMakefile() const { return this->Makefile;};
  96. #define DECLARE_TARGET_POLICY(POLICY) \
  97. cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
  98. { return this->PolicyStatus ## POLICY; }
  99. CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
  100. #undef DECLARE_TARGET_POLICY
  101. /**
  102. * Get the list of the custom commands for this target
  103. */
  104. std::vector<cmCustomCommand> const &GetPreBuildCommands() const
  105. {return this->PreBuildCommands;}
  106. std::vector<cmCustomCommand> const &GetPreLinkCommands() const
  107. {return this->PreLinkCommands;}
  108. std::vector<cmCustomCommand> const &GetPostBuildCommands() const
  109. {return this->PostBuildCommands;}
  110. void AddPreBuildCommand(cmCustomCommand const &cmd)
  111. {this->PreBuildCommands.push_back(cmd);}
  112. void AddPreLinkCommand(cmCustomCommand const &cmd)
  113. {this->PreLinkCommands.push_back(cmd);}
  114. void AddPostBuildCommand(cmCustomCommand const &cmd)
  115. {this->PostBuildCommands.push_back(cmd);}
  116. /**
  117. * Get the list of the source files used by this target
  118. */
  119. void GetSourceFiles(std::vector<std::string> &files,
  120. const std::string& config) const;
  121. void GetSourceFiles(std::vector<cmSourceFile*> &files,
  122. const std::string& config) const;
  123. bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
  124. /**
  125. * Add sources to the target.
  126. */
  127. void AddSources(std::vector<std::string> const& srcs);
  128. cmSourceFile* AddSourceCMP0049(const std::string& src);
  129. cmSourceFile* AddSource(const std::string& src);
  130. enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
  131. //* how we identify a library, by name and type
  132. typedef std::pair<std::string, LinkLibraryType> LibraryID;
  133. typedef std::vector<LibraryID > LinkLibraryVectorType;
  134. const LinkLibraryVectorType &GetLinkLibraries() const {
  135. return this->LinkLibraries;}
  136. const LinkLibraryVectorType &GetOriginalLinkLibraries() const
  137. {return this->OriginalLinkLibraries;}
  138. void GetDirectLinkLibraries(const std::string& config,
  139. std::vector<std::string> &,
  140. cmTarget const* head) const;
  141. void GetInterfaceLinkLibraries(const std::string& config,
  142. std::vector<std::string> &,
  143. cmTarget const* head) const;
  144. /** Compute the link type to use for the given configuration. */
  145. LinkLibraryType ComputeLinkType(const std::string& config) const;
  146. /**
  147. * Clear the dependency information recorded for this target, if any.
  148. */
  149. void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
  150. // Check to see if a library is a framework and treat it different on Mac
  151. bool NameResolvesToFramework(const std::string& libname) const;
  152. void AddLinkLibrary(cmMakefile& mf,
  153. const std::string& target, const std::string& lib,
  154. LinkLibraryType llt);
  155. enum TLLSignature {
  156. KeywordTLLSignature,
  157. PlainTLLSignature
  158. };
  159. bool PushTLLCommandTrace(TLLSignature signature);
  160. void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
  161. void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
  162. const LinkLibraryVectorType& libs );
  163. const std::vector<std::string>& GetLinkDirectories() const;
  164. void AddLinkDirectory(const std::string& d);
  165. /**
  166. * Set the path where this target should be installed. This is relative to
  167. * INSTALL_PREFIX
  168. */
  169. std::string GetInstallPath() const {return this->InstallPath;}
  170. void SetInstallPath(const char *name) {this->InstallPath = name;}
  171. /**
  172. * Set the path where this target (if it has a runtime part) should be
  173. * installed. This is relative to INSTALL_PREFIX
  174. */
  175. std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;}
  176. void SetRuntimeInstallPath(const char *name) {
  177. this->RuntimeInstallPath = name; }
  178. /**
  179. * Get/Set whether there is an install rule for this target.
  180. */
  181. bool GetHaveInstallRule() const { return this->HaveInstallRule; }
  182. void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; }
  183. /** Add a utility on which this project depends. A utility is an executable
  184. * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
  185. * commands. It is not a full path nor does it have an extension.
  186. */
  187. void AddUtility(const std::string& u, cmMakefile *makefile = 0);
  188. ///! Get the utilities used by this target
  189. std::set<std::string>const& GetUtilities() const { return this->Utilities; }
  190. cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
  191. /** Finalize the target at the end of the Configure step. */
  192. void FinishConfigure();
  193. ///! Set/Get a property of this target file
  194. void SetProperty(const std::string& prop, const char *value);
  195. void AppendProperty(const std::string& prop, const char* value,
  196. bool asString=false);
  197. const char *GetProperty(const std::string& prop) const;
  198. const char *GetProperty(const std::string& prop,
  199. cmProperty::ScopeType scope) const;
  200. bool GetPropertyAsBool(const std::string& prop) const;
  201. void CheckProperty(const std::string& prop, cmMakefile* context) const;
  202. const char* GetFeature(const std::string& feature,
  203. const std::string& config) const;
  204. bool IsImported() const {return this->IsImportedTarget;}
  205. /** The link interface specifies transitive library dependencies and
  206. other information needed by targets that link to this target. */
  207. struct LinkInterface
  208. {
  209. // Languages whose runtime libraries must be linked.
  210. std::vector<std::string> Languages;
  211. // Libraries listed in the interface.
  212. std::vector<std::string> Libraries;
  213. // Shared library dependencies needed for linking on some platforms.
  214. std::vector<std::string> SharedDeps;
  215. // Number of repetitions of a strongly connected component of two
  216. // or more static libraries.
  217. int Multiplicity;
  218. // Libraries listed for other configurations.
  219. // Needed only for OLD behavior of CMP0003.
  220. std::vector<std::string> WrongConfigLibraries;
  221. bool ImplementationIsInterface;
  222. LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
  223. };
  224. /** Get the link interface for the given configuration. Returns 0
  225. if the target cannot be linked. */
  226. LinkInterface const* GetLinkInterface(const std::string& config,
  227. cmTarget const* headTarget) const;
  228. LinkInterface const* GetLinkInterfaceLibraries(const std::string& config,
  229. cmTarget const* headTarget) const;
  230. void GetTransitivePropertyTargets(const std::string& config,
  231. cmTarget const* headTarget,
  232. std::vector<cmTarget*> &libs) const;
  233. void GetTransitiveTargetClosure(const std::string& config,
  234. cmTarget const* headTarget,
  235. std::vector<cmTarget*> &libs) const;
  236. /** The link implementation specifies the direct library
  237. dependencies needed by the object files of the target. */
  238. struct LinkImplementation
  239. {
  240. // Languages whose runtime libraries must be linked.
  241. std::vector<std::string> Languages;
  242. // Libraries linked directly in this configuration.
  243. std::vector<std::string> Libraries;
  244. // Libraries linked directly in other configurations.
  245. // Needed only for OLD behavior of CMP0003.
  246. std::vector<std::string> WrongConfigLibraries;
  247. };
  248. LinkImplementation const* GetLinkImplementation(const std::string& config,
  249. cmTarget const* head) const;
  250. LinkImplementation const* GetLinkImplementationLibraries(
  251. const std::string& config,
  252. cmTarget const* head) const;
  253. /** Link information from the transitive closure of the link
  254. implementation and the interfaces of its dependencies. */
  255. struct LinkClosure
  256. {
  257. // The preferred linker language.
  258. std::string LinkerLanguage;
  259. // Languages whose runtime libraries must be linked.
  260. std::vector<std::string> Languages;
  261. };
  262. LinkClosure const* GetLinkClosure(const std::string& config,
  263. cmTarget const* head) const;
  264. /** Strip off leading and trailing whitespace from an item named in
  265. the link dependencies of this target. */
  266. std::string CheckCMP0004(std::string const& item) const;
  267. /** Get the directory in which this target will be built. If the
  268. configuration name is given then the generator will add its
  269. subdirectory for that configuration. Otherwise just the canonical
  270. output directory is given. */
  271. std::string GetDirectory(const std::string& config = "",
  272. bool implib = false) const;
  273. /** Get the directory in which this targets .pdb files will be placed.
  274. If the configuration name is given then the generator will add its
  275. subdirectory for that configuration. Otherwise just the canonical
  276. pdb output directory is given. */
  277. std::string GetPDBDirectory(const std::string& config) const;
  278. /** Get the directory in which to place the target compiler .pdb file.
  279. If the configuration name is given then the generator will add its
  280. subdirectory for that configuration. Otherwise just the canonical
  281. compiler pdb output directory is given. */
  282. std::string GetCompilePDBDirectory(const std::string& config = "") const;
  283. /** Get the location of the target in the build tree for the given
  284. configuration. */
  285. const char* GetLocation(const std::string& config) const;
  286. /** Get the location of the target in the build tree with a placeholder
  287. referencing the configuration in the native build system. This
  288. location is suitable for use as the LOCATION target property. */
  289. const char* GetLocationForBuild() const;
  290. /** Get the target major and minor version numbers interpreted from
  291. the VERSION property. Version 0 is returned if the property is
  292. not set or cannot be parsed. */
  293. void GetTargetVersion(int& major, int& minor) const;
  294. /** Get the target major, minor, and patch version numbers
  295. interpreted from the VERSION or SOVERSION property. Version 0
  296. is returned if the property is not set or cannot be parsed. */
  297. void
  298. GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
  299. ///! Return the preferred linker language for this target
  300. std::string GetLinkerLanguage(const std::string& config = "",
  301. cmTarget const* head = 0) const;
  302. /** Get the full name of the target according to the settings in its
  303. makefile. */
  304. std::string GetFullName(const std::string& config="",
  305. bool implib = false) const;
  306. void GetFullNameComponents(std::string& prefix,
  307. std::string& base, std::string& suffix,
  308. const std::string& config="",
  309. bool implib = false) const;
  310. /** Get the name of the pdb file for the target. */
  311. std::string GetPDBName(const std::string& config) const;
  312. /** Get the name of the compiler pdb file for the target. */
  313. std::string GetCompilePDBName(const std::string& config="") const;
  314. /** Get the path for the MSVC /Fd option for this target. */
  315. std::string GetCompilePDBPath(const std::string& config="") const;
  316. /** Whether this library has soname enabled and platform supports it. */
  317. bool HasSOName(const std::string& config) const;
  318. /** Get the soname of the target. Allowed only for a shared library. */
  319. std::string GetSOName(const std::string& config) const;
  320. /** Whether this library has \@rpath and platform supports it. */
  321. bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
  322. /** Whether this library defaults to \@rpath. */
  323. bool MacOSXRpathInstallNameDirDefault() const;
  324. /** Test for special case of a third-party shared library that has
  325. no soname at all. */
  326. bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
  327. /** Get the full path to the target according to the settings in its
  328. makefile and the configuration type. */
  329. std::string GetFullPath(const std::string& config="", bool implib = false,
  330. bool realname = false) const;
  331. /** Get the names of the library needed to generate a build rule
  332. that takes into account shared library version numbers. This
  333. should be called only on a library target. */
  334. void GetLibraryNames(std::string& name, std::string& soName,
  335. std::string& realName, std::string& impName,
  336. std::string& pdbName, const std::string& config) const;
  337. /** Get the names of the executable needed to generate a build rule
  338. that takes into account executable version numbers. This should
  339. be called only on an executable target. */
  340. void GetExecutableNames(std::string& name, std::string& realName,
  341. std::string& impName,
  342. std::string& pdbName,
  343. const std::string& config) const;
  344. /** Does this target have a GNU implib to convert to MS format? */
  345. bool HasImplibGNUtoMS() const;
  346. /** Convert the given GNU import library name (.dll.a) to a name with a new
  347. extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */
  348. bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
  349. const char* newExt = 0) const;
  350. /**
  351. * Compute whether this target must be relinked before installing.
  352. */
  353. bool NeedRelinkBeforeInstall(const std::string& config) const;
  354. bool HaveBuildTreeRPATH(const std::string& config) const;
  355. bool HaveInstallTreeRPATH() const;
  356. /** Return true if builtin chrpath will work for this target */
  357. bool IsChrpathUsed(const std::string& config) const;
  358. /** Return the install name directory for the target in the
  359. * build tree. For example: "\@rpath/", "\@loader_path/",
  360. * or "/full/path/to/library". */
  361. std::string GetInstallNameDirForBuildTree(const std::string& config) const;
  362. /** Return the install name directory for the target in the
  363. * install tree. For example: "\@rpath/" or "\@loader_path/". */
  364. std::string GetInstallNameDirForInstallTree() const;
  365. cmComputeLinkInformation* GetLinkInformation(const std::string& config,
  366. cmTarget const* head = 0) const;
  367. // Get the properties
  368. cmPropertyMap &GetProperties() const { return this->Properties; };
  369. bool GetMappedConfig(std::string const& desired_config,
  370. const char** loc,
  371. const char** imp,
  372. std::string& suffix) const;
  373. // Define the properties
  374. static void DefineProperties(cmake *cm);
  375. /** Get the macro to define when building sources in this target.
  376. If no macro should be defined null is returned. */
  377. const char* GetExportMacro() const;
  378. void GetCompileDefinitions(std::vector<std::string> &result,
  379. const std::string& config) const;
  380. // Compute the set of languages compiled by the target. This is
  381. // computed every time it is called because the languages can change
  382. // when source file properties are changed and we do not have enough
  383. // information to forward these property changes to the targets
  384. // until we have per-target object file properties.
  385. void GetLanguages(std::set<std::string>& languages,
  386. const std::string& config) const;
  387. /** Return whether this target is an executable with symbol exports
  388. enabled. */
  389. bool IsExecutableWithExports() const;
  390. /** Return whether this target may be used to link another target. */
  391. bool IsLinkable() const;
  392. /** Return whether or not the target is for a DLL platform. */
  393. bool IsDLLPlatform() const { return this->DLLPlatform; }
  394. /** Return whether or not the target has a DLL import library. */
  395. bool HasImportLibrary() const;
  396. /** Return whether this target is a shared library Framework on
  397. Apple. */
  398. bool IsFrameworkOnApple() const;
  399. /** Return whether this target is a CFBundle (plugin) on Apple. */
  400. bool IsCFBundleOnApple() const;
  401. /** Return whether this target is an executable Bundle on Apple. */
  402. bool IsAppBundleOnApple() const;
  403. /** Return whether this target is an executable Bundle, a framework
  404. or CFBundle on Apple. */
  405. bool IsBundleOnApple() const;
  406. /** Return the framework version string. Undefined if
  407. IsFrameworkOnApple returns false. */
  408. std::string GetFrameworkVersion() const;
  409. /** Get a backtrace from the creation of the target. */
  410. cmListFileBacktrace const& GetBacktrace() const;
  411. /** Get a build-tree directory in which to place target support files. */
  412. std::string GetSupportDirectory() const;
  413. /** Return whether this target uses the default value for its output
  414. directory. */
  415. bool UsesDefaultOutputDir(const std::string& config, bool implib) const;
  416. /** @return the mac content directory for this target. */
  417. std::string GetMacContentDirectory(const std::string& config,
  418. bool implib) const;
  419. /** @return whether this target have a well defined output file name. */
  420. bool HaveWellDefinedOutputFiles() const;
  421. /** @return the Mac framework directory without the base. */
  422. std::string GetFrameworkDirectory(const std::string& config,
  423. bool rootDir) const;
  424. /** @return the Mac CFBundle directory without the base */
  425. std::string GetCFBundleDirectory(const std::string& config,
  426. bool contentOnly) const;
  427. /** @return the Mac App directory without the base */
  428. std::string GetAppBundleDirectory(const std::string& config,
  429. bool contentOnly) const;
  430. std::vector<std::string> GetIncludeDirectories(
  431. const std::string& config) const;
  432. void InsertInclude(const cmValueWithOrigin &entry,
  433. bool before = false);
  434. void InsertCompileOption(const cmValueWithOrigin &entry,
  435. bool before = false);
  436. void InsertCompileDefinition(const cmValueWithOrigin &entry);
  437. void AppendBuildInterfaceIncludes();
  438. void GetCompileOptions(std::vector<std::string> &result,
  439. const std::string& config) const;
  440. void GetAutoUicOptions(std::vector<std::string> &result,
  441. const std::string& config) const;
  442. bool IsNullImpliedByLinkLibraries(const std::string &p) const;
  443. bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
  444. const std::string& config) const;
  445. bool IsLinkInterfaceDependentStringProperty(const std::string &p,
  446. const std::string& config) const;
  447. bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
  448. const std::string& config) const;
  449. bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
  450. const std::string& config) const;
  451. bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
  452. const std::string& config) const;
  453. const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
  454. const std::string& config) const;
  455. const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
  456. const std::string& config) const;
  457. const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
  458. const std::string& config) const;
  459. std::string GetDebugGeneratorExpressions(const std::string &value,
  460. cmTarget::LinkLibraryType llt) const;
  461. void AddSystemIncludeDirectories(const std::set<std::string> &incs);
  462. void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
  463. std::set<std::string> const & GetSystemIncludeDirectories() const
  464. { return this->SystemIncludeDirectories; }
  465. bool LinkLanguagePropagatesToDependents() const
  466. { return this->TargetTypeValue == STATIC_LIBRARY; }
  467. void ReportPropertyOrigin(const std::string &p,
  468. const std::string &result,
  469. const std::string &report,
  470. const std::string &compatibilityType) const;
  471. private:
  472. bool HandleLocationPropertyPolicy() const;
  473. // The set of include directories that are marked as system include
  474. // directories.
  475. std::set<std::string> SystemIncludeDirectories;
  476. std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;
  477. /**
  478. * A list of direct dependencies. Use in conjunction with DependencyMap.
  479. */
  480. typedef std::vector< LibraryID > DependencyList;
  481. /**
  482. * This map holds the dependency graph. map[x] returns a set of
  483. * direct dependencies of x. Note that the direct depenencies are
  484. * ordered. This is necessary to handle direct dependencies that
  485. * themselves have no dependency information.
  486. */
  487. typedef std::map< LibraryID, DependencyList > DependencyMap;
  488. /**
  489. * Inserts \a dep at the end of the dependency list of \a lib.
  490. */
  491. void InsertDependency( DependencyMap& depMap,
  492. const LibraryID& lib,
  493. const LibraryID& dep);
  494. /*
  495. * Deletes \a dep from the dependency list of \a lib.
  496. */
  497. void DeleteDependency( DependencyMap& depMap,
  498. const LibraryID& lib,
  499. const LibraryID& dep);
  500. /**
  501. * Emits the library \a lib and all its dependencies into link_line.
  502. * \a emitted keeps track of the libraries that have been emitted to
  503. * avoid duplicates--it is more efficient than searching
  504. * link_line. \a visited is used detect cycles. Note that \a
  505. * link_line is in reverse order, in that the dependencies of a
  506. * library are listed before the library itself.
  507. */
  508. void Emit( const LibraryID lib,
  509. const DependencyMap& dep_map,
  510. std::set<LibraryID>& emitted,
  511. std::set<LibraryID>& visited,
  512. DependencyList& link_line);
  513. /**
  514. * Finds the dependencies for \a lib and inserts them into \a
  515. * dep_map.
  516. */
  517. void GatherDependencies( const cmMakefile& mf,
  518. const LibraryID& lib,
  519. DependencyMap& dep_map);
  520. void AnalyzeLibDependencies( const cmMakefile& mf );
  521. const char* GetSuffixVariableInternal(bool implib) const;
  522. const char* GetPrefixVariableInternal(bool implib) const;
  523. std::string GetFullNameInternal(const std::string& config,
  524. bool implib) const;
  525. void GetFullNameInternal(const std::string& config, bool implib,
  526. std::string& outPrefix, std::string& outBase,
  527. std::string& outSuffix) const;
  528. // Use a makefile variable to set a default for the given property.
  529. // If the variable is not defined use the given default instead.
  530. void SetPropertyDefault(const std::string& property,
  531. const char* default_value);
  532. // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
  533. const char* GetOutputTargetType(bool implib) const;
  534. // Get the target base name.
  535. std::string GetOutputName(const std::string& config, bool implib) const;
  536. std::string GetFullNameImported(const std::string& config,
  537. bool implib) const;
  538. std::string ImportedGetFullPath(const std::string& config,
  539. bool implib) const;
  540. std::string NormalGetFullPath(const std::string& config, bool implib,
  541. bool realname) const;
  542. /** Get the real name of the target. Allowed only for non-imported
  543. targets. When a library or executable file is versioned this is
  544. the full versioned name. If the target is not versioned this is
  545. the same as GetFullName. */
  546. std::string NormalGetRealName(const std::string& config) const;
  547. /** Append to @a base the mac content directory and return it. */
  548. std::string BuildMacContentDirectory(const std::string& base,
  549. const std::string& config,
  550. bool contentOnly) const;
  551. private:
  552. std::string Name;
  553. std::vector<cmCustomCommand> PreBuildCommands;
  554. std::vector<cmCustomCommand> PreLinkCommands;
  555. std::vector<cmCustomCommand> PostBuildCommands;
  556. TargetType TargetTypeValue;
  557. LinkLibraryVectorType LinkLibraries;
  558. LinkLibraryVectorType PrevLinkedLibraries;
  559. bool LinkLibrariesAnalyzed;
  560. std::vector<std::string> LinkDirectories;
  561. std::set<std::string> LinkDirectoriesEmmitted;
  562. bool HaveInstallRule;
  563. std::string InstallPath;
  564. std::string RuntimeInstallPath;
  565. mutable std::string ExportMacro;
  566. std::set<std::string> Utilities;
  567. std::map<std::string, cmListFileBacktrace> UtilityBacktraces;
  568. bool RecordDependencies;
  569. mutable cmPropertyMap Properties;
  570. LinkLibraryVectorType OriginalLinkLibraries;
  571. bool DLLPlatform;
  572. bool IsApple;
  573. bool IsImportedTarget;
  574. mutable bool DebugIncludesDone;
  575. mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
  576. mutable bool DebugCompileOptionsDone;
  577. mutable bool DebugCompileDefinitionsDone;
  578. mutable std::set<std::string> LinkImplicitNullProperties;
  579. bool BuildInterfaceIncludesAppended;
  580. // Cache target output paths for each configuration.
  581. struct OutputInfo;
  582. OutputInfo const* GetOutputInfo(const std::string& config) const;
  583. bool
  584. ComputeOutputDir(const std::string& config,
  585. bool implib, std::string& out) const;
  586. bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
  587. std::string& out) const;
  588. // Cache import information from properties for each configuration.
  589. struct ImportInfo;
  590. ImportInfo const* GetImportInfo(const std::string& config,
  591. cmTarget const* workingTarget) const;
  592. void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
  593. cmTarget const* head) const;
  594. // Cache target compile paths for each configuration.
  595. struct CompileInfo;
  596. CompileInfo const* GetCompileInfo(const std::string& config) const;
  597. mutable cmTargetLinkInformationMap LinkInformation;
  598. void CheckPropertyCompatibility(cmComputeLinkInformation *info,
  599. const std::string& config) const;
  600. const char* ComputeLinkInterfaceLibraries(const std::string& config,
  601. LinkInterface& iface,
  602. cmTarget const* head,
  603. bool &exists) const;
  604. void ComputeLinkImplementation(const std::string& config,
  605. LinkImplementation& impl,
  606. cmTarget const* head) const;
  607. void ComputeLinkImplementationLanguages(const std::string& config,
  608. LinkImplementation& impl) const;
  609. void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
  610. cmTarget const* head) const;
  611. void ClearLinkMaps();
  612. void MaybeInvalidatePropertyCache(const std::string& prop);
  613. void ProcessSourceExpression(std::string const& expr);
  614. // The cmMakefile instance that owns this target. This should
  615. // always be set.
  616. cmMakefile* Makefile;
  617. // Policy status recorded when target was created.
  618. #define TARGET_POLICY_MEMBER(POLICY) \
  619. cmPolicies::PolicyStatus PolicyStatus ## POLICY;
  620. CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER)
  621. #undef TARGET_POLICY_MEMBER
  622. // Internal representation details.
  623. friend class cmTargetInternals;
  624. friend class cmGeneratorTarget;
  625. friend class cmTargetTraceDependencies;
  626. cmTargetInternalPointer Internal;
  627. void ComputeVersionedName(std::string& vName,
  628. std::string const& prefix,
  629. std::string const& base,
  630. std::string const& suffix,
  631. std::string const& name,
  632. const char* version) const;
  633. };
  634. typedef std::map<std::string,cmTarget> cmTargets;
  635. class cmTargetSet: public std::set<std::string> {};
  636. class cmTargetManifest: public std::map<std::string, cmTargetSet> {};
  637. #endif