cmMakefile.h 37.7 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
#ifndef cmMakefile_h
#define cmMakefile_h
14

15
#include "cmExecutionStatus.h"
16
#include "cmListFileCache.h"
17
#include "cmPolicies.h"
18
#include "cmPropertyMap.h"
19
20
#include "cmSystemTools.h"
#include "cmTarget.h"
21
#include "cmNewLineStyle.h"
22
#include "cmGeneratorTarget.h"
23
#include "cmExpandedCommandArgument.h"
Bill Hoffman's avatar
Bill Hoffman committed
24
#include "cmake.h"
25

26
27
28
29
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmSourceGroup.h"
#endif

30
#include <cmsys/auto_ptr.hxx>
31
#include <cmsys/RegularExpression.hxx>
32
33
34
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include <cmsys/hash_map.hxx>
#endif
35

36
#include <stack>
37
#include <deque>
38

39
class cmFunctionBlocker;
40
class cmCommand;
41
class cmInstallGenerator;
Ken Martin's avatar
Ken Martin committed
42
class cmLocalGenerator;
43
class cmMakeDepend;
44
class cmSourceFile;
45
class cmTest;
46
class cmTestGenerator;
47
class cmVariableWatch;
48
class cmake;
49
class cmMakefileCall;
50
class cmCMakePolicyCommand;
51

52
53
54
55
/** \class cmMakefile
 * \brief Process the input CMakeLists.txt file.
 *
 * Process and store into memory the input CMakeLists.txt file.
56
 * Each CMakeLists.txt file is parsed and the commands found there
57
58
 * are added into the build process.
 */
59
60
class cmMakefile
{
61
62
  class Internals;
  cmsys::auto_ptr<Internals> Internal;
63
public:
64
65
  /* Check for unused variables in this scope */
  void CheckForUnusedVariables() const;
66
  /* Mark a variable as used */
67
  void MarkVariableAsUsed(const std::string& var);
68
  /* return true if a variable has been initialized */
69
  bool VariableInitialized(const std::string& ) const;
Ben Boeckel's avatar
Ben Boeckel committed
70
  /* return true if a variable has been used */
71
  bool VariableUsed(const std::string& ) const;
72

73
74
75
  /**
   * Construct an empty makefile.
   */
Ken Martin's avatar
Ken Martin committed
76
  cmMakefile();
77
  cmMakefile(const cmMakefile& mf);
78
79
80
81

  /**
   * Destructor.
   */
Ken Martin's avatar
Ken Martin committed
82
  ~cmMakefile();
83
84
85
86

  /**
   * Read and parse a CMakeLists.txt file.
   */
87
88
  bool ReadListFile(const char* listfile,
                    const char* external= 0,
89
90
                    std::string* fullPath= 0,
                    bool noPolicyScope = true);
91

92
93
94
  /**
   * Add a function blocker to this makefile
   */
95
  void AddFunctionBlocker(cmFunctionBlocker* fb);
96
97
98
99
100
101

