cmTarget.h 29.4 KB
Newer Older
1
2
3
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4

5
6
  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.
7

8
9
10
11
  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
12
13
14
15
#ifndef cmTarget_h
#define cmTarget_h

#include "cmCustomCommand.h"
16
#include "cmPropertyMap.h"
17
#include "cmPolicies.h"
18
#include "cmListFileCache.h"
19

20
21
#include <cmsys/auto_ptr.hxx>

22
23
24
25
26
27
#define CM_FOR_EACH_TARGET_POLICY(F) \
  F(CMP0003) \
  F(CMP0004) \
  F(CMP0008) \
  F(CMP0020) \
  F(CMP0021) \
28
  F(CMP0022) \
29
30
  F(CMP0041) \
  F(CMP0042)
31

32
class cmake;
33
class cmMakefile;
Ken Martin's avatar
Ken Martin committed
34
class cmSourceFile;
35
class cmGlobalGenerator;
36
class cmComputeLinkInformation;
37
class cmListFileBacktrace;
38
class cmTarget;
39
40
class cmGeneratorTarget;
class cmTargetTraceDependencies;
41

42
struct cmTargetLinkInformationMap:
43
44
  public std::map<std::pair<cmTarget const* , std::string>,
                  cmComputeLinkInformation*>
45
{
46
  typedef std::map<std::pair<cmTarget const* , std::string>,
47
                   cmComputeLinkInformation*> derived;
48
49
50
51
52
  cmTargetLinkInformationMap() {}
  cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r);
  ~cmTargetLinkInformationMap();
};

53
54
55
56
57
58
59
60
61
class cmTargetInternals;
class cmTargetInternalPointer
{
public:
  cmTargetInternalPointer();
  cmTargetInternalPointer(cmTargetInternalPointer const& r);
  ~cmTargetInternalPointer();
  cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r);
  cmTargetInternals* operator->() const { return this->Pointer; }
62
  cmTargetInternals* Get() const { return this->Pointer; }
63
64
65
66
private:
  cmTargetInternals* Pointer;
};

67
68
69
/** \class cmTarget
 * \brief Represent a library or executable target loaded from a makefile.
 *
70
 * cmTarget represents a target loaded from
71
72
73
74
75
 * a makefile.
 */
class cmTarget
{
public:
76
  cmTarget();
77
  enum TargetType { EXECUTABLE, STATIC_LIBRARY,
Brad King's avatar
Brad King committed
78
79
                    SHARED_LIBRARY, MODULE_LIBRARY,
                    OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET,
80
                    INTERFACE_LIBRARY,
81
                    UNKNOWN_LIBRARY};
Nicolas Despres's avatar
Nicolas Despres committed
82
  static const char* GetTargetTypeName(TargetType targetType);
83
84
  enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };

85
  /**
86
   * Return the type of target.
87
   */
Alexander Neundorf's avatar
   
Alexander Neundorf committed
88
  TargetType GetType() const
89
    {
90
    return this->TargetTypeValue;
91
    }
92

93
94
95
  /**
   * Set the target type
   */
96
97
  void SetType(TargetType f, const char* name);

Alexander Neundorf's avatar
   
Alexander Neundorf committed
98
  void MarkAsImported();
99

100
  ///! Set/Get the name of the target
Alexander Neundorf's avatar
   
Alexander Neundorf committed
101
  const char* GetName() const {return this->Name.c_str();}
102
  const char* GetExportName() const;
103

104
  ///! Set the cmMakefile that owns this target
105
  void SetMakefile(cmMakefile *mf);
106
  cmMakefile *GetMakefile() const { return this->Makefile;};
107

