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(CMP0027) \
  F(CMP0038) \
31
  F(CMP0041) \
32
33
  F(CMP0042) \
  F(CMP0046)
34

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

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

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

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

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

96
97
98
  /**
   * Set the target type
   */
99
100
  void SetType(TargetType f, const char* name);

Alexander Neundorf's avatar
   
Alexander Neundorf committed
101
  void MarkAsImported();
102

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

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

111
112
113
#define DECLARE_TARGET_POLICY(POLICY) \
  cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
    { return this->PolicyStatus ## POLICY; }
114

115
  CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
116

117
#undef DECLARE_TARGET_POLICY
118

119
120
121
  /**
   * Get the list of the custom commands for this target
   */
122
  std::vector<cmCustomCommand> const &GetPreBuildCommands() const
Ken Martin's avatar
Ken Martin committed
123
    {return this->PreBuildCommands;}
124
  std::vector<cmCustomCommand> const &GetPreLinkCommands() const
Ken Martin's avatar
Ken Martin committed
125
    {return this->PreLinkCommands;}
126
  std::vector<cmCustomCommand> const &GetPostBuildCommands() const
Ken Martin's avatar
Ken Martin committed
127
    {return this->PostBuildCommands;}
128
129
130
131
132
133
  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);}
134

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

145
146
147
148
  /**
   * 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.
   */
149
150
151
152
153
154
155
156
157
  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"
  };
158
159
  struct SourceFileFlags
  {
160
161
162
163
164
    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
165
166
167
168
169
  };

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

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

179
  enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
180

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

196
  /** Compute the link type to use for the given configuration.  */
197
  LinkLibraryType ComputeLinkType(const char* config) const;
198

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

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

216
  void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
Ken Martin's avatar
Ken Martin committed
217
                           const LinkLibraryVectorType& libs );
218

219
  const std::vector<std::string>& GetLinkDirectories() const;
220

221
  void AddLinkDirectory(const char* d);
Ken Martin's avatar
Ken Martin committed
222
223
224
225
226

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

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

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

244
245
  /** 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
246
   * commands. It is not a full path nor does it have an extension.
247
   */
248
  void AddUtility(const char* u, cmMakefile *makefile = 0);
249
  ///! Get the utilities used by this target
250
  std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
251
  cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
252

253
254
  /** Finalize the target at the end of the Configure step.  */
  void FinishConfigure();
255

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

264
  const char* GetFeature(const char* feature, const char* config) const;
265

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

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

275
276
277
278
279
280
    // Libraries listed in the interface.
    std::vector<std::string> Libraries;

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

281
282
283
284
    // Number of repetitions of a strongly connected component of two
    // or more static libraries.
    int Multiplicity;

285
286
287
    // Libraries listed for other configurations.
    // Needed only for OLD behavior of CMP0003.
    std::vector<std::string> WrongConfigLibraries;
288

289
290
291
    bool ImplementationIsInterface;

    LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
292
293
294
295
  };

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

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

309
310
311
312
313
314
315
    // 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;
  };
316
  LinkImplementation const* GetLinkImplementation(const char* config,
317
                                                  cmTarget const* head) const;
318

319
320
321
322
323
324
325
326
327
328
  /** 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;
  };
329
330
  LinkClosure const* GetLinkClosure(const char* config,
                                    cmTarget const* head) const;
331

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

336
337
338
339
  /** 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.  */
340
  std::string GetDirectory(const char* config = 0, bool implib = false) const;
341

342
343
344
345
  /** 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.  */
346
  std::string GetPDBDirectory(const char* config = 0) const;
347

348
349
350
  /** 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.  */
351
  const char* GetLocation(const char* config) const;
352

353
354
355
  /** 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.  */
356
  void GetTargetVersion(int& major, int& minor) const;
357

358
359
360
  /** 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.  */
361
362
  void
  GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
363

364
365
366
367
368
  /**
   * Make sure the full path to all source files is known.
   */
  bool FindSourceFiles();

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

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

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

383
  /** Whether this library has soname enabled and platform supports it.  */
384
  bool HasSOName(const char* config) const;
385

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

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

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

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

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

  /** 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.  */
407
  void GetLibraryNames(std::string& name, std::string& soName,
408
                       std::string& realName, std::string& impName,
409
                       std::string& pdbName, const char* config) const;
410

411
412
413
  /** 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.  */
414
  void GetExecutableNames(std::string& name, std::string& realName,
415
                          std::string& impName,
416
                          std::string& pdbName, const char* config) const;
417

418
  /** Does this target have a GNU implib to convert to MS format?  */
419
  bool HasImplibGNUtoMS() const;
420
421
422
423

  /** 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,
424
                        const char* newExt = 0) const;
425

426
427
428
  /**
   * Compute whether this target must be relinked before installing.
   */
429
  bool NeedRelinkBeforeInstall(const char* config) const;
430

431
432
  bool HaveBuildTreeRPATH(const char *config) const;
  bool HaveInstallTreeRPATH() const;
433

434
  /** Return true if builtin chrpath will work for this target */
435
  bool IsChrpathUsed(const char* config) const;
436

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

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

446
  cmComputeLinkInformation* GetLinkInformation(const char* config,
447
                                               cmTarget const* head = 0) const;