  /**
   * Remove the function blocker whose scope ends with the given command.
   * This returns ownership of the function blocker object.
   */
  cmsys::auto_ptr<cmFunctionBlocker>
102
  RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
103

104
105
106
107
108
109
110
111
112
113
114
115
116
  /** Push/pop a lexical (function blocker) barrier automatically.  */
  class LexicalPushPop
  {
  public:
    LexicalPushPop(cmMakefile* mf);
    ~LexicalPushPop();
    void Quiet() { this->ReportError = false; }
  private:
    cmMakefile* Makefile;
    bool ReportError;
  };
  friend class LexicalPushPop;

117
118
119
120
121
122
123
124
125
  class LoopBlockPop
  {
  public:
    LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
    ~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
  private:
    cmMakefile* Makefile;
  };

126
127
128
129
  /**
   * Try running cmake and building a file. This is used for dynalically
   * loaded commands, not as part of the usual build process.
   */
130
  int TryCompile(const std::string& srcdir, const std::string& bindir,
131
                 const std::string& projectName, const std::string& targetName,
132
                 bool fast,
133
                 const std::vector<std::string> *cmakeArgs,
134
                 std::string& output);
135

136
137
  bool GetIsSourceFileTryCompile() const;

138
139
140
141
142
  /**
   * Specify the makefile generator. This is platform/compiler
   * dependent, although the interface is through a generic
   * superclass.
   */
Ken Martin's avatar
Ken Martin committed
143
  void SetLocalGenerator(cmLocalGenerator*);
144

145
  ///! Get the current makefile generator.
146
  cmLocalGenerator* GetLocalGenerator() const
Ken Martin's avatar
Ken Martin committed
147
    { return this->LocalGenerator;}
148

149
150
151
  /**
   * Help enforce global target name uniqueness.
   */
152
  bool EnforceUniqueName(std::string const& name, std::string& msg,
153
                         bool isCustom = false) const;
154

155
  /**
156
   * Perform FinalPass, Library dependency analysis etc before output of the
157
   * makefile.
158
   */
159
  void ConfigureFinalPass();
160

161
162
163
164
  /**
   * run the final pass on all commands.
   */
  void FinalPass();
165

166
167
168
  /**
   * Print the object state to std::cout.
   */
169
  void Print() const;
170
171

  /** Add a custom command to the build.  */
172
  void AddCustomCommandToTarget(const std::string& target,
173
                                const std::vector<std::string>& byproducts,
174
175
176
                                const std::vector<std::string>& depends,
                                const cmCustomCommandLines& commandLines,
                                cmTarget::CustomCommandType type,
177
                                const char* comment, const char* workingDir,
178
                                bool escapeOldStyle = true,
179
                                bool uses_terminal = false);
180
181
  cmSourceFile* AddCustomCommandToOutput(
    const std::vector<std::string>& outputs,
182
    const std::vector<std::string>& byproducts,
183
    const std::vector<std::string>& depends,
184
    const std::string& main_dependency,
185
186
187
    const cmCustomCommandLines& commandLines,
    const char* comment, const char* workingDir,
    bool replace = false,
188
189
    bool escapeOldStyle = true,
    bool uses_terminal = false);
190
  cmSourceFile* AddCustomCommandToOutput(
191
    const std::string& output,
192
    const std::vector<std::string>& depends,
193
    const std::string& main_dependency,
194
195
196
    const cmCustomCommandLines& commandLines,
    const char* comment, const char* workingDir,
    bool replace = false,
197
198
    bool escapeOldStyle = true,
    bool uses_terminal = false);
199
  void AddCustomCommandOldStyle(const std::string& target,
200
201
                                const std::vector<std::string>& outputs,
                                const std::vector<std::string>& depends,
202
                                const std::string& source,
203
204
205
                                const cmCustomCommandLines& commandLines,
                                const char* comment);

206
207
208
  /**
   * Add a define flag to the build.
   */
209
  void AddDefineFlag(const char* definition);
210
  void RemoveDefineFlag(const char* definition);
211
  void AddCompileOption(const char* option);
212

213
  /** Create a new imported target with the name and type given.  */
214
215
  cmTarget* AddImportedTarget(const std::string& name,
                              cmTarget::TargetType type,
216
                              bool global);
217

218
  cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name);
219

220
221
222
  /**
   * Add an executable to the build.
   */
223
  cmTarget* AddExecutable(const char *exename,
224
                          const std::vector<std::string> &srcs,
Ken Martin's avatar
Ken Martin committed
225
                          bool excludeFromAll = false);
226

227
  /**
228
229
   * Add a utility to the build.  A utiltity target is a command that
   * is run every time the target is built.
230
   */
231
  void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll,
232
                         const std::vector<std::string>& depends,
233
                         const char* workingDirectory,
234
                         const char* command,
235
236
                         const char* arg1=0,
                         const char* arg2=0,
