cmGeneratorTarget.h 33.8 KB
Newer Older
1
2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3
4
5
#ifndef cmGeneratorTarget_h
#define cmGeneratorTarget_h

6
#include "cmConfigure.h" // IWYU pragma: keep
7

8
#include "cmLinkItem.h"
9
10
#include "cmListFileCache.h"
#include "cmPolicies.h"
11
#include "cmStateTypes.h"
12
13
14

#include <map>
#include <set>
15
#include <stddef.h>
16
17
18
#include <string>
#include <utility>
#include <vector>
19

20
class cmComputeLinkInformation;
21
22
23
24
25
26
27
28
29
class cmCustomCommand;
class cmGlobalGenerator;
class cmLocalGenerator;
class cmMakefile;
class cmSourceFile;
class cmTarget;

class cmGeneratorTarget
{
Daniel Pfeifer's avatar
Daniel Pfeifer committed
30
31
  CM_DISABLE_COPY(cmGeneratorTarget)

32
public:
33
  cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg);
34
  ~cmGeneratorTarget();
35

36
37
  cmLocalGenerator* GetLocalGenerator() const;

38
39
  cmGlobalGenerator* GetGlobalGenerator() const;

40
  bool IsImported() const;
41
  bool IsImportedGloballyVisible() const;
42
  const char* GetLocation(const std::string& config) const;
43

44
45
46
  std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
  std::vector<cmCustomCommand> const& GetPreLinkCommands() const;
  std::vector<cmCustomCommand> const& GetPostBuildCommands() const;
47

48
49
50
51
52
#define DECLARE_TARGET_POLICY(POLICY)                                         \
  cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const                    \
  {                                                                           \
    return this->PolicyMap.Get(cmPolicies::POLICY);                           \
  }
53
54
55
56
57

  CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)

#undef DECLARE_TARGET_POLICY

58
59
60
61
62
  /** Get the location of the target in the build tree with a placeholder
      referencing the configuration in the native build system.  This
      location is suitable for use as the LOCATION target property.  */
  const char* GetLocationForBuild() const;

63
64
  cmComputeLinkInformation* GetLinkInformation(
    const std::string& config) const;
65

66
  cmStateEnums::TargetType GetType() const;
67
  const std::string& GetName() const;
68
69
  std::string GetExportName() const;

70
  std::vector<std::string> GetPropertyKeys() const;
71
  ///! Might return a nullptr if the property is not set or invalid
72
  const char* GetProperty(const std::string& prop) const;
73
74
  ///! Always returns a valid pointer
  const char* GetSafeProperty(const std::string& prop) const;
75
  bool GetPropertyAsBool(const std::string& prop) const;
76
77
  void GetSourceFiles(std::vector<cmSourceFile*>& files,
                      const std::string& config) const;
78
79
  void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files,
                                            const std::string& config) const;
80

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  /** Source file kinds (classifications).
      Generators use this to decide how to treat a source file.  */
  enum SourceKind
  {
    SourceKindAppManifest,
    SourceKindCertificate,
    SourceKindCustomCommand,
    SourceKindExternalObject,
    SourceKindExtra,
    SourceKindHeader,
    SourceKindIDL,
    SourceKindManifest,
    SourceKindModuleDefinition,
    SourceKindObjectSource,
    SourceKindResx,
    SourceKindXaml
  };

  /** A source file paired with a kind (classification).  */
  struct SourceAndKind
  {
    cmSourceFile* Source;
    SourceKind Kind;
  };

  /** All sources needed for a configuration with kinds assigned.  */
  struct KindedSources
  {
    std::vector<SourceAndKind> Sources;
    std::set<std::string> ExpectedResxHeaders;
    std::set<std::string> ExpectedXamlHeaders;
    std::set<std::string> ExpectedXamlSources;
113
114
115
116
117
    bool Initialized;
    KindedSources()
      : Initialized(false)
    {
    }
118
119
120
121
122
  };

  /** Get all sources needed for a configuration with kinds assigned.  */
  KindedSources const& GetKindedSources(std::string const& config) const;

