summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-02 09:43:35 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-03 09:44:38 (GMT)
commit0962589627f9bb3399d8144fc8252e47484bc0b3 (patch)
tree7711ef77ffcb23308355eb54520d0fd8cd9fb7ac /Source
parent2a5d077a89ea3ef08409e4d3e043ae78c9d8132d (diff)
downloadCMake-0962589627f9bb3399d8144fc8252e47484bc0b3.zip
CMake-0962589627f9bb3399d8144fc8252e47484bc0b3.tar.gz
CMake-0962589627f9bb3399d8144fc8252e47484bc0b3.tar.bz2
cmake: Initialize booleans at declaration and cleanup constructor
Diffstat (limited to 'Source')
-rw-r--r--Source/cmake.cxx57
-rw-r--r--Source/cmake.h28
2 files changed, 31 insertions, 54 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 309efd3..a81b7e4 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -28,6 +28,7 @@
#include "cmUtils.hxx"
#include "cmVersionConfig.h"
#include "cmWorkingDirectory.h"
+#include "cm_string_view.hxx"
#include "cm_sys_stat.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -132,22 +133,15 @@ static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
}
cmake::cmake(Role role, cmState::Mode mode)
+ : FileTimeCache(cm::make_unique<cmFileTimeCache>())
+#ifdef CMAKE_BUILD_WITH_CMAKE
+ , VariableWatch(cm::make_unique<cmVariableWatch>())
+#endif
+ , State(cm::make_unique<cmState>())
+ , Messenger(cm::make_unique<cmMessenger>())
{
- this->Trace = false;
- this->TraceExpand = false;
- this->WarnUninitialized = false;
- this->WarnUnused = false;
- this->WarnUnusedCli = true;
- this->CheckSystemVars = false;
- this->DebugOutput = false;
- this->DebugTryCompile = false;
- this->ClearBuildSystem = false;
- this->FileTimeCache = cm::make_unique<cmFileTimeCache>();
-
- this->State = cm::make_unique<cmState>();
this->State->SetMode(mode);
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
- this->Messenger = cm::make_unique<cmMessenger>();
#ifdef __APPLE__
struct rlimit rlp;
@@ -159,16 +153,6 @@ cmake::cmake(Role role, cmState::Mode mode)
}
#endif
- this->GlobalGenerator = nullptr;
- this->GeneratorInstanceSet = false;
- this->GeneratorPlatformSet = false;
- this->GeneratorToolsetSet = false;
- this->CurrentWorkingMode = NORMAL_MODE;
-
-#ifdef CMAKE_BUILD_WITH_CMAKE
- this->VariableWatch = cm::make_unique<cmVariableWatch>();
-#endif
-
this->AddDefaultGenerators();
this->AddDefaultExtraGenerators();
if (role == RoleScript || role == RoleProject) {
@@ -188,32 +172,25 @@ cmake::cmake(Role role, cmState::Mode mode)
// Set up a list of source and header extensions.
// These are used to find files when the extension is not given.
{
- auto fillExts = [](FileExtensions& exts,
- std::initializer_list<const char*> extList) {
+ auto setupExts = [](FileExtensions& exts,
+ std::initializer_list<cm::string_view> extList) {
// Fill ordered vector
exts.ordered.reserve(extList.size());
- for (const char* ext : extList) {
+ for (cm::string_view ext : extList) {
exts.ordered.emplace_back(ext);
};
// Fill unordered set
exts.unordered.insert(exts.ordered.begin(), exts.ordered.end());
};
- // Source extensions
// The "c" extension MUST precede the "C" extension.
- fillExts(this->SourceFileExtensions,
- { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" });
-
- // Header extensions
- fillExts(this->HeaderFileExtensions,
- { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" });
-
- // Cuda extensions
- fillExts(this->CudaFileExtensions, { "cu" });
-
- // Fortran extensions
- fillExts(this->FortranFileExtensions,
- { "f", "F", "for", "f77", "f90", "f95", "f03" });
+ setupExts(this->SourceFileExtensions,
+ { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" });
+ setupExts(this->HeaderFileExtensions,
+ { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" });
+ setupExts(this->CudaFileExtensions, { "cu" });
+ setupExts(this->FortranFileExtensions,
+ { "f", "F", "for", "f77", "f90", "f95", "f03" });
}
}
diff --git a/Source/cmake.h b/Source/cmake.h
index 6aa00e1..92494ae 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -509,14 +509,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,
@@ -543,14 +543,14 @@ 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;
+ bool WarnUninitialized = false;
+ bool WarnUnused = false;
+ bool WarnUnusedCli = true;
+ bool CheckSystemVars = false;
std::map<std::string, bool> UsedCliVariables;
std::string CMakeEditCommand;
std::string CXXEnvironment;
@@ -564,8 +564,8 @@ private:
FileExtensions HeaderFileExtensions;
FileExtensions CudaFileExtensions;
FileExtensions FortranFileExtensions;
- bool ClearBuildSystem;
- bool DebugTryCompile;
+ bool ClearBuildSystem = false;
+ bool DebugTryCompile = false;
std::unique_ptr<cmFileTimeCache> FileTimeCache;
std::string GraphVizFile;
InstalledFilesMap InstalledFiles;