Andy Cedilnik's avatar
Andy Cedilnik committed
237
238
                         const char* arg3=0,
                         const char* arg4=0);
239
240
  cmTarget* AddUtilityCommand(const std::string& utilityName,
                              bool excludeFromAll,
241
242
243
244
                              const char* workingDirectory,
                              const std::vector<std::string>& depends,
                              const cmCustomCommandLines& commandLines,
                              bool escapeOldStyle = true,
245
246
                              const char* comment = 0,
                              bool uses_terminal = false);
247
248
249
250
251
252
253
254
255
  cmTarget* AddUtilityCommand(const std::string& utilityName,
                              bool excludeFromAll,
                              const char* workingDirectory,
                              const std::vector<std::string>& byproducts,
                              const std::vector<std::string>& depends,
                              const cmCustomCommandLines& commandLines,
                              bool escapeOldStyle = true,
                              const char* comment = 0,
                              bool uses_terminal = false);
256

257
258
259
  /**
   * Add a link library to the build.
   */
260
261
262
  void AddLinkLibrary(const std::string&);
  void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
  void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
263
                               cmTarget::LinkLibraryType type);
264
  void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
265
266
267
268

  /**
   * Add a link directory to the build.
   */
269
  void AddLinkDirectory(const std::string&);
270

271
272
  const std::vector<std::string>& GetLinkDirectories() const
    {
Ken Martin's avatar
Ken Martin committed
273
      return this->LinkDirectories;
274
275
276
    }
  void SetLinkDirectories(const std::vector<std::string>& vec)
    {
Ken Martin's avatar
Ken Martin committed
277
      this->LinkDirectories = vec;
278
279
    }

280
281
282
  /**
   * Add a subdirectory to the build.
   */
283
  void AddSubDirectory(const std::string&, bool excludeFromAll=false);
284
285
  void AddSubDirectory(const std::string& fullSrcDir,
                       const std::string& fullBinDir,
286
                       bool excludeFromAll,
287
                       bool immediate);
288

289
290
291
292
  /**
   * Configure a subdirectory
   */
  void ConfigureSubDirectory(cmLocalGenerator *);
293

294
295
296
  /**
   * Add an include directory to the build.
   */
297
298
  void AddIncludeDirectories(const std::vector<std::string> &incs,
                             bool before = false);
299
300
301
302
303

  /**
   * Add a variable definition to the build. This variable
   * can be used in CMake to refer to lists, directories, etc.
   */
304
  void AddDefinition(const std::string& name, const char* value);
305
  ///! Add a definition to this makefile and the global cmake cache.
306
  void AddCacheDefinition(const std::string& name, const char* value,
307
                          const char* doc,
308
309
                          cmCacheManager::CacheEntryType type,
                          bool force = false);
310

311
  /**
312
   * Add bool variable definition to the build.
313
   */
314
  void AddDefinition(const std::string& name, bool);
315

316
317
318
319
  /**
   * Remove a variable definition from the build.  This is not valid
   * for cache entries, and will only affect the current makefile.
   */
320
  void RemoveDefinition(const std::string& name);
Brad King's avatar
Brad King committed
321
  ///! Remove a definition from the cache.
322
  void RemoveCacheDefinition(const std::string& name);
323

324
325
326
  /**
   * Specify the name of the project for this build.
   */
327
  void SetProjectName(const char*);
328
329
330
331

  /**
   * Get the name of the project for this build.
   */
Alexander Neundorf's avatar
   
Alexander Neundorf committed
332
  const char* GetProjectName() const
333
    {
Ken Martin's avatar
Ken Martin committed
334
      return this->ProjectName.c_str();
335
    }
336
337

  /** Get the configurations to be generated.  */
338
  std::string GetConfigurations(std::vector<std::string>& configs,
339
340
                                bool single = true) const;

341
342
343
  /**
   * Set the name of the library.
   */
344
  cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type,
345
                  const std::vector<std::string> &srcs,
Ken Martin's avatar
Ken Martin committed
346
                  bool excludeFromAll = false);