123
124
125
126
127
128
129
130
131
132
133
  struct AllConfigSource
  {
    cmSourceFile const* Source;
    cmGeneratorTarget::SourceKind Kind;
    std::vector<size_t> Configs;
  };

  /** Get all sources needed for all configurations with kinds and
      per-source configurations assigned.  */
  std::vector<AllConfigSource> const& GetAllConfigSources() const;

134
  void GetObjectSources(std::vector<cmSourceFile const*>&,
135
                        const std::string& config) const;
136
  const std::string& GetObjectName(cmSourceFile const* file);
137
  const char* GetCustomObjectExtension() const;
138
139

  bool HasExplicitObjectName(cmSourceFile const* file) const;
140
  void AddExplicitObjectName(cmSourceFile const* sf);
141

142
143
  void GetModuleDefinitionSources(std::vector<cmSourceFile const*>&,
                                  const std::string& config) const;
144
145
146
147
148
149
150
151
152
153
154
155
  void GetResxSources(std::vector<cmSourceFile const*>&,
                      const std::string& config) const;
  void GetExternalObjects(std::vector<cmSourceFile const*>&,
                          const std::string& config) const;
  void GetHeaderSources(std::vector<cmSourceFile const*>&,
                        const std::string& config) const;
  void GetExtraSources(std::vector<cmSourceFile const*>&,
                       const std::string& config) const;
  void GetCustomCommands(std::vector<cmSourceFile const*>&,
                         const std::string& config) const;
  void GetExpectedResxHeaders(std::set<std::string>&,
                              const std::string& config) const;
156
157
  void GetAppManifest(std::vector<cmSourceFile const*>&,
                      const std::string& config) const;
158
159
  void GetManifests(std::vector<cmSourceFile const*>&,
                    const std::string& config) const;
160
161
  void GetCertificates(std::vector<cmSourceFile const*>&,
                       const std::string& config) const;
162
163
164
165
166
167
  void GetXamlSources(std::vector<cmSourceFile const*>&,
                      const std::string& config) const;
  void GetExpectedXamlHeaders(std::set<std::string>&,
                              const std::string& config) const;
  void GetExpectedXamlSources(std::set<std::string>&,
                              const std::string& config) const;
168

169
  std::set<cmLinkItem> const& GetUtilityItems() const;
170

171
172
  void ComputeObjectMapping();

173
174
  const char* GetFeature(const std::string& feature,
                         const std::string& config) const;
175

176
  bool IsIPOEnabled(std::string const& lang, std::string const& config) const;
177

178
179
180
181
182
183
184
185
  bool IsLinkInterfaceDependentBoolProperty(const std::string& p,
                                            const std::string& config) const;
  bool IsLinkInterfaceDependentStringProperty(const std::string& p,
                                              const std::string& config) const;
  bool IsLinkInterfaceDependentNumberMinProperty(
    const std::string& p, const std::string& config) const;
  bool IsLinkInterfaceDependentNumberMaxProperty(
    const std::string& p, const std::string& config) const;
186

187
  bool GetLinkInterfaceDependentBoolProperty(const std::string& p,
188
189
                                             const std::string& config) const;

190
191
192
193
194
195
  const char* GetLinkInterfaceDependentStringProperty(
    const std::string& p, const std::string& config) const;
  const char* GetLinkInterfaceDependentNumberMinProperty(
    const std::string& p, const std::string& config) const;
  const char* GetLinkInterfaceDependentNumberMaxProperty(
    const std::string& p, const std::string& config) const;
196

197
198
  cmLinkInterface const* GetLinkInterface(
    const std::string& config, const cmGeneratorTarget* headTarget) const;
199
200
  void ComputeLinkInterface(const std::string& config,
                            cmOptionalLinkInterface& iface,
201
                            const cmGeneratorTarget* head) const;
202

203
204
205
  cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries(
    const std::string& config, const cmGeneratorTarget* headTarget,
    bool usage_requirements_only) const;
206

207
  void ComputeLinkInterfaceLibraries(const std::string& config,
208
                                     cmOptionalLinkInterface& iface,
209
                                     const cmGeneratorTarget* head,
210
211
                                     bool usage_requirements_only) const;

