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"
23 #include "cmGeneratorTarget.h"
26 #if defined(CMAKE_BUILD_WITH_CMAKE)
27 #include "cmSourceGroup.h"
30 #include <cmsys/auto_ptr.hxx>
31 #include <cmsys/RegularExpression.hxx>
32 #if defined(CMAKE_BUILD_WITH_CMAKE)
33 # include <cmsys/hash_map.hxx>
36 class cmFunctionBlocker;
38 class cmInstallGenerator;
39 class cmLocalGenerator;
43 class cmTestGenerator;
44 class cmVariableWatch;
47 class cmCMakePolicyCommand;
50 * \brief Process the input CMakeLists.txt file.
52 * Process and store into memory the input CMakeLists.txt file.
53 * Each CMakeLists.txt file is parsed and the commands found there
54 * are added into the build process.
59 cmsys::auto_ptr<Internals> Internal;
62 * Return the major and minor version of the cmake that
63 * was used to write the currently loaded cache, note
64 * this method will not work before the cache is loaded.
66 unsigned int GetCacheMajorVersion();
67 unsigned int GetCacheMinorVersion();
69 /* Check for unused variables in this scope */
70 void CheckForUnusedVariables() const;
71 /* Mark a variable as used */
72 void MarkVariableAsUsed(const char* var);
73 /* return true if a variable has been initialized */
74 bool VariableInitialized(const char* ) const;
75 /* return true if a variable has been used */
76 bool VariableUsed(const char* ) const;
77 /** Return whether compatibility features needed for a version of
78 the cache or lower should be enabled. */
79 bool NeedCacheCompatibility(int major, int minor);
82 * Construct an empty makefile.
85 cmMakefile(const cmMakefile& mf);
93 * Read and parse a CMakeLists.txt file.
95 bool ReadListFile(const char* listfile,
96 const char* external= 0,
97 std::string* fullPath= 0,
98 bool noPolicyScope = true);
101 * Add a function blocker to this makefile
103 void AddFunctionBlocker(cmFunctionBlocker* fb);
106 * Remove the function blocker whose scope ends with the given command.
107 * This returns ownership of the function blocker object.
109 cmsys::auto_ptr<cmFunctionBlocker>
110 RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
112 /** Push/pop a lexical (function blocker) barrier automatically. */
116 LexicalPushPop(cmMakefile* mf);
118 void Quiet() { this->ReportError = false; }
120 cmMakefile* Makefile;
123 friend class LexicalPushPop;
126 * Try running cmake and building a file. This is used for dynalically
127 * loaded commands, not as part of the usual build process.
129 int TryCompile(const char *srcdir, const char *bindir,
130 const char *projectName, const char *targetName,
132 const std::vector<std::string> *cmakeArgs,
133 std::string *output);
135 bool GetIsSourceFileTryCompile() const;
138 * Specify the makefile generator. This is platform/compiler
139 * dependent, although the interface is through a generic
142 void SetLocalGenerator(cmLocalGenerator*);
144 ///! Get the current makefile generator.
145 cmLocalGenerator* GetLocalGenerator()
146 { return this->LocalGenerator;}
149 * Test whether compatibility is set to a given version or lower.
151 bool NeedBackwardsCompatibility(unsigned int major,
153 unsigned int patch = 0xFFu);
156 * Help enforce global target name uniqueness.
158 bool EnforceUniqueName(std::string const& name, std::string& msg,
159 bool isCustom = false);
162 * Perform FinalPass, Library dependency analysis etc before output of the
165 void ConfigureFinalPass();
168 * run the final pass on all commands.
173 * Print the object state to std::cout.
177 /** Add a custom command to the build. */
178 void AddCustomCommandToTarget(const char* target,
179 const std::vector<std::string>& depends,
180 const cmCustomCommandLines& commandLines,
181 cmTarget::CustomCommandType type,
182 const char* comment, const char* workingDir,
183 bool escapeOldStyle = true);
184 cmSourceFile* AddCustomCommandToOutput(
185 const std::vector<std::string>& outputs,
186 const std::vector<std::string>& depends,
187 const char* main_dependency,
188 const cmCustomCommandLines& commandLines,
189 const char* comment, const char* workingDir,
190 bool replace = false,
191 bool escapeOldStyle = true);
192 cmSourceFile* AddCustomCommandToOutput(
194 const std::vector<std::string>& depends,
195 const char* main_dependency,
196 const cmCustomCommandLines& commandLines,
197 const char* comment, const char* workingDir,
198 bool replace = false,
199 bool escapeOldStyle = true);
200 void AddCustomCommandOldStyle(const char* target,
201 const std::vector<std::string>& outputs,
202 const std::vector<std::string>& depends,
204 const cmCustomCommandLines& commandLines,
205 const char* comment);
208 * Add a define flag to the build.
210 void AddDefineFlag(const char* definition);
211 void RemoveDefineFlag(const char* definition);
212 void AddCompileOption(const char* option);
214 /** Create a new imported target with the name and type given. */
215 cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
218 cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
221 * Add an executable to the build.
223 cmTarget* AddExecutable(const char *exename,
224 const std::vector<std::string> &srcs,
225 bool excludeFromAll = false);
228 * Add a utility to the build. A utiltity target is a command that
229 * is run every time the target is built.
231 void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
232 const std::vector<std::string>& depends,
233 const char* workingDirectory,
239 cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll,
240 const char* workingDirectory,
241 const std::vector<std::string>& depends,
242 const cmCustomCommandLines& commandLines,
243 bool escapeOldStyle = true,
244 const char* comment = 0);
247 * Add a link library to the build.
249 void AddLinkLibrary(const char*);
250 void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
251 void AddLinkLibraryForTarget(const char *tgt, const char*,
252 cmTarget::LinkLibraryType type);
253 void AddLinkDirectoryForTarget(const char *tgt, const char* d);
256 * Add a link directory to the build.
258 void AddLinkDirectory(const char*);
261 * Get the list of link directories
263 std::vector<std::string>& GetLinkDirectories()
265 return this->LinkDirectories;
267 const std::vector<std::string>& GetLinkDirectories() const
269 return this->LinkDirectories;
271 void SetLinkDirectories(const std::vector<std::string>& vec)
273 this->LinkDirectories = vec;
277 * Add a subdirectory to the build.
279 void AddSubDirectory(const char*, bool excludeFromAll=false,
280 bool preorder = false);
281 void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
282 bool excludeFromAll, bool preorder,
286 * Configure a subdirectory
288 void ConfigureSubDirectory(cmLocalGenerator *);
291 * Add an include directory to the build.
293 void AddIncludeDirectories(const std::vector<std::string> &incs,
294 bool before = false);
297 * Add a variable definition to the build. This variable
298 * can be used in CMake to refer to lists, directories, etc.
300 void AddDefinition(const char* name, const char* value);
301 ///! Add a definition to this makefile and the global cmake cache.
302 void AddCacheDefinition(const char* name, const char* value,
304 cmCacheManager::CacheEntryType type,
308 * Add bool variable definition to the build.
310 void AddDefinition(const char* name, bool);
313 * Remove a variable definition from the build. This is not valid
314 * for cache entries, and will only affect the current makefile.
316 void RemoveDefinition(const char* name);
317 ///! Remove a definition from the cache.
318 void RemoveCacheDefinition(const char* name);
321 * Specify the name of the project for this build.
323 void SetProjectName(const char*);
326 * Get the name of the project for this build.
328 const char* GetProjectName() const
330 return this->ProjectName.c_str();
333 /** Get the configurations to be generated. */
334 const char* GetConfigurations(std::vector<std::string>& configs,
335 bool single = true) const;
338 * Set the name of the library.
340 cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
341 const std::vector<std::string> &srcs,
342 bool excludeFromAll = false);
343 void AddAlias(const char *libname, cmTarget *tgt);
345 #if defined(CMAKE_BUILD_WITH_CMAKE)
347 * Add a root source group for consideration when adding a new source.
349 void AddSourceGroup(const char* name, const char* regex=0);
352 * Add a source group for consideration when adding a new source.
355 void AddSourceGroup(const std::vector<std::string>& name,
356 const char* regex=0);
362 * Set, Push, Pop policy values for CMake.
364 bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
365 bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
366 cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
367 bool SetPolicyVersion(const char *version);
368 void RecordPolicies(cmPolicies::PolicyMap& pm);
371 /** Helper class to push and pop policies automatically. */
375 PolicyPushPop(cmMakefile* m,
377 cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
379 void Quiet() { this->ReportError = false; }
381 cmMakefile* Makefile;
384 friend class PolicyPushPop;
387 * Get the Policies Instance
389 cmPolicies *GetPolicies();
392 * Add an auxiliary directory to the build.
394 void AddExtraDirectory(const char* dir);
398 * Add an auxiliary directory to the build.
400 void MakeStartDirectoriesCurrent()
402 this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
403 this->cmStartDirectory.c_str());
404 this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
405 this->StartOutputDirectory.c_str());
410 * Set/Get the home directory (or output directory) in the project. The
411 * home directory is the top directory of the project. It is where
412 * CMakeSetup or configure was run. Remember that CMake processes
413 * CMakeLists files by recursing up the tree starting at the StartDirectory
414 * and going up until it reaches the HomeDirectory.
416 void SetHomeDirectory(const char* dir);
417 const char* GetHomeDirectory() const
419 return this->cmHomeDirectory.c_str();
421 void SetHomeOutputDirectory(const char* lib);
422 const char* GetHomeOutputDirectory() const
424 return this->HomeOutputDirectory.c_str();
429 * Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script.
431 void SetScriptModeFile(const char* scriptfile);
434 * Set CMAKE_ARGC, CMAKE_ARGV0 ... variables.
436 void SetArgcArgv(const std::vector<std::string>& args);
440 * Set/Get the start directory (or output directory). The start directory
441 * is the directory of the CMakeLists.txt file that started the current
442 * round of processing. Remember that CMake processes CMakeLists files by
443 * recursing up the tree starting at the StartDirectory and going up until
444 * it reaches the HomeDirectory.
446 void SetStartDirectory(const char* dir)
448 this->cmStartDirectory = dir;
449 cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
450 this->cmStartDirectory =
451 cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str());
452 this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
453 this->cmStartDirectory.c_str());
455 const char* GetStartDirectory() const
457 return this->cmStartDirectory.c_str();
459 void SetStartOutputDirectory(const char* lib)
461 this->StartOutputDirectory = lib;
462 cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
463 this->StartOutputDirectory =
464 cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str());
465 cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
466 this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
467 this->StartOutputDirectory.c_str());
469 const char* GetStartOutputDirectory() const
471 return this->StartOutputDirectory.c_str();
475 const char* GetCurrentDirectory() const
477 return this->cmStartDirectory.c_str();
479 const char* GetCurrentOutputDirectory() const
481 return this->StartOutputDirectory.c_str();
484 /* Get the current CMakeLists.txt file that is being processed. This
485 * is just used in order to be able to 'branch' from one file to a second
487 const char* GetCurrentListFile() const
489 return this->cmCurrentListFile.c_str();
495 * Set a regular expression that include files must match
496 * in order to be considered as part of the depend information.
498 void SetIncludeRegularExpression(const char* regex)
500 this->IncludeFileRegularExpression = regex;
502 const char* GetIncludeRegularExpression()
504 return this->IncludeFileRegularExpression.c_str();
508 * Set a regular expression that include files that are not found
509 * must match in order to be considered a problem.
511 void SetComplainRegularExpression(const char* regex)
513 this->ComplainFileRegularExpression = regex;
515 const char* GetComplainRegularExpression()
517 return this->ComplainFileRegularExpression.c_str();
521 * Get the list of targets
523 cmTargets &GetTargets() { return this->Targets; }
525 * Get the list of targets, const version
527 const cmTargets &GetTargets() const { return this->Targets; }
528 const std::vector<cmTarget*> &GetOwnedImportedTargets() const
530 return this->ImportedTargetsOwned;
533 const cmGeneratorTargetsType &GetGeneratorTargets() const
535 return this->GeneratorTargets;
538 void SetGeneratorTargets(const cmGeneratorTargetsType &targets)
540 this->GeneratorTargets = targets;
543 cmTarget* FindTarget(const char* name, bool excludeAliases = false);
545 /** Find a target to use in place of the given name. The target
546 returned may be imported or built within the project. */
547 cmTarget* FindTargetToUse(const char* name, bool excludeAliases = false);
548 bool IsAlias(const char *name);
549 cmGeneratorTarget* FindGeneratorTargetToUse(const char* name);
552 * Mark include directories as system directories.
554 void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
555 bool IsSystemIncludeDirectory(const char* dir, const char *config);
557 /** Expand out any arguements in the vector that have ; separated
558 * strings into multiple arguements. A new vector is created
559 * containing the expanded versions of all arguments in argsIn.
560 * This method differes from the one in cmSystemTools in that if
561 * the CmakeLists file is version 1.2 or earlier it will check for
562 * source lists being used without ${} around them
564 void ExpandSourceListArguments(std::vector<std::string> const& argsIn,
565 std::vector<std::string>& argsOut,
566 unsigned int startArgumentIndex);
568 /** Get a cmSourceFile pointer for a given source name, if the name is
569 * not found, then a null pointer is returned.
571 cmSourceFile* GetSource(const char* sourceName);
573 /** Get a cmSourceFile pointer for a given source name, if the name is
574 * not found, then create the source file and return it. generated
575 * indicates if it is a generated file, this is used in determining
576 * how to create the source file instance e.g. name
578 cmSourceFile* GetOrCreateSource(const char* sourceName,
579 bool generated = false);
582 * Obtain a list of auxiliary source directories.
584 std::vector<std::string>& GetAuxSourceDirectories()
585 {return this->AuxSourceDirectories;}
589 * Return a list of extensions associated with source and header
592 const std::vector<std::string>& GetSourceExtensions() const
593 {return this->SourceFileExtensions;}
594 const std::vector<std::string>& GetHeaderExtensions() const
595 {return this->HeaderFileExtensions;}
599 * Given a variable name, return its value (as a string).
600 * If the variable is not found in this makefile instance, the
601 * cache is then queried.
603 const char* GetDefinition(const char*) const;
604 const char* GetSafeDefinition(const char*) const;
605 const char* GetRequiredDefinition(const char* name) const;
606 bool IsDefinitionSet(const char*) const;
608 * Get the list of all variables in the current space. If argument
609 * cacheonly is specified and is greater than 0, then only cache
610 * variables will be listed.
612 std::vector<std::string> GetDefinitions(int cacheonly=0) const;
614 /** Test a boolean cache entry to see if it is true or false,
615 * returns false if no entry defined.
617 bool IsOn(const char* name) const;
618 bool IsSet(const char* name) const;
620 /** Return whether the target platform is 64-bit. */
621 bool PlatformIs64Bit() const;
623 /** Retrieve soname flag for the specified language if supported */
624 const char* GetSONameFlag(const char* language) const;
627 * Get a list of preprocessor define flags.
629 const char* GetDefineFlags()
630 {return this->DefineFlags.c_str();}
633 * Make sure CMake can write this file
635 bool CanIWriteThisFile(const char* fileName);
637 #if defined(CMAKE_BUILD_WITH_CMAKE)
639 * Get the vector source groups.
641 const std::vector<cmSourceGroup>& GetSourceGroups() const
642 { return this->SourceGroups; }
645 * Get the source group
647 cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name);
651 * Get the vector of list files on which this makefile depends
653 const std::vector<std::string>& GetListFiles() const
654 { return this->ListFiles; }
655 ///! When the file changes cmake will be re-run from the build system.
656 void AddCMakeDependFile(const std::string& file)
657 { this->ListFiles.push_back(file);}
660 * Get the list file stack as a string
662 std::string GetListFileStack();
665 * Get the current context backtrace.
667 bool GetBacktrace(cmListFileBacktrace& backtrace) const;
670 * Get the vector of files created by this makefile
672 const std::vector<std::string>& GetOutputFiles() const
673 { return this->OutputFiles; }
674 void AddCMakeOutputFile(const std::string& file)
675 { this->OutputFiles.push_back(file);}
678 * Expand all defined variables in the string.
679 * Defined variables come from the this->Definitions map.
680 * They are expanded with ${var} where var is the
681 * entry in the this->Definitions map. Also \@var\@ is
682 * expanded to match autoconf style expansions.
684 const char *ExpandVariablesInString(std::string& source);
685 const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
688 const char* filename = 0,
690 bool removeEmpty = false,
691 bool replaceAt = true);
694 * Remove any remaining variables in the string. Anything with ${var} or
695 * \@var\@ will be removed.
697 void RemoveVariablesInString(std::string& source,
698 bool atOnly = false) const;
701 * Expand variables in the makefiles ivars such as link directories etc
703 void ExpandVariablesCMP0019();
706 * Replace variables and #cmakedefine lines in the given string.
707 * See cmConfigureFileCommand for details.
709 void ConfigureString(const std::string& input, std::string& output,
710 bool atOnly, bool escapeQuotes);
713 * Copy file but change lines acording to ConfigureString
715 int ConfigureFile(const char* infile, const char* outfile,
716 bool copyonly, bool atOnly, bool escapeQuotes,
717 const cmNewLineStyle& = cmNewLineStyle());
720 #if defined(CMAKE_BUILD_WITH_CMAKE)
722 * find what source group this source is in
724 cmSourceGroup& FindSourceGroup(const char* source,
725 std::vector<cmSourceGroup> &groups);
729 * Print a command's invocation
731 void PrintCommandTrace(const cmListFileFunction& lff);
734 * Execute a single CMake command. Returns true if the command
735 * succeeded or false if it failed.
737 bool ExecuteCommand(const cmListFileFunction& lff,
738 cmExecutionStatus &status);
740 /** Check if a command exists. */
741 bool CommandExists(const char* name) const;
744 * Add a command to this cmake instance
746 void AddCommand(cmCommand* );
748 ///! Enable support for named language, if nil then all languages are
750 void EnableLanguage(std::vector<std::string>const& languages, bool optional);
753 * Set/Get the name of the parent directories CMakeLists file
754 * given a current CMakeLists file name
756 cmCacheManager *GetCacheManager() const;
759 * Get the variable watch. This is used to determine when certain variables
762 #ifdef CMAKE_BUILD_WITH_CMAKE
763 cmVariableWatch* GetVariableWatch() const;
766 ///! Display progress or status message.
767 void DisplayStatus(const char*, float);
770 * Expand the given list file arguments into the full set after
771 * variable replacement and list expansion.
773 bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
774 std::vector<std::string>& outArgs);
778 cmake *GetCMakeInstance() const;
781 * Get all the source files this makefile knows about
783 const std::vector<cmSourceFile*> &GetSourceFiles() const
784 {return this->SourceFiles;}
785 std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
788 * Is there a source file that has the provided source file as an output?
789 * if so then return it
791 cmSourceFile *GetSourceFileWithOutput(const char *outName);
794 * Add a macro to the list of macros. The arguments should be name of the
795 * macro and a documentation signature of it
797 void AddMacro(const char* name, const char* signature);
799 ///! Add a new cmTest to the list of tests for this makefile.
800 cmTest* CreateTest(const char* testName);
802 /** Get a cmTest pointer for a given test name, if the name is
803 * not found, then a null pointer is returned.
805 cmTest* GetTest(const char* testName) const;
808 * Get a list of macros as a ; separated string
810 void GetListOfMacros(std::string& macros);
813 * Return a location of a file in cmake or custom modules directory
815 std::string GetModulesFile(const char* name);
817 ///! Set/Get a property of this directory
818 void SetProperty(const char *prop, const char *value);
819 void AppendProperty(const char *prop, const char *value,bool asString=false);
820 const char *GetProperty(const char *prop);
821 const char *GetPropertyOrDefinition(const char *prop);
822 const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
823 bool GetPropertyAsBool(const char *prop);
825 const char* GetFeature(const char* feature, const char* config);
827 // Get the properties
828 cmPropertyMap &GetProperties() { return this->Properties; };
830 ///! Initialize a makefile from its parent
831 void InitializeFromParent();
833 ///! Set/Get the preorder flag
834 void SetPreOrder(bool p) { this->PreOrder = p; }
835 bool GetPreOrder() const { return this->PreOrder; }
837 void AddInstallGenerator(cmInstallGenerator* g)
838 { if(g) this->InstallGenerators.push_back(g); }
839 std::vector<cmInstallGenerator*>& GetInstallGenerators()
840 { return this->InstallGenerators; }
842 void AddTestGenerator(cmTestGenerator* g)
843 { if(g) this->TestGenerators.push_back(g); }
844 std::vector<cmTestGenerator*>& GetTestGenerators()
845 { return this->TestGenerators; }
847 // Define the properties
848 static void DefineProperties(cmake *cm);
850 // push and pop variable scopes
853 void RaiseScope(const char *var, const char *value);
855 /** Helper class to push and pop scopes automatically. */
859 ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
860 ~ScopePushPop() { this->Makefile->PopScope(); }
862 cmMakefile* Makefile;
865 void IssueMessage(cmake::MessageType t,
866 std::string const& text) const;
868 /** Set whether or not to report a CMP0000 violation. */
869 void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
871 std::vector<cmValueWithOrigin> GetIncludeDirectoriesEntries() const
873 return this->IncludeDirectoriesEntries;
875 std::vector<cmValueWithOrigin> GetCompileOptionsEntries() const
877 return this->CompileOptionsEntries;
879 std::vector<cmValueWithOrigin> GetCompileDefinitionsEntries() const
881 return this->CompileDefinitionsEntries;
884 bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; }
885 void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
887 std::set<cmStdString> const & GetSystemIncludeDirectories() const
888 { return this->SystemIncludeDirectories; }
891 // add link libraries and directories to the target
892 void AddGlobalLinkInformation(const char* name, cmTarget& target);
894 // Check for a an unused variable
895 void CheckForUnused(const char* reason, const char* name) const;
898 std::vector<std::string> AuxSourceDirectories; //
900 std::string cmStartDirectory;
901 std::string StartOutputDirectory;
902 std::string cmHomeDirectory;
903 std::string HomeOutputDirectory;
904 std::string cmCurrentListFile;
906 std::string ProjectName; // project name
908 // libraries, classes, and executables
910 std::map<std::string, cmTarget*> AliasTargets;
911 cmGeneratorTargetsType GeneratorTargets;
912 std::vector<cmSourceFile*> SourceFiles;
915 std::map<cmStdString, cmTest*> Tests;
917 // The link-library paths. Order matters, use std::vector (not std::set).
918 std::vector<std::string> LinkDirectories;
920 // The set of include directories that are marked as system include
922 std::set<cmStdString> SystemIncludeDirectories;
924 std::vector<std::string> ListFiles; // list of command files loaded
925 std::vector<std::string> OutputFiles; // list of command files loaded
928 cmTarget::LinkLibraryVectorType LinkLibraries;
930 std::vector<cmInstallGenerator*> InstallGenerators;
931 std::vector<cmTestGenerator*> TestGenerators;
933 std::string IncludeFileRegularExpression;
934 std::string ComplainFileRegularExpression;
935 std::vector<std::string> SourceFileExtensions;
936 std::vector<std::string> HeaderFileExtensions;
937 std::string DefineFlags;
939 std::vector<cmValueWithOrigin> IncludeDirectoriesEntries;
940 std::vector<cmValueWithOrigin> CompileOptionsEntries;
941 std::vector<cmValueWithOrigin> CompileDefinitionsEntries;
943 // Track the value of the computed DEFINITIONS property.
944 void AddDefineFlag(const char*, std::string&);
945 void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
946 std::string DefineFlagsOrig;
948 #if defined(CMAKE_BUILD_WITH_CMAKE)
949 std::vector<cmSourceGroup> SourceGroups;
952 std::vector<cmCommand*> FinalPassCommands;
953 cmLocalGenerator* LocalGenerator;
954 bool IsFunctionBlocked(const cmListFileFunction& lff,
955 cmExecutionStatus &status);
960 bool ParseDefineFlag(std::string const& definition, bool remove);
962 bool EnforceUniqueDir(const char* srcPath, const char* binPath);
964 void ReadSources(std::ifstream& fin, bool t);
965 friend class cmMakeDepend; // make depend needs direct access
966 // to the Sources array
967 void PrintStringVector(const char* s, const
968 std::vector<std::pair<cmStdString, bool> >& v) const;
969 void PrintStringVector(const char* s,
970 const std::vector<std::string>& v) const;
972 void AddDefaultDefinitions();
973 typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
974 FunctionBlockersType FunctionBlockers;
975 std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
976 void PushFunctionBlockerBarrier();
977 void PopFunctionBlockerBarrier(bool reportError = true);
979 typedef std::map<cmStdString, cmStdString> StringStringMap;
980 StringStringMap MacrosMap;
982 std::map<cmStdString, bool> SubDirectoryOrder;
984 cmsys::RegularExpression cmDefineRegex;
985 cmsys::RegularExpression cmDefine01Regex;
986 cmsys::RegularExpression cmAtVarRegex;
988 cmPropertyMap Properties;
990 // should this makefile be processed before or after processing the parent
993 // Unused variable flags
995 bool CheckSystemVars;
997 // stack of list files being read
998 std::deque<cmStdString> ListFileStack;
1000 // stack of commands being invoked.
1001 struct CallStackEntry
1003 cmListFileContext const* Context;
1004 cmExecutionStatus* Status;
1006 typedef std::deque<CallStackEntry> CallStackType;
1007 CallStackType CallStack;
1008 friend class cmMakefileCall;
1010 cmTarget* FindBasicTarget(const char* name);
1011 std::vector<cmTarget*> ImportedTargetsOwned;
1012 std::map<cmStdString, cmTarget*> ImportedTargets;
1014 // Internal policy stack management.
1015 void PushPolicy(bool weak = false,
1016 cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
1018 void PushPolicyBarrier();
1019 void PopPolicyBarrier(bool reportError = true);
1020 friend class cmCMakePolicyCommand;
1022 friend class IncludeScope;
1024 // stack of policy settings
1025 struct PolicyStackEntry: public cmPolicies::PolicyMap
1027 typedef cmPolicies::PolicyMap derived;
1028 PolicyStackEntry(bool w = false): derived(), Weak(w) {}
1029 PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
1030 PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
1033 typedef std::vector<PolicyStackEntry> PolicyStackType;
1034 PolicyStackType PolicyStack;
1035 std::vector<PolicyStackType::size_type> PolicyBarriers;
1036 cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
1040 // Enforce rules about CMakeLists.txt files.
1041 void EnforceDirectoryLevelRules();
1043 bool GeneratingBuildSystem;
1046 * Old version of GetSourceFileWithOutput(const char*) kept for
1047 * backward-compatibility. It implements a linear search and support
1048 * relative file paths. It is used as a fall back by
1049 * GetSourceFileWithOutput(const char*).
1051 cmSourceFile *LinearGetSourceFileWithOutput(const char *cname);
1053 // A map for fast output to input look up.
1054 #if defined(CMAKE_BUILD_WITH_CMAKE)
1055 typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap;
1057 typedef std::map<std::string, cmSourceFile*> OutputToSourceMap;
1059 OutputToSourceMap OutputToSource;
1061 void UpdateOutputToSourceMap(std::vector<std::string> const& outputs,
1062 cmSourceFile* source);
1063 void UpdateOutputToSourceMap(std::string const& output,
1064 cmSourceFile* source);
1067 //----------------------------------------------------------------------------
1068 // Helper class to make sure the call stack is valid.
1069 class cmMakefileCall
1072 cmMakefileCall(cmMakefile* mf,
1073 cmListFileContext const& lfc,
1074 cmExecutionStatus& status): Makefile(mf)
1076 cmMakefile::CallStackEntry entry = {&lfc, &status};
1077 this->Makefile->CallStack.push_back(entry);
1081 this->Makefile->CallStack.pop_back();
1084 cmMakefile* Makefile;