347
  void AddAlias(const std::string& libname, cmTarget *tgt);
348

349
#if defined(CMAKE_BUILD_WITH_CMAKE)
350
  /**
351
   * Add a root source group for consideration when adding a new source.
352
   */
353
  void AddSourceGroup(const std::string& name, const char* regex=0);
354
355
356
357
358

  /**
   * Add a source group for consideration when adding a new source.
   * name is tokenized.
   */
359
  void AddSourceGroup(const std::vector<std::string>& name,
Alexander Neundorf's avatar
   
Alexander Neundorf committed
360
                      const char* regex=0);
361

362
#endif
363
364
365

  //@{
  /**
366
     * Set, Push, Pop policy values for CMake.
367
368
369
     */
  bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
  bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
370
  cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
371
  bool SetPolicyVersion(const char *version);
372
  void RecordPolicies(cmPolicies::PolicyMap& pm);
373
374
  //@}

375
376
377
378
  /** Helper class to push and pop policies automatically.  */
  class PolicyPushPop
  {
  public:
379
380
381
    PolicyPushPop(cmMakefile* m,
                  bool weak = false,
                  cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
382
    ~PolicyPushPop();
Brad King's avatar
Brad King committed
383
    void Quiet() { this->ReportError = false; }
384
385
  private:
    cmMakefile* Makefile;
Brad King's avatar
Brad King committed
386
    bool ReportError;
387
388
389
  };
  friend class PolicyPushPop;

390
391
392
  /**
    * Get the Policies Instance
    */
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
  cmPolicies *GetPolicies() const;

  struct cmCMP0054Id
  {
    cmCMP0054Id(cmListFileContext const& context):
        Context(context)
    {

    }

    bool operator< (cmCMP0054Id const& id) const
    {
      if(this->Context.FilePath != id.Context.FilePath)
        return this->Context.FilePath < id.Context.FilePath;

      return this->Context.Line < id.Context.Line;
    }

    cmListFileContext Context;
  };

  mutable std::set<cmCMP0054Id> CMP0054ReportedIds;

  /**
   * Determine if the given context, name pair has already been reported
   * in context of CMP0054.
   */
  bool HasCMP0054AlreadyBeenReported(
    cmListFileContext context) const;
422

Ken Martin's avatar
Ken Martin committed
423
424
  void MakeStartDirectoriesCurrent()
    {
425
      this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
Ken Martin's avatar
Ken Martin committed
426
                          this->cmStartDirectory.c_str());
427
      this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
Ken Martin's avatar
Ken Martin committed
428
                          this->StartOutputDirectory.c_str());
Ken Martin's avatar
Ken Martin committed
429
    }
430

Ken Martin's avatar
Ken Martin committed
431
  //@{
432
  /**
Ken Martin's avatar
Ken Martin committed
433
434
435
436
   * Set/Get the home directory (or output directory) in the project. The
   * home directory is the top directory of the project. It is where
   * CMakeSetup or configure was run. Remember that CMake processes
   * CMakeLists files by recursing up the tree starting at the StartDirectory
437
   * and going up until it reaches the HomeDirectory.
438
   */
439
  void SetHomeDirectory(const std::string& dir);
440
  const char* GetHomeDirectory() const
441
    {
Ken Martin's avatar
Ken Martin committed
442
      return this->cmHomeDirectory.c_str();
443
    }
444
  void SetHomeOutputDirectory(const std::string& lib);
445
  const char* GetHomeOutputDirectory() const
446
    {
Ken Martin's avatar
Ken Martin committed
447
      return this->HomeOutputDirectory.c_str();
448
    }
Ken Martin's avatar
Ken Martin committed
449
  //@}
450
451
452
453
454
455

  /**
   * Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script.
   */
  void SetScriptModeFile(const char* scriptfile);

456
457
458
459
460
  /**
   * Set CMAKE_ARGC, CMAKE_ARGV0 ... variables.
   */
  void SetArgcArgv(const std::vector<std::string>& args);