108
109
110
#define DECLARE_TARGET_POLICY(POLICY) \
  cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
    { return this->PolicyStatus ## POLICY; }
111

112
  CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
113

114
#undef DECLARE_TARGET_POLICY
115

116
117
118
  /**
   * Get the list of the custom commands for this target
   */
119
  std::vector<cmCustomCommand> const &GetPreBuildCommands() const
Ken Martin's avatar
Ken Martin committed
120
    {return this->PreBuildCommands;}
121
  std::vector<cmCustomCommand> const &GetPreLinkCommands() const
Ken Martin's avatar
Ken Martin committed
122
    {return this->PreLinkCommands;}
123
  std::vector<cmCustomCommand> const &GetPostBuildCommands() const
Ken Martin's avatar
Ken Martin committed
124
    {return this->PostBuildCommands;}
125
126
127
128
129
130
  void AddPreBuildCommand(cmCustomCommand const &cmd)
    {this->PreBuildCommands.push_back(cmd);}
  void AddPreLinkCommand(cmCustomCommand const &cmd)
    {this->PreLinkCommands.push_back(cmd);}
  void AddPostBuildCommand(cmCustomCommand const &cmd)
    {this->PostBuildCommands.push_back(cmd);}
131

132
133
134
  /**
   * Get the list of the source files used by this target
   */
135
  void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
136
  void AddSourceFile(cmSourceFile* sf);
137
138
139
140
  std::vector<std::string> const& GetObjectLibraries() const
    {
    return this->ObjectLibraries;
    }
141

142
143
144
145
  /**
   * Flags for a given source file as used in this target. Typically assigned
   * via SET_TARGET_PROPERTIES when the property is a list of source files.
   */
146
147
148
149
150
151
152
153
154
  enum SourceFileType
  {
    SourceFileTypeNormal,
    SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
    SourceFileTypePublicHeader,  // is in "PUBLIC_HEADER" target property
    SourceFileTypeResource,      // is in "RESOURCE" target property *or*
                                 // has MACOSX_PACKAGE_LOCATION=="Resources"
    SourceFileTypeMacContent     // has MACOSX_PACKAGE_LOCATION!="Resources"
  };
155
156
  struct SourceFileFlags
  {
157
158
159
160
161
    SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
    SourceFileFlags(SourceFileFlags const& r):
      Type(r.Type), MacFolder(r.MacFolder) {}
    SourceFileType Type;
    const char* MacFolder; // location inside Mac content folders
162
163
164
165
166
  };

  /**
   * Get the flags for a given source file as used in this target
   */
167
168
  struct SourceFileFlags
  GetTargetSourceFileFlags(const cmSourceFile* sf) const;
169

170
171
172
173
174
175
  /**
   * Add sources to the target.
   */
  void AddSources(std::vector<std::string> const& srcs);
  cmSourceFile* AddSource(const char* src);

176
  enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
177

178
179
180
181
  //* how we identify a library, by name and type
  typedef std::pair<cmStdString, LinkLibraryType> LibraryID;

  typedef std::vector<LibraryID > LinkLibraryVectorType;
Alexander Neundorf's avatar
   
Alexander Neundorf committed
182
  const LinkLibraryVectorType &GetLinkLibraries() const {
183
  return this->LinkLibraries;}
Alexander Neundorf's avatar
   
Alexander Neundorf committed
184
  const LinkLibraryVectorType &GetOriginalLinkLibraries() const
Ken Martin's avatar
Ken Martin committed
185
    {return this->OriginalLinkLibraries;}
186
187
  void GetDirectLinkLibraries(const char *config,
                              std::vector<std::string> &,
188
                              cmTarget const* head) const;
189
190
  void GetInterfaceLinkLibraries(const char *config,
                              std::vector<std::string> &,
191
                              cmTarget const* head) const;
192

193
  /** Compute the link type to use for the given configuration.  */
194
  LinkLibraryType ComputeLinkType(const char* config) const;
195

196
197
198
199
200
  /**
   * Clear the dependency information recorded for this target, if any.
   */
  void ClearDependencyInformation(cmMakefile& mf, const char* target);

201
  // Check to see if a library is a framework and treat it different on Mac
202
  bool NameResolvesToFramework(const std::string& libname) const;
203
  void AddLinkLibrary(cmMakefile& mf,
204
                      const char *target, const char* lib,
205
                      LinkLibraryType llt);
206
207
208
209
210
211
  enum TLLSignature {
    KeywordTLLSignature,
    PlainTLLSignature
  };
  bool PushTLLCommandTrace(TLLSignature signature);
  void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
212

213
  void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
Ken Martin's avatar
Ken Martin committed
214
                           const LinkLibraryVectorType& libs );
215

216
  const std::vector<std::string>& GetLinkDirectories() const;
217

218
  void AddLinkDirectory(const char* d);
Ken Martin's avatar
Ken Martin committed
219
220
221
222
223

  /**
   * Set the path where this target should be installed. This is relative to
   * INSTALL_PREFIX
   */
224
  std::string GetInstallPath() const {return this->InstallPath;}
Ken Martin's avatar
Ken Martin committed
225
  void SetInstallPath(const char *name) {this->InstallPath = name;}
