root/simulator/trunk/vendor/cmake/Source/cmMakefile.h

Revision 1306, 31.7 kB (checked in by sehenley, 10 months ago)

Update vendor cmake to 2.8.0-rc3

Line 
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 ============================================================================*/
12
13 // ////////////////////////////////////////////////////
14 // Modified by OSRail Project to create a CodeBlocks
15 // generator for gcc projects. sehenley@comcast.net
16 // ///////////////////////////////////////////////////
17
18 #ifndef cmMakefile_h
19 #define cmMakefile_h
20
21 #include "cmCacheManager.h"
22 #include "cmData.h"
23 #include "cmExecutionStatus.h"
24 #include "cmListFileCache.h"
25 #include "cmPolicies.h"
26 #include "cmPropertyMap.h"
27 #include "cmSystemTools.h"
28 #include "cmTarget.h"
29 #include "cmake.h"
30
31 #if defined(CMAKE_BUILD_WITH_CMAKE)
32 #include "cmSourceGroup.h"
33 #endif
34
35 #include <cmsys/auto_ptr.hxx>
36 #include <cmsys/RegularExpression.hxx>
37
38 class cmFunctionBlocker;
39 class cmCommand;
40 class cmInstallGenerator;
41 class cmLocalGenerator;
42 class cmMakeDepend;
43 class cmSourceFile;
44 class cmTest;
45 class cmTestGenerator;
46 class cmVariableWatch;
47 class cmake;
48 class cmMakefileCall;
49 class cmCMakePolicyCommand;
50
51 /** \class cmMakefile
52  * \brief Process the input CMakeLists.txt file.
53  *
54  * Process and store into memory the input CMakeLists.txt file.
55  * Each CMakeLists.txt file is parsed and the commands found there
56  * are added into the build process.
57  */
58 class cmMakefile
59 {
60   class Internals;
61   cmsys::auto_ptr<Internals> Internal;
62 public:
63   /**
64    * Return the major and minor version of the cmake that
65    * was used to write the currently loaded cache, note
66    * this method will not work before the cache is loaded.
67    */
68   unsigned int GetCacheMajorVersion();
69   unsigned int GetCacheMinorVersion();
70
71   /** Return whether compatibility features needed for a version of
72       the cache or lower should be enabled.  */
73   bool NeedCacheCompatibility(int major, int minor);
74
75   /**
76    * Construct an empty makefile.
77    */
78   cmMakefile();
79   cmMakefile(const cmMakefile& mf);
80
81   /**
82    * Destructor.
83    */
84   ~cmMakefile();
85
86   /**
87    * Read and parse a CMakeLists.txt file.
88    */
89   bool ReadListFile(const char* listfile,
90                     const char* external= 0,
91                     std::string* fullPath= 0,
92                     bool noPolicyScope = true);
93
94   /**
95    * Add a function blocker to this makefile
96    */
97   void AddFunctionBlocker(cmFunctionBlocker* fb);
98
99   /**
100    * Remove the function blocker whose scope ends with the given command.
101    * This returns ownership of the function blocker object.
102    */
103   cmsys::auto_ptr<cmFunctionBlocker>
104   RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
105
106   /** Push/pop a lexical (function blocker) barrier automatically.  */
107   class LexicalPushPop
108   {
109   public:
110     LexicalPushPop(cmMakefile* mf);
111     ~LexicalPushPop();
112     void Quiet() { this->ReportError = false; }
113   private:
114     cmMakefile* Makefile;
115     bool ReportError;
116   };
117   friend class LexicalPushPop;
118
119   /**
120    * Try running cmake and building a file. This is used for dynalically
121    * loaded commands, not as part of the usual build process.
122    */
123   int TryCompile(const char *srcdir, const char *bindir,
124                  const char *projectName, const char *targetName,
125                  bool fast,
126                  const std::vector<std::string> *cmakeArgs,
127                  std::string *output);
128
129   /**
130    * Specify the makefile generator. This is platform/compiler
131    * dependent, although the interface is through a generic
132    * superclass.
133    */
134   void SetLocalGenerator(cmLocalGenerator*);
135
136   ///! Get the current makefile generator.
137   cmLocalGenerator* GetLocalGenerator()
138     { return this->LocalGenerator;}
139
140   /**
141    * Test whether compatibility is set to a given version or lower.
142    */
143   bool NeedBackwardsCompatibility(unsigned int major,
144                                   unsigned int minor,
145                                   unsigned int patch = 0xFFu);
146
147   /**
148    * Help enforce global target name uniqueness.
149    */
150   bool EnforceUniqueName(std::string const& name, std::string& msg,
151                          bool isCustom = false);
152
153   /**
154    * Perform FinalPass, Library dependency analysis etc before output of the
155    * makefile.
156    */
157   void ConfigureFinalPass();
158
159   /**
160    * run the final pass on all commands.
161    */
162   void FinalPass();
163
164   /**
165    * Print the object state to std::cout.
166    */
167   void Print();
168
169   /** Add a custom command to the build.  */
170   void AddCustomCommandToTarget(const char* target,
171                                 const std::vector<std::string>& depends,
172                                 const cmCustomCommandLines& commandLines,
173                                 cmTarget::CustomCommandType type,
174                                 const char* comment, const char* workingDir,
175                                 bool escapeOldStyle = true);
176   void AddCustomCommandToOutput(const std::vector<std::string>& outputs,
177                                 const std::vector<std::string>& depends,
178                                 const char* main_dependency,
179                                 const cmCustomCommandLines& commandLines,
180                                 const char* comment, const char* workingDir,
181                                 bool replace = false,
182                                 bool escapeOldStyle = true);
183   void AddCustomCommandToOutput(const char* output,
184                                 const std::vector<std::string>& depends,
185                                 const char* main_dependency,
186                                 const cmCustomCommandLines& commandLines,
187                                 const char* comment, const char* workingDir,
188                                 bool replace = false,
189                                 bool escapeOldStyle = true);
190   void AddCustomCommandOldStyle(const char* target,
191                                 const std::vector<std::string>& outputs,
192                                 const std::vector<std::string>& depends,
193                                 const char* source,
194                                 const cmCustomCommandLines& commandLines,
195                                 const char* comment);
196
197   /**
198    * Add a define flag to the build.
199    */
200   void AddDefineFlag(const char* definition);
201   void RemoveDefineFlag(const char* definition);
202
203   /** Create a new imported target with the name and type given.  */
204   cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type);
205
206   cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
207
208   /**
209    * Add an executable to the build.
210    */
211   cmTarget* AddExecutable(const char *exename,
212                           const std::vector<std::string> &srcs,
213                           bool excludeFromAll = false);
214
215   /**
216    * Add a utility to the build.  A utiltity target is a command that
217    * is run every time the target is built.
218    */
219   void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
220                          const std::vector<std::string>& depends,
221                          const char* workingDirectory,
222                          const char* command,
223                          const char* arg1=0,
224                          const char* arg2=0,
225                          const char* arg3=0,
226                          const char* arg4=0);
227   cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll,
228                               const char* workingDirectory,
229                               const std::vector<std::string>& depends,
230                               const cmCustomCommandLines& commandLines,
231                               bool escapeOldStyle = true,
232                               const char* comment = 0);
233
234   /**
235    * Add a link library to the build.
236    */
237   void AddLinkLibrary(const char*);
238   void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
239   void AddLinkLibraryForTarget(const char *tgt, const char*,
240                                cmTarget::LinkLibraryType type);
241   void AddLinkDirectoryForTarget(const char *tgt, const char* d);
242
243   /**
244    * Add a link directory to the build.
245    */
246   void AddLinkDirectory(const char*);
247
248   /**
249    * Get the list of link directories
250    */
251   std::vector<std::string>& GetLinkDirectories()
252     {
253       return this->LinkDirectories;
254     }
255   const std::vector<std::string>& GetLinkDirectories() const
256     {
257       return this->LinkDirectories;
258     }
259   void SetLinkDirectories(const std::vector<std::string>& vec)
260     {
261       this->LinkDirectories = vec;
262     }
263
264   /**
265    * Add a subdirectory to the build.
266    */
267   void AddSubDirectory(const char*, bool excludeFromAll=false,
268                        bool preorder = false);
269   void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
270                        bool excludeFromAll, bool preorder,
271                        bool immediate);
272
273   /**
274    * Configure a subdirectory
275    */
276   void ConfigureSubDirectory(cmLocalGenerator *);
277
278   /**
279    * Add an include directory to the build.
280    */
281   void AddIncludeDirectory(const char*, bool before = false);
282
283   /**
284    * Add a variable definition to the build. This variable
285    * can be used in CMake to refer to lists, directories, etc.
286    */
287   void AddDefinition(const char* name, const char* value);
288   ///! Add a definition to this makefile and the global cmake cache.
289   void AddCacheDefinition(const char* name, const char* value,
290                           const char* doc,
291                           cmCacheManager::CacheEntryType type,
292                           bool force = false);
293
294   /**
295    * Add bool variable definition to the build.
296    */
297   void AddDefinition(const char* name, bool);
298
299   /**
300    * Remove a variable definition from the build.  This is not valid
301    * for cache entries, and will only affect the current makefile.
302    */
303   void RemoveDefinition(const char* name);
304   ///! Remove a definition from the cache.
305   void RemoveCacheDefinition(const char* name);
306
307   /**
308    * Specify the name of the project for this build.
309    */
310   void SetProjectName(const char*);
311
312   /**
313    * Get the name of the project for this build.
314    */
315   const char* GetProjectName() const
316     {
317       return this->ProjectName.c_str();
318     }
319
320   /**
321    * Set the name of the library.
322    */
323   void AddLibrary(const char *libname, cmTarget::TargetType type,
324                   const std::vector<std::string> &srcs,
325                   bool excludeFromAll = false);
326
327 #if defined(CMAKE_BUILD_WITH_CMAKE)
328   /**
329    * Add a root source group for consideration when adding a new source.
330    */
331   void AddSourceGroup(const char* name, const char* regex=0);
332
333   /**
334    * Add a source group for consideration when adding a new source.
335    * name is tokenized.
336    */
337   void AddSourceGroup(const std::vector<std::string>& name,
338                       const char* regex=0);
339
340 #endif
341
342   //@{
343   /**
344      * Set, Push, Pop policy values for CMake.
345      */
346   bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
347   bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
348   cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
349   bool SetPolicyVersion(const char *version);
350   void RecordPolicies(cmPolicies::PolicyMap& pm);
351   //@}
352
353   /** Helper class to push and pop policies automatically.  */
354   class PolicyPushPop
355   {
356   public:
357     PolicyPushPop(cmMakefile* m,
358                   bool weak = false,
359                   cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
360     ~PolicyPushPop();
361     void Quiet() { this->ReportError = false; }
362   private:
363     cmMakefile* Makefile;
364     bool ReportError;
365   };
366   friend class PolicyPushPop;
367
368   /**
369     * Get the Policies Instance
370     */
371  cmPolicies *GetPolicies();
372
373   /**
374    * Add an auxiliary directory to the build.
375    */
376   void AddExtraDirectory(const char* dir);
377
378
379   /**
380    * Add an auxiliary directory to the build.
381    */
382   void MakeStartDirectoriesCurrent()
383     {
384       this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
385                           this->cmStartDirectory.c_str());
386       this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
387                           this->StartOutputDirectory.c_str());
388     }
389
390   //@{
391   /**
392    * Set/Get the home directory (or output directory) in the project. The
393    * home directory is the top directory of the project. It is where
394    * CMakeSetup or configure was run. Remember that CMake processes
395    * CMakeLists files by recursing up the tree starting at the StartDirectory
396    * and going up until it reaches the HomeDirectory.
397    */
398   void SetHomeDirectory(const char* dir);
399   const char* GetHomeDirectory() const
400     {
401       return this->cmHomeDirectory.c_str();
402     }
403   void SetHomeOutputDirectory(const char* lib);
404   const char* GetHomeOutputDirectory() const
405     {
406       return this->HomeOutputDirectory.c_str();
407     }
408   //@}
409
410   //@{
411   /**
412    * Set/Get the start directory (or output directory). The start directory
413    * is the directory of the CMakeLists.txt file that started the current
414    * round of processing. Remember that CMake processes CMakeLists files by
415    * recursing up the tree starting at the StartDirectory and going up until
416    * it reaches the HomeDirectory.
417    */
418   void SetStartDirectory(const char* dir)
419     {
420       this->cmStartDirectory = dir;
421       cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
422       this->cmStartDirectory =
423         cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str());
424       this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
425                           this->cmStartDirectory.c_str());
426     }
427   const char* GetStartDirectory() const
428     {
429       return this->cmStartDirectory.c_str();
430     }
431   void SetStartOutputDirectory(const char* lib)
432     {
433       this->StartOutputDirectory = lib;
434       cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
435       this->StartOutputDirectory =
436         cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str());
437       cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
438       this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
439                           this->StartOutputDirectory.c_str());
440     }
441   const char* GetStartOutputDirectory() const
442     {
443       return this->StartOutputDirectory.c_str();
444     }
445   //@}
446
447   const char* GetCurrentDirectory() const
448     {
449       return this->cmStartDirectory.c_str();
450     }
451   const char* GetCurrentOutputDirectory() const
452     {
453       return this->StartOutputDirectory.c_str();
454     }
455
456   /* Get the current CMakeLists.txt file that is being processed.  This
457    * is just used in order to be able to 'branch' from one file to a second
458    * transparently */
459   const char* GetCurrentListFile() const
460     {
461       return this->cmCurrentListFile.c_str();
462     }
463
464   //@}
465
466   /**
467    * Set a regular expression that include files must match
468    * in order to be considered as part of the depend information.
469    */
470   void SetIncludeRegularExpression(const char* regex)
471     {
472       this->IncludeFileRegularExpression = regex;
473     }
474   const char* GetIncludeRegularExpression()
475     {
476       return this->IncludeFileRegularExpression.c_str();
477     }
478
479   /**
480    * Set a regular expression that include files that are not found
481    * must match in order to be considered a problem.
482    */
483   void SetComplainRegularExpression(const char* regex)
484     {
485       this->ComplainFileRegularExpression = regex;
486     }
487   const char* GetComplainRegularExpression()
488     {
489       return this->ComplainFileRegularExpression.c_str();
490     }
491
492   /**
493    * Get the list of targets
494    */
495   cmTargets &GetTargets() { return this->Targets; }
496   /**
497    * Get the list of targets, const version
498    */
499   const cmTargets &GetTargets() const { return this->Targets; }
500
501   cmTarget* FindTarget(const char* name);
502
503   /** Find a target to use in place of the given name.  The target
504       returned may be imported or built within the project.  */
505   cmTarget* FindTargetToUse(const char* name);
506
507   /**
508    * Get a list of include directories in the build.
509    */
510   std::vector<std::string>& GetIncludeDirectories()
511     {
512       return this->IncludeDirectories;
513     }
514   const std::vector<std::string>& GetIncludeDirectories() const
515     {
516       return this->IncludeDirectories;
517     }
518   void SetIncludeDirectories(const std::vector<std::string>& vec)
519     {
520       this->IncludeDirectories = vec;
521     }
522
523   /**
524    * Mark include directories as system directories.
525    */
526   void AddSystemIncludeDirectory(const char* dir);
527   bool IsSystemIncludeDirectory(const char* dir);
528
529   /** Expand out any arguements in the vector that have ; separated
530    *  strings into multiple arguements.  A new vector is created
531    *  containing the expanded versions of all arguments in argsIn.
532    * This method differes from the one in cmSystemTools in that if
533    * the CmakeLists file is version 1.2 or earlier it will check for
534    * source lists being used without ${} around them
535    */
536   void ExpandSourceListArguments(std::vector<std::string> const& argsIn,
537                                  std::vector<std::string>& argsOut,
538                                  unsigned int startArgumentIndex);
539
540   /** Get a cmSourceFile pointer for a given source name, if the name is
541    *  not found, then a null pointer is returned.
542    */
543   cmSourceFile* GetSource(const char* sourceName);
544
545   /** Get a cmSourceFile pointer for a given source name, if the name is
546    *  not found, then create the source file and return it. generated
547    * indicates if it is a generated file, this is used in determining
548    * how to create the source file instance e.g. name
549    */
550   cmSourceFile* GetOrCreateSource(const char* sourceName,
551                                   bool generated = false);
552
553   /**
554    * Obtain a list of auxiliary source directories.
555    */
556   std::vector<std::string>& GetAuxSourceDirectories()
557     {return this->AuxSourceDirectories;}
558
559   //@{
560   /**
561    * Return a list of extensions associated with source and header
562    * files
563    */
564   const std::vector<std::string>& GetSourceExtensions() const
565     {return this->SourceFileExtensions;}
566   const std::vector<std::string>& GetHeaderExtensions() const
567     {return this->HeaderFileExtensions;}
568   //@}
569
570   /**
571    * Given a variable name, return its value (as a string).
572    * If the variable is not found in this makefile instance, the
573    * cache is then queried.
574    */
575   const char* GetDefinition(const char*) const;
576   const char* GetSafeDefinition(const char*) const;
577   const char* GetRequiredDefinition(const char* name) const;
578   bool IsDefinitionSet(const char*) const;
579   /**
580    * Get the list of all variables in the current space. If argument
581    * cacheonly is specified and is greater than 0, then only cache
582    * variables will be listed.
583    */
584   std::vector<std::string> GetDefinitions(int cacheonly=0) const;
585
586   /** Test a boolean cache entry to see if it is true or false,
587    *  returns false if no entry defined.
588    */
589   bool IsOn(const char* name) const;
590   bool IsSet(const char* name) const;
591
592   /** Return whether the target platform is 64-bit.  */
593   bool PlatformIs64Bit() const;
594
595   /**
596    * Get a list of preprocessor define flags.
597    */
598   const char* GetDefineFlags()
599     {return this->DefineFlags.c_str();}
600
601   /**
602    * Make sure CMake can write this file
603    */
604   bool CanIWriteThisFile(const char* fileName);
605
606   /**
607    * Get the vector of used command instances.
608    */
609   const std::vector<cmCommand*>& GetUsedCommands() const
610     {return this->UsedCommands;}
611
612 #if defined(CMAKE_BUILD_WITH_CMAKE)
613   /**
614    * Get the vector source groups.
615    */
616   const std::vector<cmSourceGroup>& GetSourceGroups() const
617     { return this->SourceGroups; }
618
619   /**
620    * Get the source group
621    */
622   cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name);
623 #endif
624
625   /**
626    * Get the vector of list files on which this makefile depends
627    */
628   const std::vector<std::string>& GetListFiles() const
629     { return this->ListFiles; }
630   ///! When the file changes cmake will be re-run from the build system.
631   void AddCMakeDependFile(const char* file)
632     { this->ListFiles.push_back(file);}
633
634     /**
635      * Get the list file stack as a string
636      */
637     std::string GetListFileStack();
638
639   /**
640    * Get the current context backtrace.
641    */
642   bool GetBacktrace(cmListFileBacktrace& backtrace) const;
643
644   /**
645    * Get the vector of  files created by this makefile
646    */
647   const std::vector<std::string>& GetOutputFiles() const
648     { return this->OutputFiles; }
649   void AddCMakeOutputFile(const char* file)
650     { this->OutputFiles.push_back(file);}
651
652   /**
653    * Expand all defined variables in the string.
654    * Defined variables come from the this->Definitions map.
655    * They are expanded with ${var} where var is the
656    * entry in the this->Definitions map.  Also @var@ is
657    * expanded to match autoconf style expansions.
658    */
659   const char *ExpandVariablesInString(std::string& source);
660   const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
661                                       bool noEscapes,
662                                       bool atOnly = false,
663                                       const char* filename = 0,
664                                       long line = -1,
665                                       bool removeEmpty = false,
666                                       bool replaceAt = true);
667
668   /**
669    * Remove any remaining variables in the string. Anything with ${var} or
670    * @var@ will be removed.
671    */
672   void RemoveVariablesInString(std::string& source,
673                                bool atOnly = false) const;
674
675   /**
676    * Expand variables in the makefiles ivars such as link directories etc
677    */
678   void ExpandVariables();
679
680   /**
681    * Replace variables and #cmakedefine lines in the given string.
682    * See cmConfigureFileCommand for details.
683    */
684   void ConfigureString(const std::string& input, std::string& output,
685                        bool atOnly, bool escapeQuotes);
686
687   /**
688    * Copy file but change lines acording to ConfigureString
689    */
690   int ConfigureFile(const char* infile, const char* outfile,
691                     bool copyonly, bool atOnly, bool escapeQuotes);
692
693 #if defined(CMAKE_BUILD_WITH_CMAKE)
694   /**
695    * find what source group this source is in
696    */
697   cmSourceGroup& FindSourceGroup(const char* source,
698                                  std::vector<cmSourceGroup> &groups);
699 #endif
700
701   void RegisterData(cmData*);
702   void RegisterData(const char*, cmData*);
703   cmData* LookupData(const char*) const;
704
705   /**
706    * Execute a single CMake command.  Returns true if the command
707    * succeeded or false if it failed.
708    */
709   bool ExecuteCommand(const cmListFileFunction& lff,
710                       cmExecutionStatus &status);
711
712   /** Check if a command exists. */
713   bool CommandExists(const char* name) const;
714
715   /**
716    * Add a command to this cmake instance
717    */
718   void AddCommand(cmCommand* );
719
720   ///! Enable support for named language, if nil then all languages are
721   ///enabled.
722   void EnableLanguage(std::vector<std::string>const& languages, bool optional);
723
724   /**
725    * Set/Get the name of the parent directories CMakeLists file
726    * given a current CMakeLists file name
727    */
728   cmCacheManager *GetCacheManager() const;
729
730   /**
731    * Get the variable watch. This is used to determine when certain variables
732    * are accessed.
733    */
734 #ifdef CMAKE_BUILD_WITH_CMAKE
735   cmVariableWatch* GetVariableWatch() const;
736 #endif
737
738   ///! Display progress or status message.
739   void DisplayStatus(const char*, float);
740
741   /**
742    * Expand the given list file arguments into the full set after
743    * variable replacement and list expansion.
744    */
745   bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
746                        std::vector<std::string>& outArgs);
747   /**
748    * Get the instance
749    */
750   cmake *GetCMakeInstance() const;
751
752   /**
753    * Get all the source files this makefile knows about
754    */
755   const std::vector<cmSourceFile*> &GetSourceFiles() const
756     {return this->SourceFiles;}
757   std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
758
759   /**
760    * Is there a source file that has the provided source file as an output?
761    * if so then return it
762    */
763   cmSourceFile *GetSourceFileWithOutput(const char *outName);
764
765   /**
766    * Add a macro to the list of macros. The arguments should be name of the
767    * macro and a documentation signature of it
768    */
769   void AddMacro(const char* name, const char* signature);
770
771   ///! Add a new cmTest to the list of tests for this makefile.
772   cmTest* CreateTest(const char* testName);
773
774   /** Get a cmTest pointer for a given test name, if the name is
775    *  not found, then a null pointer is returned.
776    */
777   cmTest* GetTest(const char* testName) const;
778
779   /**
780    * Get a list of macros as a ; separated string
781    */
782   void GetListOfMacros(std::string& macros);
783
784   /**
785    * Return a location of a file in cmake or custom modules directory
786    */
787   std::string GetModulesFile(const char* name);
788
789   ///! Set/Get a property of this directory
790   void SetProperty(const char *prop, const char *value);
791   void AppendProperty(const char *prop, const char *value);
792   const char *GetProperty(const char *prop);
793   const char *GetPropertyOrDefinition(const char *prop);
794   const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
795   bool GetPropertyAsBool(const char *prop);
796
797   const char* GetFeature(const char* feature, const char* config);
798
799   // Get the properties
800   cmPropertyMap &GetProperties() { return this->Properties; };
801
802   ///! Initialize a makefile from its parent
803   void InitializeFromParent();
804
805   ///! Set/Get the preorder flag
806   void SetPreOrder(bool p) { this->PreOrder = p; }
807   bool GetPreOrder() const { return this->PreOrder; }
808
809   void AddInstallGenerator(cmInstallGenerator* g)
810     { if(g) this->InstallGenerators.push_back(g); }
811   std::vector<cmInstallGenerator*>& GetInstallGenerators()
812     { return this->InstallGenerators; }
813
814   void AddTestGenerator(cmTestGenerator* g)
815     { if(g) this->TestGenerators.push_back(g); }
816   std::vector<cmTestGenerator*>& GetTestGenerators()
817     { return this->TestGenerators; }
818
819   // Define the properties
820   static void DefineProperties(cmake *cm);
821
822   // push and pop variable scopes
823   void PushScope();
824   void PopScope();
825   void RaiseScope(const char *var, const char *value);
826
827   /** Helper class to push and pop scopes automatically.  */
828   class ScopePushPop
829   {
830   public:
831     ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
832     ~ScopePushPop() { this->Makefile->PopScope(); }
833   private:
834     cmMakefile* Makefile;
835   };
836
837   void IssueMessage(cmake::MessageType t,
838                     std::string const& text) const;
839
840   /** Set whether or not to report a CMP0000 violation.  */
841   void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
842
843 // ////////////////////////////////////////////////////
844 // Modified by OSRail Project to create a CodeBlocks
845 // generator for gcc projects. sehenley@comcast.net
846 // ///////////////////////////////////////////////////
847   std::map<cmStdString, cmTest*>& GetTests(){ return Tests; }
848
849
850 protected:
851   // add link libraries and directories to the target
852   void AddGlobalLinkInformation(const char* name, cmTarget& target);
853
854   std::string Prefix;
855   std::vector<std::string> AuxSourceDirectories; //
856
857   std::string cmStartDirectory;
858   std::string StartOutputDirectory;
859   std::string cmHomeDirectory;
860   std::string HomeOutputDirectory;
861   std::string cmCurrentListFile;
862
863   std::string ProjectName;    // project name
864
865   // libraries, classes, and executables
866   cmTargets Targets;
867   std::vector<cmSourceFile*> SourceFiles;
868
869   // Tests
870   std::map<cmStdString, cmTest*> Tests;
871
872   // The include and link-library paths.  These may have order
873   // dependency, so they must be vectors (not set).
874   std::vector<std::string> IncludeDirectories;
875   std::vector<std::string> LinkDirectories;
876
877   // The set of include directories that are marked as system include
878   // directories.
879   std::set<cmStdString> SystemIncludeDirectories;
880
881   std::vector<std::string> ListFiles; // list of command files loaded
882   std::vector<std::string> OutputFiles; // list of command files loaded
883
884
885   cmTarget::LinkLibraryVectorType LinkLibraries;
886
887   std::vector<cmInstallGenerator*> InstallGenerators;
888   std::vector<cmTestGenerator*> TestGenerators;
889
890   std::string IncludeFileRegularExpression;
891   std::string ComplainFileRegularExpression;
892   std::vector<std::string> SourceFileExtensions;
893   std::vector<std::string> HeaderFileExtensions;
894   std::string DefineFlags;
895
896   // Track the value of the computed DEFINITIONS property.
897   void AddDefineFlag(const char*, std::string&);
898   void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
899   std::string DefineFlagsOrig;
900
901 #if defined(CMAKE_BUILD_WITH_CMAKE)
902   std::vector<cmSourceGroup> SourceGroups;
903 #endif
904
905   std::vector<cmCommand*> UsedCommands;
906   cmLocalGenerator* LocalGenerator;
907   bool IsFunctionBlocked(const cmListFileFunction& lff,
908                          cmExecutionStatus &status);
909
910 private:
911   void Initialize();
912
913   bool ParseDefineFlag(std::string const& definition, bool remove);
914
915   bool EnforceUniqueDir(const char* srcPath, const char* binPath);
916
917   void ReadSources(std::ifstream& fin, bool t);
918   friend class cmMakeDepend;    // make depend needs direct access
919                                 // to the Sources array
920   void PrintStringVector(const char* s, const
921                          std::vector<std::pair<cmStdString, bool> >& v) const;
922   void PrintStringVector(const char* s,
923                          const std::vector<std::string>& v) const;
924
925   void AddDefaultDefinitions();
926   typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
927   FunctionBlockersType FunctionBlockers;
928   std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
929   void PushFunctionBlockerBarrier();
930   void PopFunctionBlockerBarrier(bool reportError = true);
931
932   typedef std::map<cmStdString, cmData*> DataMapType;
933   DataMapType DataMap;
934
935   typedef std::map<cmStdString, cmStdString> StringStringMap;
936   StringStringMap MacrosMap;
937
938   std::map<cmStdString, bool> SubDirectoryOrder;
939
940   cmsys::RegularExpression cmDefineRegex;
941   cmsys::RegularExpression cmDefine01Regex;
942   cmsys::RegularExpression cmAtVarRegex;
943
944   cmPropertyMap Properties;
945
946   // should this makefile be processed before or after processing the parent
947   bool PreOrder;
948
949   // stack of list files being read
950   std::deque<cmStdString> ListFileStack;
951
952   // stack of commands being invoked.
953   struct CallStackEntry
954   {
955     cmListFileContext const* Context;
956     cmExecutionStatus* Status;
957   };
958   typedef std::deque<CallStackEntry> CallStackType;
959   CallStackType CallStack;
960   friend class cmMakefileCall;
961
962   cmTarget* FindBasicTarget(const char* name);
963   std::vector<cmTarget*> ImportedTargetsOwned;
964   std::map<cmStdString, cmTarget*> ImportedTargets;
965
966   // Internal policy stack management.
967   void PushPolicy(bool weak = false,
968                   cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
969   void PopPolicy();
970   void PushPolicyBarrier();
971   void PopPolicyBarrier(bool reportError = true);
972   friend class cmCMakePolicyCommand;
973   class IncludeScope;
974   friend class IncludeScope;
975
976   // stack of policy settings
977   struct PolicyStackEntry: public cmPolicies::PolicyMap
978   {
979     typedef cmPolicies::PolicyMap derived;
980     PolicyStackEntry(bool w = false): derived(), Weak(w) {}
981     PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
982     PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
983     bool Weak;
984   };
985   typedef std::vector<PolicyStackEntry> PolicyStackType;
986   PolicyStackType PolicyStack;
987   std::vector<PolicyStackType::size_type> PolicyBarriers;
988   cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
989
990   bool CheckCMP0000;
991
992   // Enforce rules about CMakeLists.txt files.
993   void EnforceDirectoryLevelRules();
994 };
995
996 //----------------------------------------------------------------------------
997 // Helper class to make sure the call stack is valid.
998 class cmMakefileCall
999 {
1000 public:
1001   cmMakefileCall(cmMakefile* mf,
1002                  cmListFileContext const& lfc,
1003                  cmExecutionStatus& status): Makefile(mf)
1004     {
1005     cmMakefile::CallStackEntry entry = {&lfc, &status};
1006     this->Makefile->CallStack.push_back(entry);
1007     }
1008   ~cmMakefileCall()
1009     {
1010     this->Makefile->CallStack.pop_back();
1011     }
1012 private:
1013   cmMakefile* Makefile;
1014 };
1015
1016 #endif
Note: See TracBrowser for help on using the browser.