Ken Martin's avatar
Ken Martin committed
461
  //@{
462
  /**
Ken Martin's avatar
Ken Martin committed
463
464
465
466
   * Set/Get the start directory (or output directory). The start directory
   * is the directory of the CMakeLists.txt file that started the current
   * round of processing. Remember that CMake processes CMakeLists files by
   * recursing up the tree starting at the StartDirectory and going up until
467
   * it reaches the HomeDirectory.
468
   */
469
  void SetStartDirectory(const std::string& dir)
470
    {
Ken Martin's avatar
Ken Martin committed
471
472
      this->cmStartDirectory = dir;
      cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
473
      this->cmStartDirectory =
474
        cmSystemTools::CollapseFullPath(this->cmStartDirectory);
475
      this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
Ken Martin's avatar
Ken Martin committed
476
                          this->cmStartDirectory.c_str());
477
    }
478
  const char* GetStartDirectory() const
479
    {
Ken Martin's avatar
Ken Martin committed
480
      return this->cmStartDirectory.c_str();
481
    }
482
  void SetStartOutputDirectory(const std::string& lib)
Ken Martin's avatar
Ken Martin committed
483
    {
Ken Martin's avatar
Ken Martin committed
484
485
      this->StartOutputDirectory = lib;
      cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
486
      this->StartOutputDirectory =
487
        cmSystemTools::CollapseFullPath(this->StartOutputDirectory);
Ken Martin's avatar
Ken Martin committed
488
      cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
489
      this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
Ken Martin's avatar
Ken Martin committed
490
                          this->StartOutputDirectory.c_str());
Ken Martin's avatar
Ken Martin committed
491
    }
492
  const char* GetStartOutputDirectory() const
493
    {
Ken Martin's avatar
Ken Martin committed
494
      return this->StartOutputDirectory.c_str();
495
    }
Ken Martin's avatar
Ken Martin committed
496
  //@}
497

498
  const char* GetCurrentDirectory() const
Ken Martin's avatar
Ken Martin committed
499
    {
Ken Martin's avatar
Ken Martin committed
500
      return this->cmStartDirectory.c_str();
Ken Martin's avatar
Ken Martin committed
501
    }
502
  const char* GetCurrentOutputDirectory() const
Ken Martin's avatar
Ken Martin committed
503
    {
Ken Martin's avatar
Ken Martin committed
504
      return this->StartOutputDirectory.c_str();
Ken Martin's avatar
Ken Martin committed
505
    }
Anonymous's avatar
Anonymous committed
506
507
508
509
510
511

  /* Get the current CMakeLists.txt file that is being processed.  This
   * is just used in order to be able to 'branch' from one file to a second
   * transparently */
  const char* GetCurrentListFile() const
    {
Ken Martin's avatar
Ken Martin committed
512
      return this->cmCurrentListFile.c_str();
Anonymous's avatar
Anonymous committed
513
514
    }

Ken Martin's avatar
Ken Martin committed
515
  //@}
516

517
  /**
518
519
520
521
522
   * Set a regular expression that include files must match
   * in order to be considered as part of the depend information.
   */
  void SetIncludeRegularExpression(const char* regex)
    {
Ken Martin's avatar
Ken Martin committed
523
      this->IncludeFileRegularExpression = regex;
524
    }
525
  const char* GetIncludeRegularExpression() const
526
    {
Ken Martin's avatar
Ken Martin committed
527
      return this->IncludeFileRegularExpression.c_str();
528
    }
529

530
  /**
531
532
533
   * Set a regular expression that include files that are not found
   * must match in order to be considered a problem.
   */
534
  void SetComplainRegularExpression(const std::string& regex)
535
    {
Ken Martin's avatar
Ken Martin committed
536
      this->ComplainFileRegularExpression = regex;
537
    }
538
  const char* GetComplainRegularExpression() const
539
    {
Ken Martin's avatar
Ken Martin committed
540
      return this->ComplainFileRegularExpression.c_str();
541
    }