226

227
228
229
230
  /**
   * Set the path where this target (if it has a runtime part) should be
   * installed. This is relative to INSTALL_PREFIX
   */
231
  std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;}
Ken Martin's avatar
Ken Martin committed
232
  void SetRuntimeInstallPath(const char *name) {
233
    this->RuntimeInstallPath = name; }
234
235
236
237

  /**
   * Get/Set whether there is an install rule for this target.
   */
238
  bool GetHaveInstallRule() const { return this->HaveInstallRule; }
Ken Martin's avatar
Ken Martin committed
239
  void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; }
240

241
242
  /** Add a utility on which this project depends. A utility is an executable
   * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
243
   * commands. It is not a full path nor does it have an extension.
244
   */
245
  void AddUtility(const char* u, cmMakefile *makefile = 0);
246
  ///! Get the utilities used by this target
247
  std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
248
  cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
249

250
251
  /** Finalize the target at the end of the Configure step.  */
  void FinishConfigure();
252

Bill Hoffman's avatar
Bill Hoffman committed
253
254
  ///! Set/Get a property of this target file
  void SetProperty(const char *prop, const char *value);
255
  void AppendProperty(const char* prop, const char* value,bool asString=false);
256
257
258
  const char *GetProperty(const char *prop) const;
  const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
  bool GetPropertyAsBool(const char *prop) const;
259
  void CheckProperty(const char* prop, cmMakefile* context) const;
260

261
  const char* GetFeature(const char* feature, const char* config) const;
262

Alexander Neundorf's avatar
   
Alexander Neundorf committed
263
  bool IsImported() const {return this->IsImportedTarget;}
Bill Hoffman's avatar
Bill Hoffman committed
264

265
266
  /** The link interface specifies transitive library dependencies and
      other information needed by targets that link to this target.  */
267
268
  struct LinkInterface
  {
269
270
271
    // Languages whose runtime libraries must be linked.
    std::vector<std::string> Languages;

272
273
274
275
276
277
    // Libraries listed in the interface.
    std::vector<std::string> Libraries;

    // Shared library dependencies needed for linking on some platforms.
    std::vector<std::string> SharedDeps;

278
279
280
281
    // Number of repetitions of a strongly connected component of two
    // or more static libraries.
    int Multiplicity;

282
283
284
    // Libraries listed for other configurations.
    // Needed only for OLD behavior of CMP0003.
    std::vector<std::string> WrongConfigLibraries;
285

286
287
288
    bool ImplementationIsInterface;

    LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
289
290
291
292
  };

  /** Get the link interface for the given configuration.  Returns 0
      if the target cannot be linked.  */
293
  LinkInterface const* GetLinkInterface(const char* config,
294
                                        cmTarget const* headTarget) const;
295
  void GetTransitivePropertyLinkLibraries(const char* config,
296
297
                                        cmTarget const* headTarget,
                                        std::vector<std::string> &libs) const;
298

299
300
301
302
  /** The link implementation specifies the direct library
      dependencies needed by the object files of the target.  */
  struct LinkImplementation
  {
303
304
305
    // Languages whose runtime libraries must be linked.
    std::vector<std::string> Languages;

306
307
308
309
310
311
312
    // Libraries linked directly in this configuration.
    std::vector<std::string> Libraries;

    // Libraries linked directly in other configurations.
    // Needed only for OLD behavior of CMP0003.
    std::vector<std::string> WrongConfigLibraries;
  };
313
  LinkImplementation const* GetLinkImplementation(const char* config,
314
                                                  cmTarget const* head) const;
315

316
317
318
319
320
321
322
323
324
325
  /** Link information from the transitive closure of the link
      implementation and the interfaces of its dependencies.  */
  struct LinkClosure
  {
    // The preferred linker language.
    std::string LinkerLanguage;

    // Languages whose runtime libraries must be linked.
    std::vector<std::string> Languages;
  };
326
327
  LinkClosure const* GetLinkClosure(const char* config,
                                    cmTarget const* head) const;
328

329
330
  /** Strip off leading and trailing whitespace from an item named in
      the link dependencies of this target.  */
331
  std::string CheckCMP0004(std::string const& item) const;
332

333
334
335
336
  /** Get the directory in which this target will be built.  If the
      configuration name is given then the generator will add its
      subdirectory for that configuration.  Otherwise just the canonical
      output directory is given.  */
337
  std::string GetDirectory(const char* config = 0, bool implib = false) const;