212
213
214
  /** Get the library name for an imported interface library.  */
  std::string GetImportedLibName(std::string const& config) const;

215
216
  /** Get the full path to the target according to the settings in its
      makefile and the configuration type.  */
217
218
219
220
221
222
  std::string GetFullPath(
    const std::string& config = "",
    cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact,
    bool realname = false) const;
  std::string NormalGetFullPath(const std::string& config,
                                cmStateEnums::ArtifactType artifact,
223
224
225
                                bool realname) const;
  std::string NormalGetRealName(const std::string& config) const;

226
227
228
229
230
  /** Get the names of an object library's object files underneath
      its object file directory.  */
  void GetTargetObjectNames(std::string const& config,
                            std::vector<std::string>& objects) const;

231
232
233
  /** What hierarchy level should the reported directory contain */
  enum BundleDirectoryLevel
  {
234
    BundleDirLevel,
235
236
237
238
    ContentLevel,
    FullLevel
  };

239
240
  /** @return the Mac App directory without the base */
  std::string GetAppBundleDirectory(const std::string& config,
241
                                    BundleDirectoryLevel level) const;
242

243
244
245
246
  /** Return whether this target is an executable Bundle, a framework
      or CFBundle on Apple.  */
  bool IsBundleOnApple() const;

247
248
  /** Get the full name of the target according to the settings in its
      makefile.  */
249
  std::string GetFullName(const std::string& config = "",
250
251
                          cmStateEnums::ArtifactType artifact =
                            cmStateEnums::RuntimeBinaryArtifact) const;
252

253
254
  /** @return the Mac framework directory without the base. */
  std::string GetFrameworkDirectory(const std::string& config,
255
                                    BundleDirectoryLevel level) const;
256

257
258
259
260
  /** Return the framework version string.  Undefined if
      IsFrameworkOnApple returns false.  */
  std::string GetFrameworkVersion() const;

261
262
  /** @return the Mac CFBundle directory without the base */
  std::string GetCFBundleDirectory(const std::string& config,
263
                                   BundleDirectoryLevel level) const;
264

265
  /** Return the install name directory for the target in the
266
267
   * build tree.  For example: "\@rpath/", "\@loader_path/",
   * or "/full/path/to/library".  */
268
269
270
  std::string GetInstallNameDirForBuildTree(const std::string& config) const;

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

274
275
  cmListFileBacktrace GetBacktrace() const;

276
277
  const std::vector<std::string>& GetLinkDirectories() const;

278
  std::set<std::string> const& GetUtilities() const;
279
280
  cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;

281
  bool LinkLanguagePropagatesToDependents() const
282
  {
283
    return this->GetType() == cmStateEnums::STATIC_LIBRARY;
284
  }
285

286
287
288
289
  /** Get the macro to define when building sources in this target.
      If no macro should be defined null is returned.  */
  const char* GetExportMacro() const;

290
291
292
  /** Get the soname of the target.  Allowed only for a shared library.  */
  std::string GetSOName(const std::string& config) const;

293
294
295
  void GetFullNameComponents(std::string& prefix, std::string& base,
                             std::string& suffix,
                             const std::string& config = "",
296
297
                             cmStateEnums::ArtifactType artifact =
                               cmStateEnums::RuntimeBinaryArtifact) const;
298

299
300
301
302
303
  /** Append to @a base the bundle directory hierarchy up to a certain @a level
   * and return it. */
  std::string BuildBundleDirectory(const std::string& base,
                                   const std::string& config,
                                   BundleDirectoryLevel level) const;
304
305

  /** @return the mac content directory for this target. */
306
307
  std::string GetMacContentDirectory(
    const std::string& config, cmStateEnums::ArtifactType artifact) const;
308

309
310
311
  /** @return folder prefix for IDEs. */
  std::string GetEffectiveFolderName() const;

312
313
314
  cmTarget* Target;
  cmMakefile* Makefile;
  cmLocalGenerator* LocalGenerator;
315
  cmGlobalGenerator const* GlobalGenerator;
316