542

543
  /**
544
   * Get the list of targets
545
   */
Ken Martin's avatar
Ken Martin committed
546
  cmTargets &GetTargets() { return this->Targets; }
Alexander Neundorf's avatar
   
Alexander Neundorf committed
547
548
549
550
  /**
   * Get the list of targets, const version
   */
  const cmTargets &GetTargets() const { return this->Targets; }
551
552
553
554
  const std::vector<cmTarget*> &GetOwnedImportedTargets() const
    {
      return this->ImportedTargetsOwned;
    }
555

556
557
558
559
560
561
562
563
564
565
  const cmGeneratorTargetsType &GetGeneratorTargets() const
    {
      return this->GeneratorTargets;
    }

  void SetGeneratorTargets(const cmGeneratorTargetsType &targets)
    {
      this->GeneratorTargets = targets;
    }

566
567
  cmTarget* FindTarget(const std::string& name,
                       bool excludeAliases = false) const;
568

569
570
  /** Find a target to use in place of the given name.  The target
      returned may be imported or built within the project.  */
571
  cmTarget* FindTargetToUse(const std::string& name,
572
573
                            bool excludeAliases = false) const;
  bool IsAlias(const std::string& name) const;
574
  cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
575

576
577
578
  /**
   * Mark include directories as system directories.
   */
579
  void AddSystemIncludeDirectories(const std::set<std::string> &incs);
580

581
582
583
  /** Get a cmSourceFile pointer for a given source name, if the name is
   *  not found, then a null pointer is returned.
   */
584
  cmSourceFile* GetSource(const std::string& sourceName) const;
585

586
587
588
589
590
591
592
  /** Create the source file and return it. generated
   * indicates if it is a generated file, this is used in determining
   * how to create the source file instance e.g. name
   */
  cmSourceFile* CreateSource(const std::string& sourceName,
                             bool generated = false);

593
  /** Get a cmSourceFile pointer for a given source name, if the name is
594
   *  not found, then create the source file and return it. generated
595
596
597
   * indicates if it is a generated file, this is used in determining
   * how to create the source file instance e.g. name
   */
598
  cmSourceFile* GetOrCreateSource(const std::string& sourceName,
599
                                  bool generated = false);
600

601
602
603
604
605
606
  //@{
  /**
   * Return a list of extensions associated with source and header
   * files
   */
  const std::vector<std::string>& GetSourceExtensions() const
Ken Martin's avatar
Ken Martin committed
607
    {return this->SourceFileExtensions;}
608
  const std::vector<std::string>& GetHeaderExtensions() const
Ken Martin's avatar
Ken Martin committed
609
    {return this->HeaderFileExtensions;}
610
611
  //@}

612
613
  /**
   * Given a variable name, return its value (as a string).
614
615
   * If the variable is not found in this makefile instance, the
   * cache is then queried.
616
   */
617
618
619
620
  const char* GetDefinition(const std::string&) const;
  const char* GetSafeDefinition(const std::string&) const;
  const char* GetRequiredDefinition(const std::string& name) const;
  bool IsDefinitionSet(const std::string&) const;
621
622
623
624
625
626
  /**
   * Get the list of all variables in the current space. If argument
   * cacheonly is specified and is greater than 0, then only cache
   * variables will be listed.
   */
  std::vector<std::string> GetDefinitions(int cacheonly=0) const;
627

628
629
630
631
632
  /**
   * Test a boolean variable to see if it is true or false.
   * If the variable is not found in this makefile instance, the
   * cache is then queried.
   * Returns false if no entry defined.
633
   */
634
635
  bool IsOn(const std::string& name) const;
  bool IsSet(const std::string& name) const;
636

637
638
639
  /** Return whether the target platform is 64-bit.  */
  bool PlatformIs64Bit() const;

640
  /** Retrieve soname flag for the specified language if supported */
641
  const char* GetSONameFlag(const std::string& language) const;