338

339
340
341
342
  /** Get the directory in which this targets .pdb files will be placed.
      If the configuration name is given then the generator will add its
      subdirectory for that configuration.  Otherwise just the canonical
      pdb output directory is given.  */
343
  std::string GetPDBDirectory(const char* config = 0) const;
344

345
346
347
  /** Get the location of the target in the build tree for the given
      configuration.  This location is suitable for use as the LOCATION
      target property.  */
348
  const char* GetLocation(const char* config) const;
349

350
351
352
  /** Get the target major and minor version numbers interpreted from
      the VERSION property.  Version 0 is returned if the property is
      not set or cannot be parsed.  */
353
  void GetTargetVersion(int& major, int& minor) const;
354

355
356
357
  /** Get the target major, minor, and patch version numbers
      interpreted from the VERSION or SOVERSION property.  Version 0
      is returned if the property is not set or cannot be parsed.  */
358
359
  void
  GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
360

361
362
363
364
365
  /**
   * Make sure the full path to all source files is known.
   */
  bool FindSourceFiles();

366
  ///! Return the preferred linker language for this target
367
368
  const char* GetLinkerLanguage(const char* config = 0,
                                cmTarget const* head = 0) const;
369

370
371
  /** Get the full name of the target according to the settings in its
      makefile.  */
372
  std::string GetFullName(const char* config=0, bool implib = false) const;
373
374
  void GetFullNameComponents(std::string& prefix,
                             std::string& base, std::string& suffix,
375
                             const char* config=0, bool implib = false) const;
376
377

  /** Get the name of the pdb file for the target.  */
378
  std::string GetPDBName(const char* config=0) const;
379

380
  /** Whether this library has soname enabled and platform supports it.  */
381
  bool HasSOName(const char* config) const;
382

383
  /** Get the soname of the target.  Allowed only for a shared library.  */
384
  std::string GetSOName(const char* config) const;
385

386
  /** Whether this library has \@rpath and platform supports it.  */
387
388
389
390
  bool HasMacOSXRpathInstallNameDir(const char* config) const;

  /** Whether this library defaults to \@rpath.  */
  bool MacOSXRpathInstallNameDirDefault() const;
391

392
393
  /** Test for special case of a third-party shared library that has
      no soname at all.  */
394
  bool IsImportedSharedLibWithoutSOName(const char* config) const;
395

396
397
  /** Get the full path to the target according to the settings in its
      makefile and the configuration type.  */
398
  std::string GetFullPath(const char* config=0, bool implib = false,
399
                          bool realname = false) const;
400
401
402
403

  /** Get the names of the library needed to generate a build rule
      that takes into account shared library version numbers.  This
      should be called only on a library target.  */
404
  void GetLibraryNames(std::string& name, std::string& soName,
405
                       std::string& realName, std::string& impName,
406
                       std::string& pdbName, const char* config) const;
407

408
409
410
  /** Get the names of the executable needed to generate a build rule
      that takes into account executable version numbers.  This should
      be called only on an executable target.  */
411
  void GetExecutableNames(std::string& name, std::string& realName,
412
                          std::string& impName,
413
                          std::string& pdbName, const char* config) const;
414

415
  /** Does this target have a GNU implib to convert to MS format?  */
416
  bool HasImplibGNUtoMS() const;
417
418
419
420

  /** Convert the given GNU import library name (.dll.a) to a name with a new
      extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}).  */
  bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
421
                        const char* newExt = 0) const;
422

423
424
425
  /**
   * Compute whether this target must be relinked before installing.
   */
426
  bool NeedRelinkBeforeInstall(const char* config) const;
427

428
429
  bool HaveBuildTreeRPATH(const char *config) const;
  bool HaveInstallTreeRPATH() const;
430

431
  /** Return true if builtin chrpath will work for this target */
432
  bool IsChrpathUsed(const char* config) const;
433

434
  /** Return the install name directory for the target in the
435
    * build tree.  For example: "\@rpath/", "\@loader_path/",
436
    * or "/full/path/to/library".  */
437
  std::string GetInstallNameDirForBuildTree(const char* config) const;
438
439

  /** Return the install name directory for the target in the
440
    * install tree.  For example: "\@rpath/" or "\@loader_path/". */
441
  std::string GetInstallNameDirForInstallTree() const;
442

443
  cmComputeLinkInformation* GetLinkInformation(const char* config,
444
                                               cmTarget const* head = 0) const;