317
318
319
  struct ModuleDefinitionInfo
  {
    std::string DefFile;
320
    bool DefFileGenerated;
321
    bool WindowsExportAllSymbols;
322
    std::vector<cmSourceFile const*> Sources;
323
324
325
  };
  ModuleDefinitionInfo const* GetModuleDefinitionInfo(
    std::string const& config) const;
326

327
328
329
  /** Return whether or not the target is for a DLL platform.  */
  bool IsDLLPlatform() const;

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

333
334
335
336
337
338
339
340
341
342
343
344
345
346
  /** 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;
  };

  LinkClosure const* GetLinkClosure(const std::string& config) const;
  void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const;

347
348
  cmLinkImplementation const* GetLinkImplementation(
    const std::string& config) const;
349

350
351
  void ComputeLinkImplementationLanguages(
    const std::string& config, cmOptionalLinkImplementation& impl) const;
352

353
354
  cmLinkImplementationLibraries const* GetLinkImplementationLibraries(
    const std::string& config) const;
355
356
357

  void ComputeLinkImplementationLibraries(const std::string& config,
                                          cmOptionalLinkImplementation& impl,
358
                                          const cmGeneratorTarget* head) const;
359

360
361
  cmGeneratorTarget* FindTargetToLink(std::string const& name) const;

362
363
364
365
366
367
368
369
  // 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<std::string>& languages,
                    std::string const& config) const;

370
371
372
373
374
375
  // Evaluate if the target uses the given language for compilation
  // and/or linking. If 'exclusive' is true, 'language' is expected
  // to be the only language used for the target.
  bool HasLanguage(std::string const& language, std::string const& config,
                   bool exclusive = true) const;

376
377
  void GetObjectLibrariesCMP0026(
    std::vector<cmGeneratorTarget*>& objlibs) const;
378

379
  std::string GetFullNameImported(const std::string& config,
380
                                  cmStateEnums::ArtifactType artifact) const;
381

382
383
384
  /** Get source files common to all configurations and diagnose cases
      with per-config sources.  Excludes sources added by a TARGET_OBJECTS
      generator expression.  */
385
386
  bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;

387
388
  bool HaveBuildTreeRPATH(const std::string& config) const;

389
390
391
392
393
  /** Full path with trailing slash to the top-level directory
      holding object files for this target.  Includes the build
      time config name placeholder if needed for the generator.  */
  std::string ObjectDirectory;

394
395
396
397
  /** Full path with trailing slash to the top-level directory
      holding object files for the given configuration.  */
  std::string GetObjectDirectory(std::string const& config) const;

398
  void GetAppleArchs(const std::string& config,
399
                     std::vector<std::string>& archVec) const;
400

401
  std::string GetFeatureSpecificLinkRuleVariable(
402
403
    std::string const& var, std::string const& lang,
    std::string const& config) const;
404

405
406
407
  /** Return the rule variable used to create this type of target.  */
  std::string GetCreateRuleVariable(std::string const& lang,
                                    std::string const& config) const;
408

409
  /** Get the include directories for this target.  */
410
  std::vector<std::string> GetIncludeDirectories(
411
    const std::string& config, const std::string& lang) const;
412

413
  void GetCompileOptions(std::vector<std::string>& result,
414
415
416
                         const std::string& config,
                         const std::string& language) const;

417
  void GetCompileFeatures(std::vector<std::string>& features,
418
419
                          const std::string& config) const;

420
  void GetCompileDefinitions(std::vector<std::string>& result,
421
422
423
                             const std::string& config,
                             const std::string& language) const;

424
425
426
427
  void GetLinkOptions(std::vector<std::string>& result,
                      const std::string& config,
                      const std::string& language) const;

428
429
430
431
  void GetLinkDepends(std::vector<std::string>& result,
                      const std::string& config,
                      const std::string& language) const;

432
  bool IsSystemIncludeDirectory(const std::string& dir,
433
434
                                const std::string& config,
                                const std::string& language) const;
435

436
  /** Add the target output files to the global generator manifest.  */
437
  void ComputeTargetManifest(const std::string& config) const;
438

