diff options
Diffstat (limited to 'Source/cmake.h')
-rw-r--r-- | Source/cmake.h | 159 |
1 files changed, 102 insertions, 57 deletions
diff --git a/Source/cmake.h b/Source/cmake.h index 53d44f148..fa4409aeb 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -26,7 +26,7 @@ class cmExternalMakefileProjectGeneratorFactory; class cmFileAPI; -class cmFileTimeComparison; +class cmFileTimeCache; class cmGlobalGenerator; class cmGlobalGeneratorFactory; class cmMakefile; @@ -96,6 +96,19 @@ public: FIND_PACKAGE_MODE }; + /** \brief Define log level constants. */ + enum LogLevel + { + LOG_UNDEFINED, + LOG_ERROR, + LOG_WARNING, + LOG_NOTICE, + LOG_STATUS, + LOG_VERBOSE, + LOG_DEBUG, + LOG_TRACE + }; + struct GeneratorInfo { std::string name; @@ -123,9 +136,9 @@ public: #if defined(CMAKE_BUILD_WITH_CMAKE) Json::Value ReportVersionJson() const; - Json::Value ReportCapabilitiesJson(bool haveServerMode) const; + Json::Value ReportCapabilitiesJson() const; #endif - std::string ReportCapabilities(bool haveServerMode) const; + std::string ReportCapabilities() const; //@{ /** @@ -162,7 +175,7 @@ public: int Configure(); int ActualConfigure(); - ///! Break up a line like VAR:type="value" into var, type and value + //! Break up a line like VAR:type="value" into var, type and value static bool ParseCacheEntry(const std::string& entry, std::string& var, std::string& value, cmStateEnums::CacheEntryType& type); @@ -176,43 +189,46 @@ public: bool DeleteCache(const std::string& path); void PreLoadCMakeFiles(); - ///! Create a GlobalGenerator + //! Create a GlobalGenerator cmGlobalGenerator* CreateGlobalGenerator(const std::string& name); - ///! Return the global generator assigned to this instance of cmake + //! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } - ///! Return the global generator assigned to this instance of cmake, const + //! Return the global generator assigned to this instance of cmake, const const cmGlobalGenerator* GetGlobalGenerator() const { return this->GlobalGenerator; } - ///! Return the full path to where the CMakeCache.txt file should be. + //! Return the full path to where the CMakeCache.txt file should be. static std::string FindCacheFile(const std::string& binaryDir); - ///! Return the global generator assigned to this instance of cmake + //! Return the global generator assigned to this instance of cmake void SetGlobalGenerator(cmGlobalGenerator*); - ///! Get the names of the current registered generators + //! Get the names of the current registered generators void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators, bool includeNamesWithPlatform = true) const; - ///! Set the name of the selected generator-specific instance. + //! Set the name of the selected generator-specific instance. void SetGeneratorInstance(std::string const& instance) { this->GeneratorInstance = instance; + this->GeneratorInstanceSet = true; } - ///! Set the name of the selected generator-specific platform. + //! Set the name of the selected generator-specific platform. void SetGeneratorPlatform(std::string const& ts) { this->GeneratorPlatform = ts; + this->GeneratorPlatformSet = true; } - ///! Set the name of the selected generator-specific toolset. + //! Set the name of the selected generator-specific toolset. void SetGeneratorToolset(std::string const& ts) { this->GeneratorToolset = ts; + this->GeneratorToolsetSet = true; } const std::vector<std::string>& GetSourceExtensions() const @@ -244,7 +260,7 @@ public: * Given a variable name, return its value (as a string). */ const char* GetCacheDefinition(const std::string&) const; - ///! Add an entry into the cache + //! Add an entry into the cache void AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type); @@ -263,17 +279,20 @@ public: */ int GetSystemInformation(std::vector<std::string>&); - ///! Parse command line arguments + //! Parse environment variables + void LoadEnvironmentPresets(); + + //! Parse command line arguments void SetArgs(const std::vector<std::string>& args); - ///! Is this cmake running as a result of a TRY_COMPILE command + //! Is this cmake running as a result of a TRY_COMPILE command bool GetIsInTryCompile() const; void SetIsInTryCompile(bool b); - ///! Parse command line arguments that might set cache values + //! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector<std::string>&); - using ProgressCallbackType = std::function<void(const char*, float)>; + using ProgressCallbackType = std::function<void(const std::string&, float)>; /** * Set the function used by GUIs to receive progress updates * Function gets passed: message as a const char*, a progress @@ -283,24 +302,24 @@ public: */ void SetProgressCallback(ProgressCallbackType f); - ///! this is called by generators to update the progress - void UpdateProgress(const char* msg, float prog); + //! this is called by generators to update the progress + void UpdateProgress(const std::string& msg, float prog); #if defined(CMAKE_BUILD_WITH_CMAKE) - ///! Get the variable watch object + //! Get the variable watch object cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } #endif std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); - ///! Set/Get a property of this target file + //! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); const char* GetProperty(const std::string& prop); bool GetPropertyAsBool(const std::string& prop); - ///! Get or create an cmInstalledFile instance and return a pointer to it + //! Get or create an cmInstalledFile instance and return a pointer to it cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf, const std::string& name); @@ -311,13 +330,13 @@ public: return this->InstalledFiles; } - ///! Do all the checks before running configure + //! Do all the checks before running configure int DoPreConfigureChecks(); void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } - ///! Debug the try compile stuff by not deleting the files + //! Debug the try compile stuff by not deleting the files bool GetDebugTryCompile() { return this->DebugTryCompile; } void DebugTryCompileOn() { this->DebugTryCompile = true; } @@ -329,7 +348,12 @@ public: /** * Get the file comparison class */ - cmFileTimeComparison* GetFileComparison() { return this->FileComparison; } + cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache; } + + // 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. bool GetDebugOutput() { return this->DebugOutput; } @@ -423,13 +447,13 @@ public: MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const; - ///! run the --build option - int Build(int jobs, const std::string& dir, const std::string& target, - const std::string& config, + //! run the --build option + int Build(int jobs, const std::string& dir, + const std::vector<std::string>& targets, const std::string& config, const std::vector<std::string>& nativeOptions, bool clean, bool verbose); - ///! run the --open option + //! run the --open option bool Open(const std::string& dir, bool dryRun); void UnwatchUnusedCli(const std::string& var); @@ -461,13 +485,16 @@ protected: std::string GeneratorInstance; std::string GeneratorPlatform; std::string GeneratorToolset; + bool GeneratorInstanceSet; + bool GeneratorPlatformSet; + bool GeneratorToolsetSet; - ///! read in a cmake list file to initialize the cache + //! read in a cmake list file to initialize the cache void ReadListFile(const std::vector<std::string>& args, const std::string& path); bool FindPackage(const std::vector<std::string>& args); - ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. + //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb void TruncateOutputLog(const char* fname); @@ -477,13 +504,13 @@ protected: */ int CheckBuildSystem(); - void SetDirectoriesFromFile(const char* arg); + void SetDirectoriesFromFile(const std::string& arg); //! Make sure all commands are what they say they are and there is no /// macros. void CleanupCommandsAndMacros(); - void GenerateGraphViz(const char* fileName) const; + void GenerateGraphViz(const std::string& fileName) const; private: ProgressCallbackType ProgressCallback; @@ -503,13 +530,14 @@ private: std::string CheckStampFile; 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; - cmFileTimeComparison* FileComparison; + cmFileTimeCache* FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; @@ -524,6 +552,8 @@ private: std::vector<std::string> TraceOnlyThisSources; + LogLevel MessageLogLevel = LogLevel::LOG_STATUS; + void UpdateConversionPathTable(); // Print a list of valid generators to stderr. @@ -562,40 +592,38 @@ private: "not errors." \ } +#define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes) + +#define FOR_EACH_C99_FEATURE(F) \ + F(c_restrict) \ + F(c_variadic_macros) + +#define FOR_EACH_C11_FEATURE(F) F(c_static_assert) + #define FOR_EACH_C_FEATURE(F) \ F(c_std_90) \ F(c_std_99) \ F(c_std_11) \ - F(c_function_prototypes) \ - F(c_restrict) \ - F(c_static_assert) \ - F(c_variadic_macros) + FOR_EACH_C90_FEATURE(F) \ + FOR_EACH_C99_FEATURE(F) \ + FOR_EACH_C11_FEATURE(F) -#define FOR_EACH_CXX_FEATURE(F) \ - F(cxx_std_98) \ - F(cxx_std_11) \ - F(cxx_std_14) \ - F(cxx_std_17) \ - F(cxx_std_20) \ - F(cxx_aggregate_default_initializers) \ +#define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters) + +#define FOR_EACH_CXX11_FEATURE(F) \ F(cxx_alias_templates) \ F(cxx_alignas) \ F(cxx_alignof) \ F(cxx_attributes) \ - F(cxx_attribute_deprecated) \ F(cxx_auto_type) \ - F(cxx_binary_literals) \ F(cxx_constexpr) \ - F(cxx_contextual_conversions) \ F(cxx_decltype) \ - F(cxx_decltype_auto) \ F(cxx_decltype_incomplete_return_types) \ F(cxx_default_function_template_args) \ F(cxx_defaulted_functions) \ F(cxx_defaulted_move_initializers) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ - F(cxx_digit_separators) \ F(cxx_enum_forward_declarations) \ F(cxx_explicit_conversions) \ F(cxx_extended_friend_declarations) \ @@ -603,11 +631,9 @@ private: F(cxx_final) \ F(cxx_func_identifier) \ F(cxx_generalized_initializers) \ - F(cxx_generic_lambdas) \ F(cxx_inheriting_constructors) \ F(cxx_inline_namespaces) \ F(cxx_lambdas) \ - F(cxx_lambda_init_captures) \ F(cxx_local_type_template_args) \ F(cxx_long_long_type) \ F(cxx_noexcept) \ @@ -617,22 +643,41 @@ private: F(cxx_range_for) \ F(cxx_raw_string_literals) \ F(cxx_reference_qualified_functions) \ - F(cxx_relaxed_constexpr) \ - F(cxx_return_type_deduction) \ F(cxx_right_angle_brackets) \ F(cxx_rvalue_references) \ F(cxx_sizeof_member) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ - F(cxx_template_template_parameters) \ F(cxx_thread_local) \ F(cxx_trailing_return_types) \ F(cxx_unicode_literals) \ F(cxx_uniform_initialization) \ F(cxx_unrestricted_unions) \ F(cxx_user_literals) \ - F(cxx_variable_templates) \ F(cxx_variadic_macros) \ F(cxx_variadic_templates) +#define FOR_EACH_CXX14_FEATURE(F) \ + F(cxx_aggregate_default_initializers) \ + F(cxx_attribute_deprecated) \ + F(cxx_binary_literals) \ + F(cxx_contextual_conversions) \ + F(cxx_decltype_auto) \ + F(cxx_digit_separators) \ + F(cxx_generic_lambdas) \ + F(cxx_lambda_init_captures) \ + F(cxx_relaxed_constexpr) \ + F(cxx_return_type_deduction) \ + F(cxx_variable_templates) + +#define FOR_EACH_CXX_FEATURE(F) \ + F(cxx_std_98) \ + F(cxx_std_11) \ + F(cxx_std_14) \ + F(cxx_std_17) \ + F(cxx_std_20) \ + FOR_EACH_CXX98_FEATURE(F) \ + FOR_EACH_CXX11_FEATURE(F) \ + FOR_EACH_CXX14_FEATURE(F) + #endif |