445

446
  // Get the properties
447
  cmPropertyMap &GetProperties() const { return this->Properties; };
448

449
450
451
  bool GetMappedConfig(std::string const& desired_config,
                       const char** loc,
                       const char** imp,
452
                       std::string& suffix) const;
453

454
455
  // Define the properties
  static void DefineProperties(cmake *cm);
456

457
458
  /** Get the macro to define when building sources in this target.
      If no macro should be defined null is returned.  */
459
  const char* GetExportMacro() const;
460

461
  void GetCompileDefinitions(std::vector<std::string> &result,
462
                             const char *config) const;
463

464
465
466
467
468
469
470
  // Compute the set of languages compiled by the target.  This is
  // computed every time it is called because the languages can change
  // when source file properties are changed and we do not have enough
  // information to forward these property changes to the targets
  // until we have per-target object file properties.
  void GetLanguages(std::set<cmStdString>& languages) const;

471
472
  /** Return whether this target is an executable with symbol exports
      enabled.  */
473
  bool IsExecutableWithExports() const;
474

475
  /** Return whether this target may be used to link another target.  */
476
  bool IsLinkable() const;
477

Brad King's avatar
Brad King committed
478
  /** Return whether or not the target is for a DLL platform.  */
479
  bool IsDLLPlatform() const { return this->DLLPlatform; }
Brad King's avatar
Brad King committed
480
481

  /** Return whether or not the target has a DLL import library.  */
482
  bool HasImportLibrary() const;
Brad King's avatar
Brad King committed
483

484
485
  /** Return whether this target is a shared library Framework on
      Apple.  */
486
  bool IsFrameworkOnApple() const;
487

488
  /** Return whether this target is a CFBundle (plugin) on Apple.  */
489
  bool IsCFBundleOnApple() const;
490

491
  /** Return whether this target is an executable Bundle on Apple.  */
492
  bool IsAppBundleOnApple() const;
493

494
495
  /** Return whether this target is an executable Bundle, a framework
      or CFBundle on Apple.  */
496
  bool IsBundleOnApple() const;
497

498
499
  /** Return the framework version string.  Undefined if
      IsFrameworkOnApple returns false.  */
500
  std::string GetFrameworkVersion() const;
501

502
503
504
  /** Get a backtrace from the creation of the target.  */
  cmListFileBacktrace const& GetBacktrace() const;

505
506
507
  /** Get a build-tree directory in which to place target support files.  */
  std::string GetSupportDirectory() const;

508
509
  /** Return whether this target uses the default value for its output
      directory.  */
510
  bool UsesDefaultOutputDir(const char* config, bool implib) const;
511

512
  /** @return the mac content directory for this target. */
513
  std::string GetMacContentDirectory(const char* config,
514
                                     bool implib) const;
515
516

  /** @return whether this target have a well defined output file name. */
517
  bool HaveWellDefinedOutputFiles() const;
518

519
  /** @return the Mac framework directory without the base. */
520
  std::string GetFrameworkDirectory(const char* config, bool rootDir) const;
521
522

  /** @return the Mac CFBundle directory without the base */
523
  std::string GetCFBundleDirectory(const char* config, bool contentOnly) const;
524
525

  /** @return the Mac App directory without the base */
526
527
  std::string GetAppBundleDirectory(const char* config,
                                    bool contentOnly) const;
528

529
  std::vector<std::string> GetIncludeDirectories(const char *config) const;
530
  void InsertInclude(const cmValueWithOrigin &entry,
531
                     bool before = false);
532
533
  void InsertCompileOption(const cmValueWithOrigin &entry,
                     bool before = false);
534
  void InsertCompileDefinition(const cmValueWithOrigin &entry);
535

536
537
  void AppendBuildInterfaceIncludes();

538
  void GetCompileOptions(std::vector<std::string> &result,
539
                         const char *config) const;
540
541
  void GetAutoUicOptions(std::vector<std::string> &result,
                         const char *config) const;
542

543
  bool IsNullImpliedByLinkLibraries(const std::string &p) const;
544
  bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
545
                                            const char *config) const;
546
  bool IsLinkInterfaceDependentStringProperty(const std::string &p,
547
                                              const char *config) const;
548
  bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
549
                                                 const char *config) const;
550
  bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
551
                                                 const char *config) const;
552

553
  bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
554
                                             const char *config) const;
555
556

  const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
557
                                                    const char *config) const;