439
440
  bool ComputeCompileFeatures(std::string const& config) const;

441
442
443
444
445
446
  /**
   * Trace through the source files in this target and add al source files
   * that they depend on, used by all generators
   */
  void TraceDependencies();

447
448
449
450
451
  /** 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.  */
  std::string GetDirectory(const std::string& config = "",
452
453
                           cmStateEnums::ArtifactType artifact =
                             cmStateEnums::RuntimeBinaryArtifact) const;
454

455
456
457
458
459
460
  /** Get the directory in which to place the target compiler .pdb file.
      If the configuration name is given then the generator will add its
      subdirectory for that configuration.  Otherwise just the canonical
      compiler pdb output directory is given.  */
  std::string GetCompilePDBDirectory(const std::string& config = "") const;

461
  /** Get sources that must be built before the given source.  */
462
463
  std::vector<cmSourceFile*> const* GetSourceDepends(
    cmSourceFile const* sf) const;
464

465
466
  /** Return whether this target uses the default value for its output
      directory.  */
467
468
  bool UsesDefaultOutputDir(const std::string& config,
                            cmStateEnums::ArtifactType artifact) const;
469

470
471
472
473
474
475
476
  // Cache target output paths for each configuration.
  struct OutputInfo
  {
    std::string OutDir;
    std::string ImpDir;
    std::string PdbDir;
    bool empty() const
477
478
479
    {
      return OutDir.empty() && ImpDir.empty() && PdbDir.empty();
    }
480
481
482
483
  };

  OutputInfo const* GetOutputInfo(const std::string& config) const;

484
  /** Get the name of the pdb file for the target.  */
485
  std::string GetPDBName(const std::string& config = "") const;
486

487
488
489
  /** Whether this library has soname enabled and platform supports it.  */
  bool HasSOName(const std::string& config) const;

490
491
492
493
494
495
496
497
498
499
  struct CompileInfo
  {
    std::string CompilePdbDir;
  };

  CompileInfo const* GetCompileInfo(const std::string& config) const;

  typedef std::map<std::string, CompileInfo> CompileInfoMapType;
  mutable CompileInfoMapType CompileInfoMap;

500
  bool IsNullImpliedByLinkLibraries(const std::string& p) const;
501

502
  /** Get the name of the compiler pdb file for the target.  */
503
  std::string GetCompilePDBName(const std::string& config = "") const;
504
505

  /** Get the path for the MSVC /Fd option for this target.  */
506
  std::string GetCompilePDBPath(const std::string& config = "") const;
507

508
  // Get the target base name.
509
510
  std::string GetOutputName(const std::string& config,
                            cmStateEnums::ArtifactType artifact) const;
511

512
  /** Clears cached meta data for local and external source files.
513
514
   * The meta data will be recomputed on demand.
   */
515
516
  void ClearSourcesCache();

517
518
519
  void AddSource(const std::string& src);
  void AddTracedSources(std::vector<std::string> const& srcs);

520
521
522
523
524
525
  /**
   * Adds an entry to the INCLUDE_DIRECTORIES list.
   * If before is true the entry is pushed at the front.
   */
  void AddIncludeDirectory(const std::string& src, bool before = false);

526
527
528
529
530
531
532
533
534
535
536
  /**
   * 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.
   */
  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"
537
538
539
    SourceFileTypeDeepResource,  // MACOSX_PACKAGE_LOCATION starts with
                                 // "Resources/"
    SourceFileTypeMacContent     // has MACOSX_PACKAGE_LOCATION!="Resources[/]"
540
541
542
  };
  struct SourceFileFlags
  {
543
544
    SourceFileFlags()
      : Type(SourceFileTypeNormal)
Daniel Pfeifer's avatar
Daniel Pfeifer committed
545
      , MacFolder(nullptr)
546
547
    {
    }
548
549
550
    SourceFileType Type;
    const char* MacFolder; // location inside Mac content folders
  };
551
  void GetAutoUicOptions(std::vector<std::string>& result,
552
553
                         const std::string& config) const;

