~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Source/cmTarget.h

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*=========================================================================
2
 
 
3
 
  Program:   CMake - Cross-Platform Makefile Generator
4
 
  Module:    $RCSfile: cmTarget.h,v $
5
 
  Language:  C++
6
 
  Date:      $Date: 2009-01-13 18:03:53 $
7
 
  Version:   $Revision: 1.109.2.8 $
8
 
 
9
 
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
10
 
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
11
 
 
12
 
     This software is distributed WITHOUT ANY WARRANTY; without even
13
 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
 
     PURPOSE.  See the above copyright notices for more information.
15
 
 
16
 
=========================================================================*/
 
1
/*============================================================================
 
2
  CMake - Cross Platform Makefile Generator
 
3
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
 
4
 
 
5
  Distributed under the OSI-approved BSD License (the "License");
 
6
  see accompanying file Copyright.txt for details.
 
7
 
 
8
  This software is distributed WITHOUT ANY WARRANTY; without even the
 
9
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
10
  See the License for more information.
 
11
============================================================================*/
17
12
#ifndef cmTarget_h
18
13
#define cmTarget_h
19
14
 
21
16
#include "cmPropertyMap.h"
22
17
#include "cmPolicies.h"
23
18
 
 
19
#include <cmsys/auto_ptr.hxx>
 
20
 
24
21
class cmake;
25
22
class cmMakefile;
26
23
class cmSourceFile;
37
34
  ~cmTargetLinkInformationMap();
38
35
};
39
36
 
40
 
struct cmTargetLinkInterface
41
 
{
42
 
  // Libraries listed in the interface.
43
 
  std::vector<std::string> Libraries;
44
 
 
45
 
  // Shared library dependencies needed for linking on some platforms.
46
 
  std::vector<std::string> SharedDeps;
47
 
};
48
 
 
49
 
struct cmTargetLinkInterfaceMap:
50
 
  public std::map<cmStdString, cmTargetLinkInterface*>
51
 
{
52
 
  typedef std::map<cmStdString, cmTargetLinkInterface*> derived;
53
 
  cmTargetLinkInterfaceMap() {}
54
 
  cmTargetLinkInterfaceMap(cmTargetLinkInterfaceMap const& r);
55
 
  ~cmTargetLinkInterfaceMap();
56
 
};
57
 
 
58
37
class cmTargetInternals;
59
38
class cmTargetInternalPointer
60
39
{
64
43
  ~cmTargetInternalPointer();
65
44
  cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r);
66
45
  cmTargetInternals* operator->() const { return this->Pointer; }
 
46
  cmTargetInternals* Get() const { return this->Pointer; }
67
47
private:
68
48
  cmTargetInternals* Pointer;
69
49
};
135
115
  /**
136
116
   * Get the list of the source files used by this target
137
117
   */
138
 
  std::vector<cmSourceFile*> const &GetSourceFiles()
139
 
    {return this->SourceFiles;}
140
 
  void AddSourceFile(cmSourceFile* sf) { this->SourceFiles.push_back(sf); }
 
118
  std::vector<cmSourceFile*> const& GetSourceFiles();
 
119
  void AddSourceFile(cmSourceFile* sf);
 
120
 
 
121
  /** Get sources that must be built before the given source.  */
 
122
  std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf);
141
123
 
142
124
  /**
143
125
   * Flags for a given source file as used in this target. Typically assigned
201
183
                      const char *target, const char* lib,
202
184
                      LinkLibraryType llt);
203
185
 
204
 
  void AddLinkLibrary(const std::string& lib,
205
 
                      LinkLibraryType llt);
206
 
 
207
186
  void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
208
187
                           const LinkLibraryVectorType& libs );
209
188
 
240
219
  ///! Get the utilities used by this target
241
220
  std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
242
221
 
243
 
  void AnalyzeLibDependencies( const cmMakefile& mf );
 
222
  /** Finalize the target at the end of the Configure step.  */
 
223
  void FinishConfigure();
244
224
 
245
225
  ///! Set/Get a property of this target file
246
226
  void SetProperty(const char *prop, const char *value);
250
230
  bool GetPropertyAsBool(const char *prop);
251
231
  void CheckProperty(const char* prop, cmMakefile* context);
252
232
 
 
233
  const char* GetFeature(const char* feature, const char* config);
 
234
 
253
235
  bool IsImported() const {return this->IsImportedTarget;}
254
236
 
255
 
  /** Get the library interface dependencies.  This is the set of
256
 
      libraries from which something that links to this target may
257
 
      also receive symbols.  Returns 0 if the user has not specified
258
 
      such dependencies or for static libraries.  */
259
 
  cmTargetLinkInterface const* GetLinkInterface(const char* config);
 
237
  /** The link interface specifies transitive library dependencies and
 
238
      other information needed by targets that link to this target.  */
 
239
  struct LinkInterface
 
