123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 |
- #ifndef cmake_h
- #define cmake_h
- #include "cmConfigure.h"
- #include <map>
- #include <set>
- #include <string>
- #include <unordered_set>
- #include <vector>
- #include "cmInstalledFile.h"
- #include "cmListFileCache.h"
- #include "cmStateSnapshot.h"
- #include "cmStateTypes.h"
- #if defined(CMAKE_BUILD_WITH_CMAKE)
- #include "cm_jsoncpp_value.h"
- #endif
- class cmExternalMakefileProjectGeneratorFactory;
- class cmFileTimeComparison;
- class cmGlobalGenerator;
- class cmGlobalGeneratorFactory;
- class cmMakefile;
- class cmMessenger;
- class cmState;
- class cmVariableWatch;
- struct cmDocumentationEntry;
- class cmake
- {
- CM_DISABLE_COPY(cmake)
- public:
- enum Role
- {
- RoleInternal,
- RoleScript,
- RoleProject
- };
- enum MessageType
- {
- AUTHOR_WARNING,
- AUTHOR_ERROR,
- FATAL_ERROR,
- INTERNAL_ERROR,
- MESSAGE,
- WARNING,
- LOG,
- DEPRECATION_ERROR,
- DEPRECATION_WARNING
- };
- enum DiagLevel
- {
- DIAG_IGNORE,
- DIAG_WARN,
- DIAG_ERROR
- };
-
- enum WorkingMode
- {
- NORMAL_MODE,
-
- SCRIPT_MODE,
-
- FIND_PACKAGE_MODE
- };
- struct GeneratorInfo
- {
- std::string name;
- std::string baseName;
- std::string extraName;
- bool supportsToolset;
- bool supportsPlatform;
- bool isAlias;
- };
- typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
-
- cmake(Role role);
-
- ~cmake();
- #if defined(CMAKE_BUILD_WITH_CMAKE)
- Json::Value ReportCapabilitiesJson(bool haveServerMode) const;
- #endif
- std::string ReportCapabilities(bool haveServerMode) const;
- static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; }
- static const char* GetCMakeFilesDirectoryPostSlash()
- {
- return "CMakeFiles/";
- }
-
-
- void SetHomeDirectory(const std::string& dir);
- std::string const& GetHomeDirectory() const;
- void SetHomeOutputDirectory(const std::string& dir);
- std::string const& GetHomeOutputDirectory() const;
-
-
- int Run(const std::vector<std::string>& args)
- {
- return this->Run(args, false);
- }
- int Run(const std::vector<std::string>& args, bool noconfigure);
-
- int Generate();
-
- int Configure();
- int ActualConfigure();
-
- static bool ParseCacheEntry(const std::string& entry, std::string& var,
- std::string& value,
- cmStateEnums::CacheEntryType& type);
- int LoadCache();
- bool LoadCache(const std::string& path);
- bool LoadCache(const std::string& path, bool internal,
- std::set<std::string>& excludes,
- std::set<std::string>& includes);
- bool SaveCache(const std::string& path);
- bool DeleteCache(const std::string& path);
- void PreLoadCMakeFiles();
-
- cmGlobalGenerator* CreateGlobalGenerator(const std::string& name);
-
- cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
-
- const cmGlobalGenerator* GetGlobalGenerator() const
- {
- return this->GlobalGenerator;
- }
-
- static std::string FindCacheFile(const std::string& binaryDir);
-
- void SetGlobalGenerator(cmGlobalGenerator*);
-
- void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const;
-
- void SetGeneratorInstance(std::string const& instance)
- {
- this->GeneratorInstance = instance;
- }
-
- void SetGeneratorPlatform(std::string const& ts)
- {
- this->GeneratorPlatform = ts;
- }
-
- void SetGeneratorToolset(std::string const& ts)
- {
- this->GeneratorToolset = ts;
- }
- const std::vector<std::string>& GetSourceExtensions() const
- {
- return this->SourceFileExtensions;
- }
- bool IsSourceExtension(const std::string& ext) const
- {
- return this->SourceFileExtensionsSet.find(ext) !=
- this->SourceFileExtensionsSet.end();
- }
- const std::vector<std::string>& GetHeaderExtensions() const
- {
- return this->HeaderFileExtensions;
- }
- bool IsHeaderExtension(const std::string& ext) const
- {
- return this->HeaderFileExtensionsSet.find(ext) !=
- this->HeaderFileExtensionsSet.end();
- }
-
- std::string StripExtension(const std::string& file) const;
-
- const char* GetCacheDefinition(const std::string&) const;
-
- void AddCacheEntry(const std::string& key, const char* value,
- const char* helpString, int type);
-
- int GetSystemInformation(std::vector<std::string>&);
-
- void SetArgs(const std::vector<std::string>&,
- bool directoriesSetBefore = false);
-
- bool GetIsInTryCompile() const;
- void SetIsInTryCompile(bool b);
-
- bool SetCacheArgs(const std::vector<std::string>&);
- typedef void (*ProgressCallbackType)(const char* msg, float progress, void*);
-
- void SetProgressCallback(ProgressCallbackType f, void* clientData = nullptr);
-
- void UpdateProgress(const char* msg, float prog);
-
- cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
- void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
-
- 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);
-
- cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf,
- const std::string& name);
- cmInstalledFile const* GetInstalledFile(const std::string& name) const;
- InstalledFilesMap const& GetInstalledFiles() const
- {
- return this->InstalledFiles;
- }
-
- int DoPreConfigureChecks();
- void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; }
- WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
-
- bool GetDebugTryCompile() { return this->DebugTryCompile; }
- void DebugTryCompileOn() { this->DebugTryCompile = true; }
-
- int AddCMakePaths();
-
- cmFileTimeComparison* GetFileComparison() { return this->FileComparison; }
-
- bool GetDebugOutput() { return this->DebugOutput; }
- void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
-
- bool GetTrace() { return this->Trace; }
- void SetTrace(bool b) { this->Trace = b; }
- bool GetTraceExpand() { return this->TraceExpand; }
- void SetTraceExpand(bool b) { this->TraceExpand = b; }
- void AddTraceSource(std::string const& file)
- {
- this->TraceOnlyThisSources.push_back(file);
- }
- std::vector<std::string> const& GetTraceSources() const
- {
- return this->TraceOnlyThisSources;
- }
- bool GetWarnUninitialized() { return this->WarnUninitialized; }
- void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
- bool GetWarnUnused() { return this->WarnUnused; }
- void SetWarnUnused(bool b) { this->WarnUnused = b; }
- bool GetWarnUnusedCli() { return this->WarnUnusedCli; }
- void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
- bool GetCheckSystemVars() { return this->CheckSystemVars; }
- void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
- void MarkCliAsUsed(const std::string& variable);
-
- std::vector<std::string> GetDebugConfigs();
- void SetCMakeEditCommand(std::string const& s)
- {
- this->CMakeEditCommand = s;
- }
- std::string const& GetCMakeEditCommand() const
- {
- return this->CMakeEditCommand;
- }
- cmMessenger* GetMessenger() const;
-
- bool GetSuppressDevWarnings() const;
-
- void SetSuppressDevWarnings(bool v);
-
- bool GetSuppressDeprecatedWarnings() const;
-
- void SetSuppressDeprecatedWarnings(bool v);
-
- bool GetDevWarningsAsErrors() const;
-
- void SetDevWarningsAsErrors(bool v);
-
- bool GetDeprecatedWarningsAsErrors() const;
-
- void SetDeprecatedWarningsAsErrors(bool v);
-
- void IssueMessage(
- cmake::MessageType t, std::string const& text,
- cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
-
- int Build(const std::string& dir, const std::string& target,
- const std::string& config,
- const std::vector<std::string>& nativeOptions, bool clean);
-
- bool Open(const std::string& dir, bool dryRun);
- void UnwatchUnusedCli(const std::string& var);
- void WatchUnusedCli(const std::string& var);
- cmState* GetState() const { return this->State; }
- void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
- {
- this->CurrentSnapshot = snapshot;
- }
- cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; }
- protected:
- void RunCheckForUnusedVariables();
- void InitializeProperties();
- int HandleDeleteCacheVariables(const std::string& var);
- typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
- RegisteredGeneratorsVector Generators;
- typedef std::vector<cmExternalMakefileProjectGeneratorFactory*>
- RegisteredExtraGeneratorsVector;
- RegisteredExtraGeneratorsVector ExtraGenerators;
- void AddScriptingCommands();
- void AddProjectCommands();
- void AddDefaultGenerators();
- void AddDefaultExtraGenerators();
- cmGlobalGenerator* GlobalGenerator;
- std::map<std::string, DiagLevel> DiagLevels;
- std::string GeneratorInstance;
- std::string GeneratorPlatform;
- std::string GeneratorToolset;
-
- void ReadListFile(const std::vector<std::string>& args, const char* path);
- bool FindPackage(const std::vector<std::string>& args);
-
-
- void TruncateOutputLog(const char* fname);
-
- int CheckBuildSystem();
- void SetDirectoriesFromFile(const char* arg);
-
-
- void CleanupCommandsAndMacros();
- void GenerateGraphViz(const char* fileName) const;
- cmVariableWatch* VariableWatch;
- private:
- ProgressCallbackType ProgressCallback;
- void* ProgressCallbackClientData;
- bool InTryCompile;
- WorkingMode CurrentWorkingMode;
- bool DebugOutput;
- bool Trace;
- bool TraceExpand;
- bool WarnUninitialized;
- bool WarnUnused;
- bool WarnUnusedCli;
- bool CheckSystemVars;
- std::map<std::string, bool> UsedCliVariables;
- std::string CMakeEditCommand;
- std::string CXXEnvironment;
- std::string CCEnvironment;
- std::string CheckBuildSystemArgument;
- std::string CheckStampFile;
- std::string CheckStampList;
- std::string VSSolutionFile;
- 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;
- std::string GraphVizFile;
- InstalledFilesMap InstalledFiles;
- cmState* State;
- cmStateSnapshot CurrentSnapshot;
- cmMessenger* Messenger;
- std::vector<std::string> TraceOnlyThisSources;
- void UpdateConversionPathTable();
-
- void PrintGeneratorList();
- void CreateDefaultGlobalGenerator();
-
- cmake::MessageType ConvertMessageType(cmake::MessageType t) const;
-
- bool IsMessageTypeVisible(cmake::MessageType t) const;
- };
- #define CMAKE_STANDARD_OPTIONS_TABLE \
- { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \
- { "-D <var>[:<type>]=<value>", "Create a cmake cache entry." }, \
- { "-U <globbing_expr>", "Remove matching entries from CMake cache." }, \
- { "-G <generator-name>", "Specify a build system generator." }, \
- { "-T <toolset-name>", \
- "Specify toolset name if supported by generator." }, \
- { "-A <platform-name>", \
- "Specify platform name if supported by generator." }, \
- { "-Wdev", "Enable developer warnings." }, \
- { "-Wno-dev", "Suppress developer warnings." }, \
- { "-Werror=dev", "Make developer warnings errors." }, \
- { "-Wno-error=dev", "Make developer warnings not errors." }, \
- { "-Wdeprecated", "Enable deprecation warnings." }, \
- { "-Wno-deprecated", "Suppress deprecation warnings." }, \
- { "-Werror=deprecated", "Make deprecated macro and function warnings " \
- "errors." }, \
- { \
- "-Wno-error=deprecated", "Make deprecated macro and function warnings " \
- "not errors." \
- }
- #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)
- #define FOR_EACH_CXX_FEATURE(F) \
- F(cxx_std_98) \
- F(cxx_std_11) \
- F(cxx_std_14) \
- F(cxx_std_17) \
- F(cxx_aggregate_default_initializers) \
- 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) \
- F(cxx_extern_templates) \
- 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) \
- F(cxx_nonstatic_member_init) \
- F(cxx_nullptr) \
- F(cxx_override) \
- 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)
- #endif
|