554
555
556
557
558
559
  /** 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.  */
  void GetExecutableNames(std::string& name, std::string& realName,
                          std::string& impName, std::string& pdbName,
                          const std::string& config) const;
560

561
562
563
564
565
566
567
  /** 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.  */
  void GetLibraryNames(std::string& name, std::string& soName,
                       std::string& realName, std::string& impName,
                       std::string& pdbName, const std::string& config) const;

568
569
570
571
572
  /**
   * Compute whether this target must be relinked before installing.
   */
  bool NeedRelinkBeforeInstall(const std::string& config) const;

573
574
575
  /** Return true if builtin chrpath will work for this target */
  bool IsChrpathUsed(const std::string& config) const;

576
577
578
579
580
581
  /** 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.  */
  std::string GetPDBDirectory(const std::string& config) const;

582
  ///! Return the preferred linker language for this target
583
  std::string GetLinkerLanguage(const std::string& config) const;
584

585
  /** Does this target have a GNU implib to convert to MS format?  */
586
  bool HasImplibGNUtoMS(std::string const& config) const;
587
588
589

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

593
594
  bool IsExecutableWithExports() const;

595
  /** Return whether or not the target has a DLL import library.  */
596
  bool HasImportLibrary(std::string const& config) const;
597

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

601
602
603
  /** Return whether this target may be used to link another target.  */
  bool IsLinkable() const;

604
605
606
607
  /** Return whether this target is a shared library Framework on
      Apple.  */
  bool IsFrameworkOnApple() const;

608
609
610
  /** Return whether this target is an executable Bundle on Apple.  */
  bool IsAppBundleOnApple() const;

611
612
613
  /** Return whether this target is a XCTest on Apple.  */
  bool IsXCTestOnApple() const;

614
615
616
  /** Return whether this target is a CFBundle (plugin) on Apple.  */
  bool IsCFBundleOnApple() const;

617
618
619
620
621
622
623
624
625
626
627
628
629
  /** Assembly types. The order of the values of this enum is relevant
      because of smaller/larger comparison operations! */
  enum ManagedType
  {
    Undefined = 0, // target is no lib or executable
    Native,        // target compiles to unmanaged binary.
    Mixed,         // target compiles to mixed (managed and unmanaged) binary.
    Managed        // target compiles to managed binary.
  };

  /** Return the type of assembly this target compiles to. */
  ManagedType GetManagedType(const std::string& config) const;

630
631
  struct SourceFileFlags GetTargetSourceFileFlags(
    const cmSourceFile* sf) const;
632

633
634
635
  void ReportPropertyOrigin(const std::string& p, const std::string& result,
                            const std::string& report,
                            const std::string& compatibilityType) const;
636

637
638
  class TargetPropertyEntry;

639
640
  bool HaveInstallTreeRPATH() const;

641
642
643
644
645
646
  /** Whether this library has \@rpath and platform supports it.  */
  bool HasMacOSXRpathInstallNameDir(const std::string& config) const;

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

647
648
649
650
651
652
653
654
655
656
  enum InstallNameType
  {
    INSTALL_NAME_FOR_BUILD,
    INSTALL_NAME_FOR_INSTALL
  };
  /** Whether to use INSTALL_NAME_DIR. */
  bool MacOSXUseInstallNameDir() const;
  /** Whether to generate an install_name. */
  bool CanGenerateInstallNameDir(InstallNameType t) const;

657
658
659
660
  /** Test for special case of a third-party shared library that has
      no soname at all.  */
  bool IsImportedSharedLibWithoutSOName(const std::string& config) const;

661
  std::string ImportedGetLocation(const std::string& config) const;
662

663
664
665
666
667
668
669
670
  /** 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.  */
  void GetTargetVersion(int& major, int& minor) const;

  /** 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.  */
671
672
  void GetTargetVersion(bool soversion, int& major, int& minor,
                        int& patch) const;
673

674
  std::string GetFortranModuleDirectory(std::string const& working_dir) const;
675

676
677
  const char* GetSourcesProperty() const;

678
private:
679
680
  void AddSourceCommon(const std::string& src);

681
682
  std::string CreateFortranModuleDirectory(
    std::string const& working_dir) const;