642

643
  /**
644
   * Get a list of preprocessor define flags.
645
   */
646
  const char* GetDefineFlags() const
Ken Martin's avatar
Ken Martin committed
647
    {return this->DefineFlags.c_str();}
648
649
650
651

  /**
   * Make sure CMake can write this file
   */
652
  bool CanIWriteThisFile(const char* fileName) const;
653

654
#if defined(CMAKE_BUILD_WITH_CMAKE)
655
656
657
658
  /**
   * Get the vector source groups.
   */
  const std::vector<cmSourceGroup>& GetSourceGroups() const
Ken Martin's avatar
Ken Martin committed
659
    { return this->SourceGroups; }
Anonymous's avatar
Anonymous committed
660

661
662
663
  /**
   * Get the source group
   */
664
  cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name) const;
665
#endif
666

Anonymous's avatar
Anonymous committed
667
668
669
670
  /**
   * Get the vector of list files on which this makefile depends
   */
  const std::vector<std::string>& GetListFiles() const
Ken Martin's avatar
Ken Martin committed
671
    { return this->ListFiles; }
672
  ///! When the file changes cmake will be re-run from the build system.
673
  void AddCMakeDependFile(const std::string& file)
Ken Martin's avatar
Ken Martin committed
674
    { this->ListFiles.push_back(file);}
675
  void AddCMakeDependFilesFromUser();
676

677
  std::string GetListFileStack() const;
678

679
680
681
  /**
   * Get the current context backtrace.
   */
Ben Boeckel's avatar
Ben Boeckel committed
682
  cmListFileBacktrace GetBacktrace() const;
683

684
685
686
687
688
  /**
   * Get the vector of  files created by this makefile
   */
  const std::vector<std::string>& GetOutputFiles() const
    { return this->OutputFiles; }
689
  void AddCMakeOutputFile(const std::string& file)
690
    { this->OutputFiles.push_back(file);}
691

692
  /**
693
   * Expand all defined variables in the string.
Ken Martin's avatar
Ken Martin committed
694
   * Defined variables come from the this->Definitions map.
695
   * They are expanded with ${var} where var is the
Nicolas Despres's avatar
Nicolas Despres committed
696
   * entry in the this->Definitions map.  Also \@var\@ is
697
   * expanded to match autoconf style expansions.
698
   */
699
  const char *ExpandVariablesInString(std::string& source) const;
700
  const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
701
                                      bool noEscapes,
702
703
                                      bool atOnly = false,
                                      const char* filename = 0,
Bill Hoffman's avatar
Bill Hoffman committed
704
                                      long line = -1,
705
                                      bool removeEmpty = false,
706
                                      bool replaceAt = false) const;
707

708
709
  /**
   * Remove any remaining variables in the string. Anything with ${var} or
Nicolas Despres's avatar
Nicolas Despres committed
710
   * \@var\@ will be removed.
711
   */
712
  void RemoveVariablesInString(std::string& source,
Ken Martin's avatar
Ken Martin committed
713
                               bool atOnly = false) const;
714

715
716
717
  /**
   * Expand variables in the makefiles ivars such as link directories etc
   */
718
  void ExpandVariablesCMP0019();
719
720
721
722
723
724

  /**
   * Replace variables and #cmakedefine lines in the given string.
   * See cmConfigureFileCommand for details.
   */
  void ConfigureString(const std::string& input, std::string& output,
725
                       bool atOnly, bool escapeQuotes) const;
726

Andy Cedilnik's avatar
Andy Cedilnik committed
727
728
729
  /**
   * Copy file but change lines acording to ConfigureString
   */
730
  int ConfigureFile(const char* infile, const char* outfile,
731
732
733
                    bool copyonly, bool atOnly, bool escapeQuotes,
                    const cmNewLineStyle& = cmNewLineStyle());

Andy Cedilnik's avatar
Andy Cedilnik committed
734

735
#if defined(CMAKE_BUILD_WITH_CMAKE)
736
737
738
  /**
   * find what source group this source is in
   */