448

449
  // Get the properties
450
  cmPropertyMap &GetProperties() const { return this->Properties; };
451

452
453
454
  bool GetMappedConfig(std::string const& desired_config,
                       const char** loc,
                       const char** imp,
455
                       std::string& suffix) const;
456

457
458
  // Define the properties
  static void DefineProperties(cmake *cm);
459

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

464
  void GetCompileDefinitions(std::vector<std::string> &result,
465
                             const char *config) const;
466

467
468
469
470
471
472
473
  // 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;

474
475
  /** Return whether this target is an executable with symbol exports
      enabled.  */
476
  bool IsExecutableWithExports() const;
477

478
  /** Return whether this target may be used to link another target.  */
479
  bool IsLinkable() const;
480

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

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

487
488
  /** Return whether this target is a shared library Framework on
      Apple.  */
489
  bool IsFrameworkOnApple() const;
490

491
  /** Return whether this target is a CFBundle (plugin) on Apple.  */
492
  bool IsCFBundleOnApple() const;
493

494
  /** Return whether this target is an executable Bundle on Apple.  */
495
  bool IsAppBundleOnApple() const;
496

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

501
502
  /** Return the framework version string.  Undefined if
      IsFrameworkOnApple returns false.  */
503
  std::string GetFrameworkVersion() const;
504

505
506
507
  /** Get a backtrace from the creation of the target.  */
  cmListFileBacktrace const& GetBacktrace() const;

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

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

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

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

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

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

  /** @return the Mac App directory without the base */
529
530
  std::string GetAppBundleDirectory(const char* config,
                                    bool contentOnly) const;
531

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

539
540
  void AppendBuildInterfaceIncludes();

541
  void GetCompileOptions(std::vector<std::string> &result,
542
                         const char *config) const;
543
544
  void GetAutoUicOptions(std::vector<std::string> &result,
                         const char *config) const;
545

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

556
  bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
557
                                             const char *config) const;
558
559

  const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
560
                                                    const char *config) const;
561
  const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
562
                                                    const char *config) const;
563
  const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
564
                                                    const char *config) const;
565
566

  std::string GetDebugGeneratorExpressions(const std::string &value,
567
                                  cmTarget::LinkLibraryType llt) const;
568
569
570
571
572

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

574
575
576
  bool LinkLanguagePropagatesToDependents() const
  { return this->TargetTypeValue == STATIC_LIBRARY; }

577
578
579
580
581
  void ReportPropertyOrigin(const std::string &p,
                            const std::string &result,
                            const std::string &report,
                            const std::string &compatibilityType) const;

582
private:
583
  bool HandleLocationPropertyPolicy() const;
584

585
586
587
588
  // The set of include directories that are marked as system include
  // directories.
  std::set<cmStdString> SystemIncludeDirectories;

589
590
  std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;

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

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

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

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

  /**
   * 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.
625
   */
626
  void Emit( const LibraryID lib,
627
             const DependencyMap& dep_map,
628
629
630
             std::set<LibraryID>& emitted,
             std::set<LibraryID>& visited,
             DependencyList& link_line);
631
632

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

640
641
  void AnalyzeLibDependencies( const cmMakefile& mf );

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

649
650
651
  // 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);
652

653
  // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
654
  const char* GetOutputTargetType(bool implib) const;
655

656
  // Get the target base name.
657
  std::string GetOutputName(const char* config, bool implib) const;
658

659
660
  const char* ImportedGetLocation(const char* config) const;
  const char* NormalGetLocation(const char* config) const;
661

662
  std::string GetFullNameImported(const char* config, bool implib) const;
663

664
  std::string ImportedGetFullPath(const char* config, bool implib) const;
665
  std::string NormalGetFullPath(const char* config, bool implib,
666
                                bool realname) const;
667
668
669
670
671

  /** 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.  */
672
  std::string NormalGetRealName(const char* config) const;
673

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

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

711
  // Cache target output paths for each configuration.
712
  struct OutputInfo;
713
714
715
716
  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;
717

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

725
  mutable cmTargetLinkInformationMap LinkInformation;
726
  void CheckPropertyCompatibility(cmComputeLinkInformation *info,
727
                                  const char* config) const;
728

729
  bool ComputeLinkInterface(const char* config, LinkInterface& iface,
730
                                        cmTarget const* head) const;
731

732
  void ComputeLinkImplementation(const char* config,
733
734
735
736
                                 LinkImplementation& impl,
                                 cmTarget const* head) const;
  void ComputeLinkClosure(const char* config, LinkClosure& lc,
                          cmTarget const* head) const;
737

738
739
  void ClearLinkMaps();

740
741
  void MaybeInvalidatePropertyCache(const char* prop);

742
743
  void ProcessSourceExpression(std::string const& expr);

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

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

  CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER)

#undef TARGET_POLICY_MEMBER
755

756
757
  // Internal representation details.
  friend class cmTargetInternals;
758
759
  friend class cmGeneratorTarget;
  friend class cmTargetTraceDependencies;
760
761
  cmTargetInternalPointer Internal;

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

771
typedef std::map<cmStdString,cmTarget> cmTargets;
772

773
774
775
class cmTargetSet: public std::set<cmStdString> {};
class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};

776
#endif