683
684
685
  mutable bool FortranModuleDirectoryCreated;
  mutable std::string FortranModuleDirectory;

686
  friend class cmTargetTraceDependencies;
687
688
689
690
  struct SourceEntry
  {
    std::vector<cmSourceFile*> Depends;
  };
691
  typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
692
  SourceEntriesType SourceDepends;
693
  mutable std::map<cmSourceFile const*, std::string> Objects;
694
  std::set<cmSourceFile const*> ExplicitObjectName;
695
  mutable std::map<std::string, std::vector<std::string>> SystemIncludesCache;
696

697
698
  mutable std::string ExportMacro;

699
700
701
702
  void ConstructSourceFileFlags() const;
  mutable bool SourceFileFlagsConstructed;
  mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;

703
704
  mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;

705
  std::string GetFullNameInternal(const std::string& config,
706
707
708
                                  cmStateEnums::ArtifactType artifact) const;
  void GetFullNameInternal(const std::string& config,
                           cmStateEnums::ArtifactType artifact,
709
710
711
                           std::string& outPrefix, std::string& outBase,
                           std::string& outSuffix) const;

712
713
714
  typedef std::map<std::string, LinkClosure> LinkClosureMapType;
  mutable LinkClosureMapType LinkClosureMap;

715
  // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
716
  const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const;
717

718
719
  void ComputeVersionedName(std::string& vName, std::string const& prefix,
                            std::string const& base, std::string const& suffix,
720
721
722
                            std::string const& name,
                            const char* version) const;

723
724
725
726
727
728
729
  struct CompatibleInterfacesBase
  {
    std::set<std::string> PropsBool;
    std::set<std::string> PropsString;
    std::set<std::string> PropsNumberMax;
    std::set<std::string> PropsNumberMin;
  };
730
731
  CompatibleInterfacesBase const& GetCompatibleInterfaces(
    std::string const& config) const;
732

733
  struct CompatibleInterfaces : public CompatibleInterfacesBase
734
  {
735
736
737
738
    CompatibleInterfaces()
      : Done(false)
    {
    }
739
740
741
742
    bool Done;
  };
  mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;

743
  typedef std::map<std::string, cmComputeLinkInformation*>
744
    cmTargetLinkInformationMap;
745
746
  mutable cmTargetLinkInformationMap LinkInformation;

747
  void CheckPropertyCompatibility(cmComputeLinkInformation* info,
748
749
                                  const std::string& config) const;

750
  struct LinkImplClosure : public std::vector<cmGeneratorTarget const*>
751
  {
752
753
754
755
    LinkImplClosure()
      : Done(false)
    {
    }
756
757
758
759
    bool Done;
  };
  mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap;

760
  typedef std::map<std::string, cmHeadToLinkInterfaceMap> LinkInterfaceMapType;
761
762
763
  mutable LinkInterfaceMapType LinkInterfaceMap;
  mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap;

764
765
  cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap(
    std::string const& config) const;
766
  cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap(
767
    std::string const& config) const;
768

769
770
771
  // Cache import information from properties for each configuration.
  struct ImportInfo
  {
772
773
    ImportInfo()
      : NoSOName(false)
774
      , Managed(Native)
775
776
777
      , Multiplicity(0)
    {
    }
778
    bool NoSOName;
779
    ManagedType Managed;
780
    unsigned int Multiplicity;
781
782
783
    std::string Location;
    std::string SOName;
    std::string ImportLibrary;
784
    std::string LibName;
785
786
787
788
789
790
791
792
793
794
795
796
    std::string Languages;
    std::string Libraries;
    std::string LibrariesProp;
    std::string SharedDeps;
  };

  typedef std::map<std::string, ImportInfo> ImportInfoMapType;
  mutable ImportInfoMapType ImportInfoMap;
  void ComputeImportInfo(std::string const& desired_config,
                         ImportInfo& info) const;
  ImportInfo const* GetImportInfo(const std::string& config) const;

797
798
799
  /** Strip off leading and trailing whitespace from an item named in
      the link dependencies of this target.  */
  std::string CheckCMP0004(std::string const& item) const;