558
  const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
559
                                                    const char *config) const;
560
  const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
561
                                                    const char *config) const;
562
563

  std::string GetDebugGeneratorExpressions(const std::string &value,
564
                                  cmTarget::LinkLibraryType llt) const;
565
566
567
568
569

  void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
  void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
  std::set<cmStdString> const & GetSystemIncludeDirectories() const
    { return this->SystemIncludeDirectories; }
570

571
572
573
  bool LinkLanguagePropagatesToDependents() const
  { return this->TargetTypeValue == STATIC_LIBRARY; }

574
575
576
577
578
  void ReportPropertyOrigin(const std::string &p,
                            const std::string &result,
                            const std::string &report,
                            const std::string &compatibilityType) const;

579
private:
580
  bool HandleLocationPropertyPolicy() const;
581

582
583
584
585
  // The set of include directories that are marked as system include
  // directories.
  std::set<cmStdString> SystemIncludeDirectories;

586
587
  std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;

588
589
590
  /**
   * A list of direct dependencies. Use in conjunction with DependencyMap.
   */
591
  typedef std::vector< LibraryID > DependencyList;
592

593
594
  /**
   * This map holds the dependency graph. map[x] returns a set of
595
596
597
   * direct dependencies of x. Note that the direct depenencies are
   * ordered. This is necessary to handle direct dependencies that
   * themselves have no dependency information.
598
   */
599
  typedef std::map< LibraryID, DependencyList > DependencyMap;
600

601
  /**
602
603
604
   * Inserts \a dep at the end of the dependency list of \a lib.
   */
  void InsertDependency( DependencyMap& depMap,
605
606
                         const LibraryID& lib,
                         const LibraryID& dep);
607
608
609
610
611

  /*
   * Deletes \a dep from the dependency list of \a lib.
   */
  void DeleteDependency( DependencyMap& depMap,
612
613
                         const LibraryID& lib,
                         const LibraryID& dep);
614
615
616
617
618
619
620
621

  /**
   * Emits the library \a lib and all its dependencies into link_line.
   * \a emitted keeps track of the libraries that have been emitted to
   * avoid duplicates--it is more efficient than searching
   * link_line. \a visited is used detect cycles. Note that \a
   * link_line is in reverse order, in that the dependencies of a
   * library are listed before the library itself.
622
   */
623
  void Emit( const LibraryID lib,
624
             const DependencyMap& dep_map,
625
626
627
             std::set<LibraryID>& emitted,
             std::set<LibraryID>& visited,
             DependencyList& link_line);
628
629

  /**
630
631
   * Finds the dependencies for \a lib and inserts them into \a
   * dep_map.
632
   */
633
  void GatherDependencies( const cmMakefile& mf,
634
                           const LibraryID& lib,
635
                           DependencyMap& dep_map);
Bill Hoffman's avatar
Bill Hoffman committed
636

637
638
  void AnalyzeLibDependencies( const cmMakefile& mf );

639
640
641
  const char* GetSuffixVariableInternal(bool implib) const;
  const char* GetPrefixVariableInternal(bool implib) const;
  std::string GetFullNameInternal(const char* config, bool implib) const;
642
  void GetFullNameInternal(const char* config, bool implib,
643
                           std::string& outPrefix, std::string& outBase,
644
                           std::string& outSuffix) const;
645

646
647
648
  // Use a makefile variable to set a default for the given property.
  // If the variable is not defined use the given default instead.
  void SetPropertyDefault(const char* property, const char* default_value);
649

650
  // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
651
  const char* GetOutputTargetType(bool implib) const;
652

653
  // Get the target base name.
654
  std::string GetOutputName(const char* config, bool implib) const;
655

656
657
  const char* ImportedGetLocation(const char* config) const;
  const char* NormalGetLocation(const char* config) const;
658

659
  std::string GetFullNameImported(const char* config, bool implib) const;
660

661
  std::string ImportedGetFullPath(const char* config, bool implib) const;
662
  std::string NormalGetFullPath(const char* config, bool implib,
663
                                bool realname) const;
664
665
666
667
668

  /** Get the real name of the target.  Allowed only for non-imported
      targets.  When a library or executable file is versioned this is
      the full versioned name.  If the target is not versioned this is
      the same as GetFullName.  */
669
  std::string NormalGetRealName(const char* config) const;
670