240
  {
 
241
    // Languages whose runtime libraries must be linked.
 
242
    std::vector<std::string> Languages;
 
243
 
 
244
    // Libraries listed in the interface.
 
245
    std::vector<std::string> Libraries;
 
246
 
 
247
    // Shared library dependencies needed for linking on some platforms.
 
248
    std::vector<std::string> SharedDeps;
 
249
 
 
250
    // Number of repetitions of a strongly connected component of two
 
251
    // or more static libraries.
 
252
    int Multiplicity;
 
253
 
 
254
    // Libraries listed for other configurations.
 
255
    // Needed only for OLD behavior of CMP0003.
 
256
    std::vector<std::string> WrongConfigLibraries;
 
257
 
 
258
    LinkInterface(): Multiplicity(0) {}
 
259
  };
 
260
 
 
261
  /** Get the link interface for the given configuration.  Returns 0
 
262
      if the target cannot be linked.  */
 
263
  LinkInterface const* GetLinkInterface(const char* config);
 
264
 
 
265
  /** The link implementation specifies the direct library
 
266
      dependencies needed by the object files of the target.  */
 
267
  struct LinkImplementation
 
268
  {
 
269
    // Languages whose runtime libraries must be linked.
 
270
    std::vector<std::string> Languages;
 
271
 
 
272
    // Libraries linked directly in this configuration.
 
273
    std::vector<std::string> Libraries;
 
274
 
 
275
    // Libraries linked directly in other configurations.
 
276
    // Needed only for OLD behavior of CMP0003.
 
277
    std::vector<std::string> WrongConfigLibraries;
 
278
  };
 
279
  LinkImplementation const* GetLinkImplementation(const char* config);
 
280
 
 
281
  /** Link information from the transitive closure of the link
 
282
      implementation and the interfaces of its dependencies.  */
 
283
  struct LinkClosure
 
284
  {
 
285
    // The preferred linker language.
 
286
    std::string LinkerLanguage;
 
287
 
 
288
    // Languages whose runtime libraries must be linked.
 
289
    std::vector<std::string> Languages;
 
290
  };
 
291
  LinkClosure const* GetLinkClosure(const char* config);
 
292
 
 
293
  /** Strip off leading and trailing whitespace from an item named in
 
294
      the link dependencies of this target.  */
 
295
  std::string CheckCMP0004(std::string const& item);
260
296
 
261
297
  /** Get the directory in which this target will be built.  If the
262
298
      configuration name is given then the generator will add its
291
327
  bool FindSourceFiles();
292
328
 
293
329
  ///! Return the prefered linker language for this target
294
 
  const char* GetLinkerLanguage(cmGlobalGenerator*);
 
330
  const char* GetLinkerLanguage(const char* config = 0);
295
331
 
296
332
  ///! Return the rule variable used to create this type of target,
297
333
  //  need to add CMAKE_(LANG) for full name.
326
362
                       std::string& realName, std::string& impName,
327
363
                       std::string& pdbName, const char* config);
328
364
 
329
 
  /** Get the names of the library used to remove existing copies of
330
 
      the library from the build tree either before linking or during
331
 
      a clean step.  This should be called only on a library
332
 
      target.  */
333
 
  void GetLibraryCleanNames(std::string& staticName,
334
 
                            std::string& sharedName,
335
 
                            std::string& sharedSOName,
336
 
                            std::string& sharedRealName,
337
 
                            std::string& importName,
338
 
                            std::string& pdbName,
339
 
                            const char* config);
340
 
 
341
365
  /** Get the names of the executable needed to generate a build rule
342
366
      that takes into account executable version numbers.  This should
343
367
      be called only on an executable target.  */
345
369
                          std::string& impName,
346
370
                          std::string& pdbName, const char* config);
347
371
 
348
 
  /** Get the names of the executable used to remove existing copies
349
 
      of the executable from the build tree either before linking or
350
 
      during a clean step.  This should be called only on an
351
 
      executable target.  */
352
 
  void GetExecutableCleanNames(std::string& name, std::string& realName,
353
 
                               std::string& impName,
354
 
                               std::string& pdbName, const char* config);
355
 
 
356
372
  /** Add the target output files to the global generator manifest.  */
357
373
  void GenerateTargetManifest(const char* config);
358
374
 
359
375
  /**
360
376
   * Compute whether this target must be relinked before installing.
361
377
   */
362
 
  bool NeedRelinkBeforeInstall();
 
378
  bool NeedRelinkBeforeInstall(const char* config);
363
379
 
364
380
  bool HaveBuildTreeRPATH();
365
381
  bool HaveInstallTreeRPATH();
366
382
 
367
383
  /** Return true if builtin chrpath will work for this target */
368
 
  bool IsChrpathUsed();
 
384
  bool IsChrpathUsed(const char* config);
369
385
 
370
386
  std::string GetInstallNameDirForBuildTree(const char* config,
371
387
                                            bool for_xcode = false);
401
417
  /** Return whether this target may be used to link another target.  */
402
418
  bool IsLinkable();
403
419
 
 
420
  /** Return whether or not the target is for a DLL platform.  */
 
421
  bool IsDLLPlatform() { return this->DLLPlatform; }
 
