diff options
Diffstat (limited to 'Source/cmGlobalGenerator.h')
-rw-r--r-- | Source/cmGlobalGenerator.h | 204 |
1 files changed, 109 insertions, 95 deletions
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 1576f09..fcf8127 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -24,12 +24,12 @@ #include "cmTargetDepend.h" // For cmTargetDependSet #if defined(CMAKE_BUILD_WITH_CMAKE) -# include "cmFileLockPool.h" -# ifdef CMake_HAVE_CXX11_UNORDERED_MAP -# include <unordered_map> -# else -# include <cmsys/hash_map.hxx> -# endif +#include "cmFileLockPool.h" +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#include <unordered_map> +#else +#include <cmsys/hash_map.hxx> +#endif #endif class cmake; @@ -55,19 +55,19 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - virtual cmLocalGenerator* - CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } /** Check whether the given name matches the current generator. */ virtual bool MatchesGeneratorName(const std::string& name) const - { return this->GetName() == name; } + { + return this->GetName() == name; + } /** Tell the generator about the target system. */ - virtual bool SetSystemName(std::string const&, cmMakefile*) - { return true; } + virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; } /** Set the generator-specific platform name. Returns true if platform is supported and false otherwise. */ @@ -86,14 +86,15 @@ public: bool Compute(); virtual void AddExtraIDETargets() {} - enum TargetTypes { + enum TargetTypes + { AllTargets, ImportedOnly }; - void CreateImportedGenerationObjects(cmMakefile* mf, - std::vector<std::string> const& targets, - std::vector<cmGeneratorTarget const*>& exports); + void CreateImportedGenerationObjects( + cmMakefile* mf, std::vector<std::string> const& targets, + std::vector<cmGeneratorTarget const*>& exports); void CreateGenerationObjects(TargetTypes targetTypes = AllTargets); /** @@ -114,31 +115,28 @@ public: * Try to determine system information such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile*, bool optional); /** * Resolve the CMAKE_<lang>_COMPILER setting for the given language. * Intended to be called from EnableLanguage. */ - void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, + void ResolveLanguageCompiler(const std::string& lang, cmMakefile* mf, bool optional) const; /** * Try to determine system information, get it from another generator */ - void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, - cmMakefile* mf); + void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf); /** * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ int TryCompile(const std::string& srcdir, const std::string& bindir, - const std::string& projectName, - const std::string& targetName, - bool fast, std::string& output, cmMakefile* mf); - + const std::string& projectName, const std::string& targetName, + bool fast, std::string& output, cmMakefile* mf); /** * Build a file given the following information. This is a more direct call @@ -148,22 +146,19 @@ public: */ int Build(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, - std::string& output, - const std::string& makeProgram, const std::string& config, - bool clean, bool fast, bool verbose, - double timeout, - cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, + std::string& output, const std::string& makeProgram, + const std::string& config, bool clean, bool fast, bool verbose, + double timeout, cmSystemTools::OutputOption outputflag = + cmSystemTools::OUTPUT_NONE, std::vector<std::string> const& nativeOptions = - std::vector<std::string>()); + std::vector<std::string>()); virtual void GenerateBuildCommand( - std::vector<std::string>& makeCommand, - const std::string& makeProgram, + std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, - const std::string& targetName, const std::string& config, - bool fast, bool verbose, - std::vector<std::string> const& makeOptions = std::vector<std::string>() - ); + const std::string& targetName, const std::string& config, bool fast, + bool verbose, + std::vector<std::string> const& makeOptions = std::vector<std::string>()); /** Generate a "cmake --build" call for a given target and config. */ std::string GenerateCMakeBuildCommand(const std::string& target, @@ -172,36 +167,38 @@ public: bool ignoreErrors); ///! Get the CMake instance - cmake *GetCMakeInstance() const { return this->CMakeInstance; } + cmake* GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); - const std::vector<cmMakefile*>& GetMakefiles() const { - return this->Makefiles;} - const std::vector<cmLocalGenerator *>& GetLocalGenerators() const { - return this->LocalGenerators;} - - cmMakefile* GetCurrentMakefile() const + const std::vector<cmMakefile*>& GetMakefiles() const + { + return this->Makefiles; + } + const std::vector<cmLocalGenerator*>& GetLocalGenerators() const { - return this->CurrentMakefile; + return this->LocalGenerators; } - void SetCurrentMakefile(cmMakefile* mf) - {this->CurrentMakefile = mf;} + cmMakefile* GetCurrentMakefile() const { return this->CurrentMakefile; } + + void SetCurrentMakefile(cmMakefile* mf) { this->CurrentMakefile = mf; } - void AddMakefile(cmMakefile *mf); + void AddMakefile(cmMakefile* mf); ///! Set an generator for an "external makefile based project" void SetExternalMakefileProjectGenerator( - cmExternalMakefileProjectGenerator *extraGenerator); + cmExternalMakefileProjectGenerator* extraGenerator); std::string GetExtraGeneratorName() const; void AddInstallComponent(const char* component); const std::set<std::string>* GetInstallComponents() const - { return &this->InstallComponents; } + { + return &this->InstallComponents; + } - cmExportSetMap& GetExportSets() {return this->ExportSets;} + cmExportSetMap& GetExportSets() { return this->ExportSets; } /** Add a file to the manifest of generated targets for a configuration. */ void AddToManifest(std::string const& f); @@ -278,17 +275,17 @@ public: static bool IsReservedTarget(std::string const& name); - virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } - virtual const char* GetInstallTargetName() const { return "INSTALL"; } - virtual const char* GetInstallLocalTargetName() const { return 0; } - virtual const char* GetInstallStripTargetName() const { return 0; } - virtual const char* GetPreinstallTargetName() const { return 0; } - virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } - virtual const char* GetPackageTargetName() const { return "PACKAGE"; } + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } + virtual const char* GetInstallTargetName() const { return "INSTALL"; } + virtual const char* GetInstallLocalTargetName() const { return 0; } + virtual const char* GetInstallStripTargetName() const { return 0; } + virtual const char* GetPreinstallTargetName() const { return 0; } + virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } + virtual const char* GetPackageTargetName() const { return "PACKAGE"; } virtual const char* GetPackageSourceTargetName() const { return 0; } - virtual const char* GetEditCacheTargetName() const { return 0; } - virtual const char* GetRebuildCacheTargetName() const { return 0; } - virtual const char* GetCleanTargetName() const { return 0; } + virtual const char* GetEditCacheTargetName() const { return 0; } + virtual const char* GetRebuildCacheTargetName() const { return 0; } + virtual const char* GetCleanTargetName() const { return 0; } // Lookup edit_cache target command preferred by this generator. virtual std::string GetEditCacheCommand() const { return ""; } @@ -299,10 +296,13 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies TargetDependSet const& GetTargetDirectDepends( - const cmGeneratorTarget* target); + const cmGeneratorTarget* target); const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap() - const {return this->ProjectMap;} + const + { + return this->ProjectMap; + } // track files replaced during a Generate void FileReplacedDuringGenerate(const std::string& filename); @@ -313,9 +313,9 @@ public: /** Return whether the given binary directory is unused. */ bool BinaryDirectoryIsNew(const std::string& dir) - { + { return this->BinaryDirectories.insert(dir).second; - } + } /** Return true if the generated build tree may contain multiple builds. i.e. "Can I build Debug and Release in the same tree?" */ @@ -331,13 +331,15 @@ public: void ProcessEvaluationFiles(); std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets() - {return this->BuildExportSets;} + { + return this->BuildExportSets; + } void AddBuildExportSet(cmExportBuildFileGenerator*); void AddBuildExportExportSet(cmExportBuildFileGenerator*); - bool IsExportedTargetsFile(const std::string &filename) const; - bool GenerateImportFile(const std::string &file); - cmExportBuildFileGenerator* - GetExportedTargetsFile(const std::string &filename) const; + bool IsExportedTargetsFile(const std::string& filename) const; + bool GenerateImportFile(const std::string& file); + cmExportBuildFileGenerator* GetExportedTargetsFile( + const std::string& filename) const; void AddCMP0042WarnTarget(const std::string& target); virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; @@ -348,24 +350,27 @@ public: void SetFilenameTargetDepends(cmSourceFile* sf, std::set<const cmGeneratorTarget*> tgts); - const std::set<const cmGeneratorTarget*>& - GetFilenameTargetDepends(cmSourceFile* sf) const; + const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends( + cmSourceFile* sf) const; #if defined(CMAKE_BUILD_WITH_CMAKE) cmFileLockPool& GetFileLockPool() { return FileLockPool; } #endif bool GetConfigureDoneCMP0026() const - { return this->ConfigureDoneCMP0026AndCMP0024; } + { + return this->ConfigureDoneCMP0026AndCMP0024; + } std::string MakeSilentFlag; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend // information, and also collect all the targets void GetTargetSets(TargetDependSet& projectTargets, - TargetDependSet& originalTargets, - cmLocalGenerator* root, GeneratorVector const&); + TargetDependSet& originalTargets, cmLocalGenerator* root, + GeneratorVector const&); bool IsRootOnlyTarget(cmGeneratorTarget* target) const; void AddTargetDepends(const cmGeneratorTarget* target, TargetDependSet& projectTargets); @@ -395,15 +400,15 @@ protected: virtual void InitializeProgressMarks() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, - const cmCustomCommandLines* commandLines, - std::vector<std::string> depends, const char* workingDir, - bool uses_terminal); + const cmCustomCommandLines* commandLines, + std::vector<std::string> depends, + const char* workingDir, bool uses_terminal); std::string FindMakeProgramFile; std::string ConfiguredFilesPath; - cmake *CMakeInstance; + cmake* CMakeInstance; std::vector<cmMakefile*> Makefiles; - std::vector<cmLocalGenerator *> LocalGenerators; + std::vector<cmLocalGenerator*> LocalGenerators; cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap; @@ -420,26 +425,25 @@ protected: cmTarget* FindTargetImpl(std::string const& name) const; cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const; - cmGeneratorTarget* - FindImportedGeneratorTargetImpl(std::string const& name) const; + cmGeneratorTarget* FindImportedGeneratorTargetImpl( + std::string const& name) const; const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty(); private: - #if defined(CMAKE_BUILD_WITH_CMAKE) -# ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX11_UNORDERED_MAP typedef std::unordered_map<std::string, cmTarget*> TargetMap; typedef std::unordered_map<std::string, cmGeneratorTarget*> GeneratorTargetMap; -# else +#else typedef cmsys::hash_map<std::string, cmTarget*> TargetMap; typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap; -# endif +#endif #else - typedef std::map<std::string,cmTarget *> TargetMap; - typedef std::map<std::string,cmGeneratorTarget *> GeneratorTargetMap; + typedef std::map<std::string, cmTarget*> TargetMap; + typedef std::map<std::string, cmGeneratorTarget*> GeneratorTargetMap; #endif // Map efficiently from target name to cmTarget instance. // Do not use this structure for looping over all targets. @@ -460,7 +464,10 @@ private: std::map<std::string, std::string> LanguageToOriginalSharedLibFlags; // Record hashes for rules and outputs. - struct RuleHash { char Data[32]; }; + struct RuleHash + { + char Data[32]; + }; std::map<std::string, RuleHash> RuleHashes; void CheckRuleHashes(); void CheckRuleHashes(std::string const& pfile, std::string const& home); @@ -489,9 +496,9 @@ private: TargetDependMap TargetDependencies; friend class cmake; - void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf, - cmLocalGenerator* lg, - std::map<cmTarget*, cmGeneratorTarget*> const& importedMap); + void CreateGeneratorTargets( + TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg, + std::map<cmTarget*, cmGeneratorTarget*> const& importedMap); void CreateGeneratorTargets(TargetTypes targetTypes); void ClearGeneratorMembers(); @@ -504,9 +511,16 @@ private: long LastDiskTime; std::set<std::string> All; std::set<std::string> Generated; - DirectoryContent(): LastDiskTime(-1) {} - DirectoryContent(DirectoryContent const& dc): - LastDiskTime(dc.LastDiskTime), All(dc.All), Generated(dc.Generated) {} + DirectoryContent() + : LastDiskTime(-1) + { + } + DirectoryContent(DirectoryContent const& dc) + : LastDiskTime(dc.LastDiskTime) + , All(dc.All) + , Generated(dc.Generated) + { + } }; std::map<std::string, DirectoryContent> DirectoryContentMap; @@ -517,7 +531,7 @@ private: std::set<std::string> CMP0042WarnTargets; mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> > - FilenameTargetDepends; + FilenameTargetDepends; #if defined(CMAKE_BUILD_WITH_CMAKE) // Pool of file locks |