671
672
673
  /** Append to @a base the mac content directory and return it. */
  std::string BuildMacContentDirectory(const std::string& base,
                                       const char* config,
674
                                       bool contentOnly) const;
675

676
private:
Ken Martin's avatar
Ken Martin committed
677
678
679
680
681
682
  std::string Name;
  std::vector<cmCustomCommand> PreBuildCommands;
  std::vector<cmCustomCommand> PreLinkCommands;
  std::vector<cmCustomCommand> PostBuildCommands;
  TargetType TargetTypeValue;
  std::vector<cmSourceFile*> SourceFiles;
683
  std::vector<std::string> ObjectLibraries;
Ken Martin's avatar
Ken Martin committed
684
685
686
687
  LinkLibraryVectorType LinkLibraries;
  LinkLibraryVectorType PrevLinkedLibraries;
  bool LinkLibrariesAnalyzed;
  std::vector<std::string> LinkDirectories;
688
  std::set<cmStdString> LinkDirectoriesEmmitted;
Ken Martin's avatar
Ken Martin committed
689
690
691
  bool HaveInstallRule;
  std::string InstallPath;
  std::string RuntimeInstallPath;
692
  mutable std::string ExportMacro;
Ken Martin's avatar
Ken Martin committed
693
  std::set<cmStdString> Utilities;
694
  std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces;
695
  bool RecordDependencies;
696
  mutable cmPropertyMap Properties;
Ken Martin's avatar
Ken Martin committed
697
  LinkLibraryVectorType OriginalLinkLibraries;
698
  bool DLLPlatform;
699
  bool IsApple;
Alexander Neundorf's avatar
   
Alexander Neundorf committed
700
  bool IsImportedTarget;
701
  mutable bool DebugIncludesDone;
702
  mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
703
704
  mutable bool DebugCompileOptionsDone;
  mutable bool DebugCompileDefinitionsDone;
705
  mutable std::set<std::string> LinkImplicitNullProperties;
706
  bool BuildInterfaceIncludesAppended;
707

708
  // Cache target output paths for each configuration.
709
  struct OutputInfo;
710
711
712
713
  OutputInfo const* GetOutputInfo(const char* config) const;
  bool
  ComputeOutputDir(const char* config, bool implib, std::string& out) const;
  bool ComputePDBOutputDir(const char* config, std::string& out) const;
714

715
  // Cache import information from properties for each configuration.
716
  struct ImportInfo;
717
  ImportInfo const* GetImportInfo(const char* config,
718
                                        cmTarget const* workingTarget) const;
719
  void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
720
                                        cmTarget const* head) const;
721

722
  mutable cmTargetLinkInformationMap LinkInformation;
723
  void CheckPropertyCompatibility(cmComputeLinkInformation *info,
724
                                  const char* config) const;
725

726
  bool ComputeLinkInterface(const char* config, LinkInterface& iface,
727
                                        cmTarget const* head) const;
728

729
  void ComputeLinkImplementation(const char* config,
730
731
732
733
                                 LinkImplementation& impl,
                                 cmTarget const* head) const;
  void ComputeLinkClosure(const char* config, LinkClosure& lc,
                          cmTarget const* head) const;
734

735
736
  void ClearLinkMaps();

737
738
  void MaybeInvalidatePropertyCache(const char* prop);

739
740
  void ProcessSourceExpression(std::string const& expr);

741
742
  // The cmMakefile instance that owns this target.  This should
  // always be set.
Ken Martin's avatar
Ken Martin committed
743
  cmMakefile* Makefile;
744

745
  // Policy status recorded when target was created.
746
747
748
749
750
751
#define TARGET_POLICY_MEMBER(POLICY) \
  cmPolicies::PolicyStatus PolicyStatus ## POLICY;

  CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER)

#undef TARGET_POLICY_MEMBER
752

753
754
  // Internal representation details.
  friend class cmTargetInternals;
755
756
  friend class cmGeneratorTarget;
  friend class cmTargetTraceDependencies;
757
758
  cmTargetInternalPointer Internal;

759
  void ConstructSourceFileFlags() const;
760
761
762
763
764
  void ComputeVersionedName(std::string& vName,
                            std::string const& prefix,
                            std::string const& base,
                            std::string const& suffix,
                            std::string const& name,
765
                            const char* version) const;
766
767
};

768
typedef std::map<cmStdString,cmTarget> cmTargets;
769

770
771
772
class cmTargetSet: public std::set<cmStdString> {};
class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};

773
#endif