422
 
 
423
  /** Return whether or not the target has a DLL import library.  */
 
424
  bool HasImportLibrary();
 
425
 
404
426
  /** Return whether this target is a shared library Framework on
405
427
      Apple.  */
406
428
  bool IsFrameworkOnApple();
415
437
  /** Get a backtrace from the creation of the target.  */
416
438
  cmListFileBacktrace const& GetBacktrace() const;
417
439
 
 
440
  /** Get a build-tree directory in which to place target support files.  */
 
441
  std::string GetSupportDirectory() const;
 
442
 
418
443
private:
419
444
  /**
420
445
   * A list of direct dependencies. Use in conjunction with DependencyMap.
465
490
                           const LibraryID& lib,
466
491
                           DependencyMap& dep_map);
467
492
 
468
 
  const char* GetSuffixVariableInternal(TargetType type, bool implib);
469
 
  const char* GetPrefixVariableInternal(TargetType type, bool implib);
470
 
  std::string GetFullNameInternal(TargetType type, const char* config,
471
 
                                  bool implib);
472
 
  void GetFullNameInternal(TargetType type, const char* config, bool implib,
 
493
  void AnalyzeLibDependencies( const cmMakefile& mf );
 
494
 
 
495
  const char* GetSuffixVariableInternal(bool implib);
 
496
  const char* GetPrefixVariableInternal(bool implib);
 
497
  std::string GetFullNameInternal(const char* config, bool implib);
 
498
  void GetFullNameInternal(const char* config, bool implib,
473
499
                           std::string& outPrefix, std::string& outBase,
474
500
                           std::string& outSuffix);
475
501
 
476
 
  void GetLibraryNamesInternal(std::string& name,
477
 
                               std::string& soName,
478
 
                               std::string& realName,
479
 
                               std::string& impName,
480
 
                               std::string& pdbName,
481
 
                               TargetType type,
482
 
                               const char* config);
483
 
  void GetExecutableNamesInternal(std::string& name,
484
 
                                  std::string& realName,
485
 
                                  std::string& impName,
486
 
                                  std::string& pdbName,
487
 
                                  TargetType type,
488
 
                                  const char* config);
489
 
 
490
502
  // Use a makefile variable to set a default for the given property.
491
503
  // If the variable is not defined use the given default instead.
492
504
  void SetPropertyDefault(const char* property, const char* default_value);
493
505
 
494
 
  // Get the full path to the target output directory.
495
 
  std::string GetOutputDir(bool implib);
496
 
  std::string const& ComputeBaseOutputDir(bool implib);
 
506
  // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
 
507
  const char* GetOutputTargetType(bool implib);
 
508
 
 
509
  // Get the target base name.
 
510
  std::string GetOutputName(const char* config, bool implib);
497
511
 
498
512
  const char* ImportedGetLocation(const char* config);
499
513
  const char* NormalGetLocation(const char* config);
526
540
  bool HaveInstallRule;
527
541
  std::string InstallPath;
528
542
  std::string RuntimeInstallPath;
529
 
  std::string BaseOutputDir;
530
 
  std::string BaseOutputDirImplib;
531
543
  std::string Location;
532
544
  std::string ExportMacro;
533
545
  std::set<cmStdString> Utilities;
537
549
  bool DLLPlatform;
538
550
  bool IsImportedTarget;
539
551
 
 
552
  // Cache target output paths for each configuration.
 
553
  struct OutputInfo;
 
554
  OutputInfo const* GetOutputInfo(const char* config);
 
555
  void ComputeOutputDir(const char* config, bool implib, std::string& out);
 
556
 
540
557
  // Cache import information from properties for each configuration.
541
 
  struct ImportInfo
542
 
  {
543
 
    bool NoSOName;
544
 
    std::string Location;
545
 
    std::string SOName;
546
 
    std::string ImportLibrary;
547
 
    cmTargetLinkInterface LinkInterface;
548
 
  };
549
 
  typedef std::map<cmStdString, ImportInfo> ImportInfoMapType;
550
 
  ImportInfoMapType ImportInfoMap;
 
558
  struct ImportInfo;
551
559
  ImportInfo const* GetImportInfo(const char* config);
552
560
  void ComputeImportInfo(std::string const& desired_config, ImportInfo& info);
553
561
 
554
562
  cmTargetLinkInformationMap LinkInformation;
555
563
 
556
 
  // Link interface.
557
 
  cmTargetLinkInterface* ComputeLinkInterface(const char* config);
558
 
  cmTargetLinkInterfaceMap LinkInterface;
 
564
  bool ComputeLinkInterface(const char* config, LinkInterface& iface);
 
565
 
 
566
  void ComputeLinkImplementation(const char* config,
 
567
                                 LinkImplementation& impl);
 
568
  void ComputeLinkClosure(const char* config, LinkClosure& lc);
 
569
 
 
570
  void ClearLinkMaps();
 
571
 
 
572
  void MaybeInvalidatePropertyCache(const char* prop);
559
573
 
560
574
  // The cmMakefile instance that owns this target.  This should
561
575
  // always be set.