1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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 ============================================================================*/
15 #include "cmCacheManager.h"
16 #include "cmExecutionStatus.h"
17 #include "cmListFileCache.h"
18 #include "cmPolicies.h"
19 #include "cmPropertyMap.h"
20 #include "cmSystemTools.h"
22 #include "cmNewLineStyle.h"
25 #if defined(CMAKE_BUILD_WITH_CMAKE)
26 #include "cmSourceGroup.h"
29 #include <cmsys/auto_ptr.hxx>
30 #include <cmsys/RegularExpression.hxx>
32 class cmFunctionBlocker;
34 class cmInstallGenerator;
35 class cmLocalGenerator;
39 class cmTestGenerator;
40 class cmVariableWatch;
43 class cmCMakePolicyCommand;
46 * \brief Process the input CMakeLists.txt file.
48 * Process and store into memory the input CMakeLists.txt file.
49 * Each CMakeLists.txt file is parsed and the commands found there
50 * are added into the build process.
55 cmsys::auto_ptr<Internals> Internal;
58 * Return the major and minor version of the cmake that
59 * was used to write the currently loaded cache, note
60 * this method will not work before the cache is loaded.
62 unsigned int GetCacheMajorVersion();
63 unsigned int GetCacheMinorVersion();
65 /* Check for unused variables in this scope */
66 void CheckForUnusedVariables() const;
67 /* Mark a variable as used */
68 void MarkVariableAsUsed(const char* var);
69 /* return true if a variable has been initialized */
70 bool VariableInitialized(const char* ) const;
71 /* return true if a variable has been used */
72 bool VariableUsed(const char* ) const;
73 /** Return whether compatibility features needed for a version of
74 the cache or lower should be enabled. */
75 bool NeedCacheCompatibility(int major, int minor);
78 * Construct an empty makefile.
81 cmMakefile(const cmMakefile& mf);
89 * Read and parse a CMakeLists.txt file.
91 bool ReadListFile(const char* listfile,
92 const char* external= 0,
93 std::string* fullPath= 0,
94 bool noPolicyScope = true);
97 * Add a function blocker to this makefile
99 void AddFunctionBlocker(cmFunctionBlocker* fb);
102 * Remove the function blocker whose scope ends with the given command.
103 * This returns ownership of the function blocker object.
105 cmsys::auto_ptr<cmFunctionBlocker>
106 RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
108 /** Push/pop a lexical (function blocker) barrier automatically. */
112 LexicalPushPop(cmMakefile* mf);
114 void Quiet() { this->ReportError = false; }
116 cmMakefile* Makefile;
119 friend class LexicalPushPop;
122 * Try running cmake and building a file. This is used for dynalically
123 * loaded commands, not as part of the usual build process.
125 int TryCompile(const char *srcdir, const char *bindir,
126 const char *projectName, const char *targetName,
128 const std::vector<std::string> *cmakeArgs,
129 std::string *output);
132 * Specify the makefile generator. This is platform/compiler
133 * dependent, although the interface is through a generic
136 void SetLocalGenerator(cmLocalGenerator*);
138 ///! Get the current makefile generator.
139 cmLocalGenerator* GetLocalGenerator()
140 { return this->LocalGenerator;}
143 * Test whether compatibility is set to a given version or lower.
145 bool NeedBackwardsCompatibility(unsigned int major,
147 unsigned int patch = 0xFFu);
150 * Help enforce global target name uniqueness.
152 bool EnforceUniqueName(std::string const& name, std::string& msg,
153 bool isCustom = false);
156 * Perform FinalPass, Library dependency analysis etc before output of the
159 void ConfigureFinalPass();
162 * run the final pass on all commands.
167 * Print the object state to std::cout.
171 /** Add a custom command to the build. */
172 void AddCustomCommandToTarget(const char* target,
173 const std::vector<std::string>& depends,
174 const cmCustomCommandLines& commandLines,
175 cmTarget::CustomCommandType type,
176 const char* comment, const char* workingDir,
177 bool escapeOldStyle = true);
178 cmSourceFile* AddCustomCommandToOutput(
179 const std::vector<std::string>& outputs,
180 const std::vector<std::string>& depends,
181 const char* main_dependency,
182 const cmCustomCommandLines& commandLines,
183 const char* comment, const char* workingDir,
184 bool replace = false,
185 bool escapeOldStyle = true);
186 cmSourceFile* AddCustomCommandToOutput(
188 const std::vector<std::string>& depends,
189 const char* main_dependency,
190 const cmCustomCommandLines& commandLines,
191 const char* comment, const char* workingDir,
192 bool replace = false,
193 bool escapeOldStyle = true);
194 void AddCustomCommandOldStyle(const char* target,
195 const std::vector<std::string>& outputs,
196 const std::vector<std::string>& depends,
198 const cmCustomCommandLines& commandLines,
199 const char* comment);
202 * Add a define flag to the build.
204 void AddDefineFlag(const char* definition);
205 void RemoveDefineFlag(const char* definition);
207 /** Create a new imported target with the name and type given. */
208 cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
211 cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
214 * Add an executable to the build.
216 cmTarget* AddExecutable(const char *exename,
217 const std::vector<std::string> &srcs,
218 bool excludeFromAll = false);
221 * Add a utility to the build. A utiltity target is a command that
222 * is run every time the target is built.
224 void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
225 const std::vector<std::string>& depends,
226 const char* workingDirectory,
232 cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll,
233 const char* workingDirectory,
234 const std::vector<std::string>& depends,
235 const cmCustomCommandLines& commandLines,
236 bool escapeOldStyle = true,
237 const char* comment = 0);
240 * Add a link library to the build.
242 void AddLinkLibrary(const char*);
243 void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
244 void AddLinkLibraryForTarget(const char *tgt, const char*,
245 cmTarget::LinkLibraryType type);
246 void AddLinkDirectoryForTarget(const char *tgt, const char* d);
249 * Add a link directory to the build.
251 void AddLinkDirectory(const char*);
254 * Get the list of link directories
256 std::vector<std::string>& GetLinkDirectories()
258 return this->LinkDirectories;
260 const std::vector<std::string>& GetLinkDirectories() const
262 return this->LinkDirectories;
264 void SetLinkDirectories(const std::vector<std::string>& vec)
266 this->LinkDirectories = vec;
270 * Add a subdirectory to the build.
272 void AddSubDirectory(const char*, bool excludeFromAll=false,
273 bool preorder = false);
274 void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
275 bool excludeFromAll, bool preorder,
279 * Configure a subdirectory
281 void ConfigureSubDirectory(cmLocalGenerator *);
284 * Add an include directory to the build.
286 void AddIncludeDirectory(const char*, bool before = false);
289 * Add a variable definition to the build. This variable
290 * can be used in CMake to refer to lists, directories, etc.
292 void AddDefinition(const char* name, const char* value);
293 ///! Add a definition to this makefile and the global cmake cache.
294 void AddCacheDefinition(const char* name, const char* value,
296 cmCacheManager::CacheEntryType type,
300 * Add bool variable definition to the build.
302 void AddDefinition(const char* name, bool);
305 * Remove a variable definition from the build. This is not valid
306 * for cache entries, and will only affect the current makefile.
308 void RemoveDefinition(const char* name);
309 ///! Remove a definition from the cache.
310 void RemoveCacheDefinition(const char* name);
313 * Specify the name of the project for this build.
315 void SetProjectName(const char*);
318 * Get the name of the project for this build.
320 const char* GetProjectName() const
322 return this->ProjectName.c_str();
325 /** Get the configurations to be generated. */
326 const char* GetConfigurations(std::vector<std::string>& configs,
327 bool single = true) const;
330 * Set the name of the library.
332 cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
333 const std::vector<std::string> &srcs,
334 bool excludeFromAll = false);
336 #if defined(CMAKE_BUILD_WITH_CMAKE)
338 * Add a root source group for consideration when adding a new source.
340 void AddSourceGroup(const char* name, const char* regex=0);
343 * Add a source group for consideration when adding a new source.
346 void AddSourceGroup(const std::vector<std::string>& name,
347 const char* regex=0);
353 * Set, Push, Pop policy values for CMake.
355 bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
356 bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
357 cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
358 bool SetPolicyVersion(const char *version);
359 void RecordPolicies(cmPolicies::PolicyMap& pm);
362 /** Helper class to push and pop policies automatically. */
366 PolicyPushPop(cmMakefile* m,
368 cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
370 void Quiet() { this->ReportError = false; }
372 cmMakefile* Makefile;
375 friend class PolicyPushPop;
378 * Get the Policies Instance
380 cmPolicies *GetPolicies();
383 * Add an auxiliary directory to the build.
385 void AddExtraDirectory(const char* dir);
389 * Add an auxiliary directory to the build.
391 void MakeStartDirectoriesCurrent()
393 this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
394 this->cmStartDirectory.c_str());
395 this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
396 this->StartOutputDirectory.c_str());
401 * Set/Get the home directory (or output directory) in the project. The
402 * home directory is the top directory of the project. It is where
403 * CMakeSetup or configure was run. Remember that CMake processes
404 * CMakeLists files by recursing up the tree starting at the StartDirectory
405 * and going up until it reaches the HomeDirectory.
407 void SetHomeDirectory(const char* dir);
408 const char* GetHomeDirectory() const
410 return this->cmHomeDirectory.c_str();
412 void SetHomeOutputDirectory(const char* lib);
413 const char* GetHomeOutputDirectory() const
415 return this->HomeOutputDirectory.c_str();
420 * Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script.
422 void SetScriptModeFile(const char* scriptfile);
425 * Set CMAKE_ARGC, CMAKE_ARGV0 ... variables.
427 void SetArgcArgv(const std::vector<std::string>& args);
431 * Set/Get the start directory (or output directory). The start directory
432 * is the directory of the CMakeLists.txt file that started the current
433 * round of processing. Remember that CMake processes CMakeLists files by
434 * recursing up the tree starting at the StartDirectory and going up until
435 * it reaches the HomeDirectory.
437 void SetStartDirectory(const char* dir)
439 this->cmStartDirectory = dir;
440 cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
441 this->cmStartDirectory =
442 cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str());
443 this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
444 this->cmStartDirectory.c_str());
446 const char* GetStartDirectory() const
448 return this->cmStartDirectory.c_str();
450 void SetStartOutputDirectory(const char* lib)
452 this->StartOutputDirectory = lib;
453 cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
454 this->StartOutputDirectory =
455 cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str());
456 cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
457 this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
458 this->StartOutputDirectory.c_str());
460 const char* GetStartOutputDirectory() const
462 return this->StartOutputDirectory.c_str();
466 const char* GetCurrentDirectory() const
468 return this->cmStartDirectory.c_str();
470 const char* GetCurrentOutputDirectory() const
472 return this->StartOutputDirectory.c_str();
475 /* Get the current CMakeLists.txt file that is being processed. This
476 * is just used in order to be able to 'branch' from one file to a second
478 const char* GetCurrentListFile() const
480 return this->cmCurrentListFile.c_str();
486 * Set a regular expression that include files must match
487 * in order to be considered as part of the depend information.
489 void SetIncludeRegularExpression(const char* regex)
491 this->IncludeFileRegularExpression = regex;
493 const char* GetIncludeRegularExpression()
495 return this->IncludeFileRegularExpression.c_str();
499 * Set a regular expression that include files that are not found
500 * must match in order to be considered a problem.
502 void SetComplainRegularExpression(const char* regex)
504 this->ComplainFileRegularExpression = regex;
506 const char* GetComplainRegularExpression()
508 return this->ComplainFileRegularExpression.c_str();
512 * Get the list of targets
514 cmTargets &GetTargets() { return this->Targets; }
516 * Get the list of targets, const version
518 const cmTargets &GetTargets() const { return this->Targets; }
520 cmTarget* FindTarget(const char* name);
522 /** Find a target to use in place of the given name. The target
523 returned may be imported or built within the project. */
524 cmTarget* FindTargetToUse(const char* name);
527 * Mark include directories as system directories.
529 void AddSystemIncludeDirectory(const char* dir);
530 bool IsSystemIncludeDirectory(const char* dir);
532 /** Expand out any arguements in the vector that have ; separated
533 * strings into multiple arguements. A new vector is created
534 * containing the expanded versions of all arguments in argsIn.
535 * This method differes from the one in cmSystemTools in that if
536 * the CmakeLists file is version 1.2 or earlier it will check for
537 * source lists being used without ${} around them
539 void ExpandSourceListArguments(std::vector<std::string> const& argsIn,
540 std::vector<std::string>& argsOut,
541 unsigned int startArgumentIndex);
543 /** Get a cmSourceFile pointer for a given source name, if the name is
544 * not found, then a null pointer is returned.
546 cmSourceFile* GetSource(const char* sourceName);
548 /** Get a cmSourceFile pointer for a given source name, if the name is
549 * not found, then create the source file and return it. generated
550 * indicates if it is a generated file, this is used in determining
551 * how to create the source file instance e.g. name
553 cmSourceFile* GetOrCreateSource(const char* sourceName,
554 bool generated = false);
557 * Obtain a list of auxiliary source directories.
559 std::vector<std::string>& GetAuxSourceDirectories()
560 {return this->AuxSourceDirectories;}
564 * Return a list of extensions associated with source and header
567 const std::vector<std::string>& GetSourceExtensions() const
568 {return this->SourceFileExtensions;}
569 const std::vector<std::string>& GetHeaderExtensions() const
570 {return this->HeaderFileExtensions;}
574 * Given a variable name, return its value (as a string).
575 * If the variable is not found in this makefile instance, the
576 * cache is then queried.
578 const char* GetDefinition(const char*) const;
579 const char* GetSafeDefinition(const char*) const;
580 const char* GetRequiredDefinition(const char* name) const;
581 bool IsDefinitionSet(const char*) const;
583 * Get the list of all variables in the current space. If argument
584 * cacheonly is specified and is greater than 0, then only cache
585 * variables will be listed.
587 std::vector<std::string> GetDefinitions(int cacheonly=0) const;
589 /** Test a boolean cache entry to see if it is true or false,
590 * returns false if no entry defined.
592 bool IsOn(const char* name) const;
593 bool IsSet(const char* name) const;
595 /** Return whether the target platform is 64-bit. */
596 bool PlatformIs64Bit() const;
598 /** Retrieve soname flag for the specified language if supported */
599 const char* GetSONameFlag(const char* language) const;
602 * Get a list of preprocessor define flags.
604 const char* GetDefineFlags()
605 {return this->DefineFlags.c_str();}
608 * Make sure CMake can write this file
610 bool CanIWriteThisFile(const char* fileName);
612 #if defined(CMAKE_BUILD_WITH_CMAKE)
614 * Get the vector source groups.
616 const std::vector<cmSourceGroup>& GetSourceGroups() const
617 { return this->SourceGroups; }
620 * Get the source group
622 cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name);
626 * Get the vector of list files on which this makefile depends
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);}
635 * Get the list file stack as a string
637 std::string GetListFileStack();
640 * Get the current context backtrace.
642 bool GetBacktrace(cmListFileBacktrace& backtrace) const;
645 * Get the vector of files created by this makefile
647 const std::vector<std::string>& GetOutputFiles() const
648 { return this->OutputFiles; }
649 void AddCMakeOutputFile(const char* file)
650 { this->OutputFiles.push_back(file);}
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.
659 const char *ExpandVariablesInString(std::string& source);
660 const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
663 const char* filename = 0,
665 bool removeEmpty = false,
666 bool replaceAt = true);
669 * Remove any remaining variables in the string. Anything with ${var} or
670 * \@var\@ will be removed.
672 void RemoveVariablesInString(std::string& source,
673 bool atOnly = false) const;
676 * Expand variables in the makefiles ivars such as link directories etc
678 void ExpandVariables();
681 * Replace variables and #cmakedefine lines in the given string.
682 * See cmConfigureFileCommand for details.
684 void ConfigureString(const std::string& input, std::string& output,
685 bool atOnly, bool escapeQuotes);
688 * Copy file but change lines acording to ConfigureString
690 int ConfigureFile(const char* infile, const char* outfile,
691 bool copyonly, bool atOnly, bool escapeQuotes,
692 const cmNewLineStyle& = cmNewLineStyle());
695 #if defined(CMAKE_BUILD_WITH_CMAKE)
697 * find what source group this source is in
699 cmSourceGroup& FindSourceGroup(const char* source,
700 std::vector<cmSourceGroup> &groups);
704 * Print a command's invocation
706 void PrintCommandTrace(const cmListFileFunction& lff);
709 * Execute a single CMake command. Returns true if the command
710 * succeeded or false if it failed.
712 bool ExecuteCommand(const cmListFileFunction& lff,
713 cmExecutionStatus &status);
715 /** Check if a command exists. */
716 bool CommandExists(const char* name) const;
719 * Add a command to this cmake instance
721 void AddCommand(cmCommand* );
723 ///! Enable support for named language, if nil then all languages are
725 void EnableLanguage(std::vector<std::string>const& languages, bool optional);
728 * Set/Get the name of the parent directories CMakeLists file
729 * given a current CMakeLists file name
731 cmCacheManager *GetCacheManager() const;
734 * Get the variable watch. This is used to determine when certain variables
737 #ifdef CMAKE_BUILD_WITH_CMAKE
738 cmVariableWatch* GetVariableWatch() const;
741 ///! Display progress or status message.
742 void DisplayStatus(const char*, float);
745 * Expand the given list file arguments into the full set after
746 * variable replacement and list expansion.
748 bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
749 std::vector<std::string>& outArgs);
753 cmake *GetCMakeInstance() const;
756 * Get all the source files this makefile knows about
758 const std::vector<cmSourceFile*> &GetSourceFiles() const
759 {return this->SourceFiles;}
760 std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
763 * Is there a source file that has the provided source file as an output?
764 * if so then return it
766 cmSourceFile *GetSourceFileWithOutput(const char *outName);
769 * Add a macro to the list of macros. The arguments should be name of the
770 * macro and a documentation signature of it
772 void AddMacro(const char* name, const char* signature);
774 ///! Add a new cmTest to the list of tests for this makefile.
775 cmTest* CreateTest(const char* testName);
777 /** Get a cmTest pointer for a given test name, if the name is
778 * not found, then a null pointer is returned.
780 cmTest* GetTest(const char* testName) const;
783 * Get a list of macros as a ; separated string
785 void GetListOfMacros(std::string& macros);
788 * Return a location of a file in cmake or custom modules directory
790 std::string GetModulesFile(const char* name);
792 ///! Set/Get a property of this directory
793 void SetProperty(const char *prop, const char *value);
794 void AppendProperty(const char *prop, const char *value,bool asString=false);
795 const char *GetProperty(const char *prop);
796 const char *GetPropertyOrDefinition(const char *prop);
797 const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
798 bool GetPropertyAsBool(const char *prop);
800 const char* GetFeature(const char* feature, const char* config);
802 // Get the properties
803 cmPropertyMap &GetProperties() { return this->Properties; };
805 ///! Initialize a makefile from its parent
806 void InitializeFromParent();
808 ///! Set/Get the preorder flag
809 void SetPreOrder(bool p) { this->PreOrder = p; }
810 bool GetPreOrder() const { return this->PreOrder; }
812 void AddInstallGenerator(cmInstallGenerator* g)
813 { if(g) this->InstallGenerators.push_back(g); }
814 std::vector<cmInstallGenerator*>& GetInstallGenerators()
815 { return this->InstallGenerators; }
817 void AddTestGenerator(cmTestGenerator* g)
818 { if(g) this->TestGenerators.push_back(g); }
819 std::vector<cmTestGenerator*>& GetTestGenerators()
820 { return this->TestGenerators; }
822 // Define the properties
823 static void DefineProperties(cmake *cm);
825 // push and pop variable scopes
828 void RaiseScope(const char *var, const char *value);
830 /** Helper class to push and pop scopes automatically. */
834 ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
835 ~ScopePushPop() { this->Makefile->PopScope(); }
837 cmMakefile* Makefile;
840 void IssueMessage(cmake::MessageType t,
841 std::string const& text) const;
843 /** Set whether or not to report a CMP0000 violation. */
844 void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
847 // add link libraries and directories to the target
848 void AddGlobalLinkInformation(const char* name, cmTarget& target);
850 // Check for a an unused variable
851 void CheckForUnused(const char* reason, const char* name) const;
854 std::vector<std::string> AuxSourceDirectories; //
856 std::string cmStartDirectory;
857 std::string StartOutputDirectory;
858 std::string cmHomeDirectory;
859 std::string HomeOutputDirectory;
860 std::string cmCurrentListFile;
862 std::string ProjectName; // project name
864 // libraries, classes, and executables
866 std::vector<cmSourceFile*> SourceFiles;
869 std::map<cmStdString, cmTest*> Tests;
871 // The link-library paths. Order matters, use std::vector (not std::set).
872 std::vector<std::string> LinkDirectories;
874 // The set of include directories that are marked as system include
876 std::set<cmStdString> SystemIncludeDirectories;
878 std::vector<std::string> ListFiles; // list of command files loaded
879 std::vector<std::string> OutputFiles; // list of command files loaded
882 cmTarget::LinkLibraryVectorType LinkLibraries;
884 std::vector<cmInstallGenerator*> InstallGenerators;
885 std::vector<cmTestGenerator*> TestGenerators;
887 std::string IncludeFileRegularExpression;
888 std::string ComplainFileRegularExpression;
889 std::vector<std::string> SourceFileExtensions;
890 std::vector<std::string> HeaderFileExtensions;
891 std::string DefineFlags;
893 // Track the value of the computed DEFINITIONS property.
894 void AddDefineFlag(const char*, std::string&);
895 void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
896 std::string DefineFlagsOrig;
898 #if defined(CMAKE_BUILD_WITH_CMAKE)
899 std::vector<cmSourceGroup> SourceGroups;
902 std::vector<cmCommand*> FinalPassCommands;
903 cmLocalGenerator* LocalGenerator;
904 bool IsFunctionBlocked(const cmListFileFunction& lff,
905 cmExecutionStatus &status);
910 bool ParseDefineFlag(std::string const& definition, bool remove);
912 bool EnforceUniqueDir(const char* srcPath, const char* binPath);
914 void ReadSources(std::ifstream& fin, bool t);
915 friend class cmMakeDepend; // make depend needs direct access
916 // to the Sources array
917 void PrintStringVector(const char* s, const
918 std::vector<std::pair<cmStdString, bool> >& v) const;
919 void PrintStringVector(const char* s,
920 const std::vector<std::string>& v) const;
922 void AddDefaultDefinitions();
923 typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
924 FunctionBlockersType FunctionBlockers;
925 std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
926 void PushFunctionBlockerBarrier();
927 void PopFunctionBlockerBarrier(bool reportError = true);
929 typedef std::map<cmStdString, cmStdString> StringStringMap;
930 StringStringMap MacrosMap;
932 std::map<cmStdString, bool> SubDirectoryOrder;
934 cmsys::RegularExpression cmDefineRegex;
935 cmsys::RegularExpression cmDefine01Regex;
936 cmsys::RegularExpression cmAtVarRegex;
938 cmPropertyMap Properties;
940 // should this makefile be processed before or after processing the parent
943 // Unused variable flags
945 bool CheckSystemVars;
947 // stack of list files being read
948 std::deque<cmStdString> ListFileStack;
950 // stack of commands being invoked.
951 struct CallStackEntry
953 cmListFileContext const* Context;
954 cmExecutionStatus* Status;
956 typedef std::deque<CallStackEntry> CallStackType;
957 CallStackType CallStack;
958 friend class cmMakefileCall;
960 cmTarget* FindBasicTarget(const char* name);
961 std::vector<cmTarget*> ImportedTargetsOwned;
962 std::map<cmStdString, cmTarget*> ImportedTargets;
964 // Internal policy stack management.
965 void PushPolicy(bool weak = false,
966 cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
968 void PushPolicyBarrier();
969 void PopPolicyBarrier(bool reportError = true);
970 friend class cmCMakePolicyCommand;
972 friend class IncludeScope;
974 // stack of policy settings
975 struct PolicyStackEntry: public cmPolicies::PolicyMap
977 typedef cmPolicies::PolicyMap derived;
978 PolicyStackEntry(bool w = false): derived(), Weak(w) {}
979 PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
980 PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
983 typedef std::vector<PolicyStackEntry> PolicyStackType;
984 PolicyStackType PolicyStack;
985 std::vector<PolicyStackType::size_type> PolicyBarriers;
986 cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
990 // Enforce rules about CMakeLists.txt files.
991 void EnforceDirectoryLevelRules();
994 //----------------------------------------------------------------------------
995 // Helper class to make sure the call stack is valid.
999 cmMakefileCall(cmMakefile* mf,
1000 cmListFileContext const& lfc,
1001 cmExecutionStatus& status): Makefile(mf)
1003 cmMakefile::CallStackEntry entry = {&lfc, &status};
1004 this->Makefile->CallStack.push_back(entry);
1008 this->Makefile->CallStack.pop_back();
1011 cmMakefile* Makefile;