800

801
802
803
  cmLinkInterface const* GetImportLinkInterface(
    const std::string& config, const cmGeneratorTarget* head,
    bool usage_requirements_only) const;
804

805
806
807
808
  typedef std::map<std::string, KindedSources> KindedSourcesMapType;
  mutable KindedSourcesMapType KindedSourcesMap;
  void ComputeKindedSources(KindedSources& files,
                            std::string const& config) const;
809

810
811
812
  mutable std::vector<AllConfigSource> AllConfigSources;
  void ComputeAllConfigSources() const;

813
  std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
814
  std::vector<TargetPropertyEntry*> CompileOptionsEntries;
815
  std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
816
  std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
817
  std::vector<TargetPropertyEntry*> LinkOptionsEntries;
818
  std::vector<TargetPropertyEntry*> SourceEntries;
819
  mutable std::set<std::string> LinkImplicitNullProperties;
820

821
  void ExpandLinkItems(std::string const& prop, std::string const& value,
822
823
                       std::string const& config,
                       const cmGeneratorTarget* headTarget,
824
825
826
827
828
829
                       bool usage_requirements_only,
                       std::vector<cmLinkItem>& items,
                       bool& hadHeadSensitiveCondition) const;
  void LookupLinkItems(std::vector<std::string> const& names,
                       std::vector<cmLinkItem>& items) const;

830
831
832
  void GetSourceFiles(std::vector<std::string>& files,
                      const std::string& config) const;

833
834
835
836
837
  struct HeadToLinkImplementationMap
    : public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation>
  {
  };
  typedef std::map<std::string, HeadToLinkImplementationMap> LinkImplMapType;
838
839
  mutable LinkImplMapType LinkImplMap;

840
841
  cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
    const std::string& config, const cmGeneratorTarget* head) const;
842
843
  bool ComputeOutputDir(const std::string& config,
                        cmStateEnums::ArtifactType artifact,
844
                        std::string& out) const;
845
846
847

  typedef std::map<std::string, OutputInfo> OutputInfoMapType;
  mutable OutputInfoMapType OutputInfoMap;
848

849
850
851
852
853
854
  typedef std::map<std::string, ModuleDefinitionInfo>
    ModuleDefinitionInfoMapType;
  mutable ModuleDefinitionInfoMapType ModuleDefinitionInfoMap;
  void ComputeModuleDefinitionInfo(std::string const& config,
                                   ModuleDefinitionInfo& info) const;

855
  typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey;
856
857
  typedef std::map<OutputNameKey, std::string> OutputNameMapType;
  mutable OutputNameMapType OutputNameMap;
858
  mutable std::set<cmLinkItem> UtilityItems;
859
  cmPolicies::PolicyMap PolicyMap;
860
  mutable bool PolicyWarnedCMP0022;
861
  mutable bool PolicyReportedCMP0069;
862
  mutable bool DebugIncludesDone;
863
  mutable bool DebugCompileOptionsDone;
864
  mutable bool DebugCompileFeaturesDone;
865
  mutable bool DebugCompileDefinitionsDone;
866
  mutable bool DebugLinkOptionsDone;
867
868
  mutable bool DebugSourcesDone;
  mutable bool LinkImplementationLanguageIsContextDependent;
869
  mutable bool UtilityItemsDone;
870
  bool DLLPlatform;
871

872
873
874
  bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
                           std::string& out) const;

875
876
  ManagedType CheckManagedType(std::string const& propval) const;

877
public:
878
879
  const std::vector<const cmGeneratorTarget*>& GetLinkImplementationClosure(
    const std::string& config) const;
880

881
  mutable std::map<std::string, std::string> MaxLanguageStandards;
882
  std::map<std::string, std::string> const& GetMaxLanguageStandards() const
883
884
885
  {
    return this->MaxLanguageStandards;
  }
886

887
888
  struct StrictTargetComparison
  {
889
890
891
    bool operator()(cmGeneratorTarget const* t1,
                    cmGeneratorTarget const* t2) const;
  };
892
893
894
};

#endif