From 09095dbcd2dd43763e37142b65bdaaeb34deb45d Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 4 Sep 2020 19:14:41 +0200 Subject: cmFindPackageCommand: Refactoring * Use member initialisation at declaration * AddFindDefinition: same signature as cmMakefile::AddDefinition for consistency * Factorise version variables creation --- Source/cmFindPackageCommand.h | 60 ++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'Source/cmFindPackageCommand.h') diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index eacd1ce698..4216ad7c29 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -11,6 +11,8 @@ #include #include +#include + #include #include "cmFindCommon.h" @@ -88,9 +90,15 @@ private: void AppendSuccessInformation(); void AppendToFoundProperty(bool found); + void SetVersionVariables( + const std::function& + addDefinition, + const std::string& prefix, const std::string& version, unsigned int count, + unsigned int major, unsigned int minor, unsigned int patch, + unsigned int tweak); void SetModuleVariables(const std::string& components); bool FindModule(bool& found); - void AddFindDefinition(const std::string& var, const char* val); + void AddFindDefinition(const std::string& var, cm::string_view value); void RestoreFindDefinitions(); enum /*class*/ HandlePackageModeType @@ -153,31 +161,31 @@ private: std::string Name; std::string Variable; std::string Version; - unsigned int VersionMajor; - unsigned int VersionMinor; - unsigned int VersionPatch; - unsigned int VersionTweak; - unsigned int VersionCount; - bool VersionExact; + unsigned int VersionMajor = 0; + unsigned int VersionMinor = 0; + unsigned int VersionPatch = 0; + unsigned int VersionTweak = 0; + unsigned int VersionCount = 0; + bool VersionExact = false; std::string FileFound; std::string VersionFound; - unsigned int VersionFoundMajor; - unsigned int VersionFoundMinor; - unsigned int VersionFoundPatch; - unsigned int VersionFoundTweak; - unsigned int VersionFoundCount; - KWIML_INT_uint64_t RequiredCMakeVersion; - bool Quiet; - bool Required; - bool UseConfigFiles; - bool UseFindModules; - bool NoUserRegistry; - bool NoSystemRegistry; - bool UseLib32Paths; - bool UseLib64Paths; - bool UseLibx32Paths; - bool UseRealPath; - bool PolicyScope; + unsigned int VersionFoundMajor = 0; + unsigned int VersionFoundMinor = 0; + unsigned int VersionFoundPatch = 0; + unsigned int VersionFoundTweak = 0; + unsigned int VersionFoundCount = 0; + KWIML_INT_uint64_t RequiredCMakeVersion = 0; + bool Quiet = false; + bool Required = false; + bool UseConfigFiles = true; + bool UseFindModules = true; + bool NoUserRegistry = false; + bool NoSystemRegistry = false; + bool UseLib32Paths = false; + bool UseLib64Paths = false; + bool UseLibx32Paths = false; + bool UseRealPath = false; + bool PolicyScope = true; std::string LibraryArchitecture; std::vector Names; std::vector Configs; @@ -185,9 +193,9 @@ private: std::string DebugBuffer; /*! the selected sortOrder (None by default)*/ - SortOrderType SortOrder; + SortOrderType SortOrder = None; /*! the selected sortDirection (Asc by default)*/ - SortDirectionType SortDirection; + SortDirectionType SortDirection = Asc; struct ConfigFileInfo { -- cgit v1.2.1