739
740
  cmSourceGroup* FindSourceGroup(const char* source,
                                 std::vector<cmSourceGroup> &groups) const;
741
742
#endif

743
744
745
  /**
   * Print a command's invocation
   */
746
  void PrintCommandTrace(const cmListFileFunction& lff) const;
747

Ken Martin's avatar
Ken Martin committed
748
  /**
749
750
   * Execute a single CMake command.  Returns true if the command
   * succeeded or false if it failed.
Ken Martin's avatar
Ken Martin committed
751
   */
752
  bool ExecuteCommand(const cmListFileFunction& lff,
753
754
                      cmExecutionStatus &status);

755
756
  /** Check if a command exists. */
  bool CommandExists(const char* name) const;
757

758
759
760
761
762
  /**
   * Add a command to this cmake instance
   */
  void AddCommand(cmCommand* );

Ken Martin's avatar
Ken Martin committed
763
764
  ///! Enable support for named language, if nil then all languages are
  ///enabled.
Alexander Neundorf's avatar
   
Alexander Neundorf committed
765
  void EnableLanguage(std::vector<std::string>const& languages, bool optional);
766

Stephen Kelly's avatar
Stephen Kelly committed
767
  cmState *GetState() const;
768
769
770
771
772
773

  /**
   * Get the variable watch. This is used to determine when certain variables
   * are accessed.
   */
#ifdef CMAKE_BUILD_WITH_CMAKE
774
  cmVariableWatch* GetVariableWatch() const;
775
#endif
776

777
  ///! Display progress or status message.
778
  void DisplayStatus(const char*, float) const;
779

780
781
782
783
  /**
   * Expand the given list file arguments into the full set after
   * variable replacement and list expansion.
   */
784
  bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
785
                       std::vector<std::string>& outArgs) const;
786
787
788
789

  bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
                       std::vector<cmExpandedCommandArgument>& outArgs) const;

790
791
  /**
   * Get the instance
792
   */
793
794
  cmake *GetCMakeInstance() const;

795
796
797
  /**
   * Get all the source files this makefile knows about
   */
798
  const std::vector<cmSourceFile*> &GetSourceFiles() const
Ken Martin's avatar
Ken Martin committed
799
800
    {return this->SourceFiles;}
  std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
801
802
803
804
805

  /**
   * Is there a source file that has the provided source file as an output?
   * if so then return it
   */
806
  cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const;
807
808
809

  /**
   * Add a macro to the list of macros. The arguments should be name of the
810
   * macro and a documentation signature of it
811
   */
812
  void AddMacro(const char* name);
813

814
  ///! Add a new cmTest to the list of tests for this makefile.
815
  cmTest* CreateTest(const std::string& testName);
816
817
818
819

  /** Get a cmTest pointer for a given test name, if the name is
   *  not found, then a null pointer is returned.
   */
820
  cmTest* GetTest(const std::string& testName) const;
821

822
823
824
  /**
   * Get a list of macros as a ; separated string
   */
825
  void GetListOfMacros(std::string& macros) const;
826
827
828
829

  /**
   * Return a location of a file in cmake or custom modules directory
   */
830
  std::string GetModulesFile(const char* name) const;
831

832
  ///! Set/Get a property of this directory
833
834
835
836
837
838
839
  void SetProperty(const std::string& prop, const char *value);
  void AppendProperty(const std::string& prop, const char *value,
                      bool asString=false);
  const char *GetProperty(const std::string& prop) const;
  const char *GetProperty(const std::string& prop,
                          cmProperty::ScopeType scope) const;
  bool GetPropertyAsBool(const std::string& prop) const;
840

841
842
  const char* GetFeature(const std::string& feature,
                         const std::string& config);
843

844
  // Get the properties
845
  cmPropertyMap &GetProperties() { return this->Properties; }
846

847
848
  ///! Initialize a makefile from its parent
  void InitializeFromParent();
849