diff options
Diffstat (limited to 'Source/cmake.h')
-rw-r--r-- | Source/cmake.h | 128 |
1 files changed, 81 insertions, 47 deletions
diff --git a/Source/cmake.h b/Source/cmake.h index fa4409a..081e120 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -7,12 +7,13 @@ #include <functional> #include <map> -#include <memory> // IWYU pragma: keep +#include <memory> #include <set> #include <string> #include <unordered_set> #include <vector> +#include "cmGeneratedFileStream.h" #include "cmInstalledFile.h" #include "cmListFileCache.h" #include "cmMessageType.h" @@ -20,7 +21,7 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cm_jsoncpp_value.h" #endif @@ -121,6 +122,17 @@ public: bool isAlias; }; + struct FileExtensions + { + bool Test(std::string const& ext) const + { + return (this->unordered.find(ext) != this->unordered.end()); + } + + std::vector<std::string> ordered; + std::unordered_set<std::string> unordered; + }; + typedef std::map<std::string, cmInstalledFile> InstalledFilesMap; static const int NO_BUILD_PARALLEL_LEVEL = -1; @@ -134,7 +146,7 @@ public: cmake(cmake const&) = delete; cmake& operator=(cmake const&) = delete; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value ReportVersionJson() const; Json::Value ReportCapabilitiesJson() const; #endif @@ -233,24 +245,42 @@ public: const std::vector<std::string>& GetSourceExtensions() const { - return this->SourceFileExtensions; + return this->SourceFileExtensions.ordered; } bool IsSourceExtension(const std::string& ext) const { - return this->SourceFileExtensionsSet.find(ext) != - this->SourceFileExtensionsSet.end(); + return this->SourceFileExtensions.Test(ext); } const std::vector<std::string>& GetHeaderExtensions() const { - return this->HeaderFileExtensions; + return this->HeaderFileExtensions.ordered; } bool IsHeaderExtension(const std::string& ext) const { - return this->HeaderFileExtensionsSet.find(ext) != - this->HeaderFileExtensionsSet.end(); + return this->HeaderFileExtensions.Test(ext); + } + + const std::vector<std::string>& GetCudaExtensions() const + { + return this->CudaFileExtensions.ordered; + } + + bool IsCudaExtension(const std::string& ext) const + { + return this->CudaFileExtensions.Test(ext); + } + + const std::vector<std::string>& GetFortranExtensions() const + { + return this->FortranFileExtensions.ordered; + } + + bool IsFortranExtension(const std::string& ext) const + { + return this->FortranFileExtensions.Test(ext); } // Strips the extension (if present and known) from a filename @@ -305,9 +335,9 @@ public: //! this is called by generators to update the progress void UpdateProgress(const std::string& msg, float prog); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) //! Get the variable watch object - cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } + cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); } #endif std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); @@ -348,18 +378,18 @@ public: /** * Get the file comparison class */ - cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache; } + cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache.get(); } - // Get the selected log level for `message()` commands during the cmake run. + //! Get the selected log level for `message()` commands during the cmake run. LogLevel GetLogLevel() const { return this->MessageLogLevel; } void SetLogLevel(LogLevel level) { this->MessageLogLevel = level; } static LogLevel StringToLogLevel(const std::string& levelStr); - // Do we want debug output during the cmake run. + //! Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b; } - // Do we want trace output during the cmake run. + //! Do we want trace output during the cmake run. bool GetTrace() { return this->Trace; } void SetTrace(bool b) { this->Trace = b; } bool GetTraceExpand() { return this->TraceExpand; } @@ -372,6 +402,9 @@ public: { return this->TraceOnlyThisSources; } + cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; } + void SetTraceFile(std::string const& file); + bool GetWarnUninitialized() { return this->WarnUninitialized; } void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; } bool GetWarnUnused() { return this->WarnUnused; } @@ -396,31 +429,31 @@ public: return this->CMakeEditCommand; } - cmMessenger* GetMessenger() const; + cmMessenger* GetMessenger() const { return this->Messenger.get(); } - /* + /** * Get the state of the suppression of developer (author) warnings. * Returns false, by default, if developer warnings should be shown, true * otherwise. */ bool GetSuppressDevWarnings() const; - /* + /** * Set the state of the suppression of developer (author) warnings. */ void SetSuppressDevWarnings(bool v); - /* + /** * Get the state of the suppression of deprecated warnings. * Returns false, by default, if deprecated warnings should be shown, true * otherwise. */ bool GetSuppressDeprecatedWarnings() const; - /* + /** * Set the state of the suppression of deprecated warnings. */ void SetSuppressDeprecatedWarnings(bool v); - /* + /** * Get the state of treating developer (author) warnings as errors. * Returns false, by default, if warnings should not be treated as errors, * true otherwise. @@ -431,7 +464,7 @@ public: */ void SetDevWarningsAsErrors(bool v); - /* + /** * Get the state of treating deprecated warnings as errors. * Returns false, by default, if warnings should not be treated as errors, * true otherwise. @@ -459,7 +492,7 @@ public: void UnwatchUnusedCli(const std::string& var); void WatchUnusedCli(const std::string& var); - cmState* GetState() const { return this->State; } + cmState* GetState() const { return this->State.get(); } void SetCurrentSnapshot(cmStateSnapshot const& snapshot) { this->CurrentSnapshot = snapshot; @@ -480,14 +513,14 @@ protected: void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator* GlobalGenerator = nullptr; std::map<std::string, DiagLevel> DiagLevels; std::string GeneratorInstance; std::string GeneratorPlatform; std::string GeneratorToolset; - bool GeneratorInstanceSet; - bool GeneratorPlatformSet; - bool GeneratorToolsetSet; + bool GeneratorInstanceSet = false; + bool GeneratorPlatformSet = false; + bool GeneratorToolsetSet = false; //! read in a cmake list file to initialize the cache void ReadListFile(const std::vector<std::string>& args, @@ -514,14 +547,15 @@ protected: private: ProgressCallbackType ProgressCallback; - WorkingMode CurrentWorkingMode; - bool DebugOutput; - bool Trace; - bool TraceExpand; - bool WarnUninitialized; - bool WarnUnused; - bool WarnUnusedCli; - bool CheckSystemVars; + WorkingMode CurrentWorkingMode = NORMAL_MODE; + bool DebugOutput = false; + bool Trace = false; + bool TraceExpand = false; + cmGeneratedFileStream TraceFile; + bool WarnUninitialized = false; + bool WarnUnused = false; + bool WarnUnusedCli = true; + bool CheckSystemVars = false; std::map<std::string, bool> UsedCliVariables; std::string CMakeEditCommand; std::string CXXEnvironment; @@ -531,24 +565,24 @@ private: std::string CheckStampList; std::string VSSolutionFile; std::string EnvironmentGenerator; - std::vector<std::string> SourceFileExtensions; - std::unordered_set<std::string> SourceFileExtensionsSet; - std::vector<std::string> HeaderFileExtensions; - std::unordered_set<std::string> HeaderFileExtensionsSet; - bool ClearBuildSystem; - bool DebugTryCompile; - cmFileTimeCache* FileTimeCache; + FileExtensions SourceFileExtensions; + FileExtensions HeaderFileExtensions; + FileExtensions CudaFileExtensions; + FileExtensions FortranFileExtensions; + bool ClearBuildSystem = false; + bool DebugTryCompile = false; + std::unique_ptr<cmFileTimeCache> FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; -#if defined(CMAKE_BUILD_WITH_CMAKE) - cmVariableWatch* VariableWatch; +#if !defined(CMAKE_BOOTSTRAP) + std::unique_ptr<cmVariableWatch> VariableWatch; std::unique_ptr<cmFileAPI> FileAPI; #endif - cmState* State; + std::unique_ptr<cmState> State; cmStateSnapshot CurrentSnapshot; - cmMessenger* Messenger; + std::unique_ptr<cmMessenger> Messenger; std::vector<std::string> TraceOnlyThisSources; @@ -556,7 +590,7 @@ private: void UpdateConversionPathTable(); - // Print a list of valid generators to stderr. + //! Print a list of valid generators to stderr. void PrintGeneratorList(); std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator(); |