cmTarget.h 31 KB

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