|
|
@@ -21,6 +21,7 @@
|
|
|
#include "cmTest.h"
|
|
|
#include "cmDocumentationFormatter.h"
|
|
|
#include "cmAlgorithms.h"
|
|
|
+#include "cmState.h"
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
# include "cmGraphVizWriter.h"
|
|
|
@@ -133,6 +134,8 @@ cmake::cmake()
|
|
|
this->FileComparison = new cmFileTimeComparison;
|
|
|
|
|
|
this->Policies = new cmPolicies();
|
|
|
+ this->State = new cmState(this);
|
|
|
+
|
|
|
this->InitializeProperties();
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
@@ -171,6 +174,7 @@ cmake::~cmake()
|
|
|
{
|
|
|
delete this->CacheManager;
|
|
|
delete this->Policies;
|
|
|
+ delete this->State;
|
|
|
if (this->GlobalGenerator)
|
|
|
{
|
|
|
delete this->GlobalGenerator;
|
|
|
@@ -332,7 +336,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|
|
}
|
|
|
}
|
|
|
std::string var, value;
|
|
|
- cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
|
|
|
+ cmState::CacheEntryType type = cmState::UNINITIALIZED;
|
|
|
if(cmCacheManager::ParseEntry(entry, var, value, type))
|
|
|
{
|
|
|
// The value is transformed if it is a filepath for example, so
|
|
|
@@ -342,22 +346,20 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|
|
std::string cachedValue;
|
|
|
if(this->WarnUnusedCli)
|
|
|
{
|
|
|
- if(const char *v = this->CacheManager
|
|
|
- ->GetInitializedCacheValue(var))
|
|
|
+ if(const char *v = this->State->GetInitializedCacheValue(var))
|
|
|
{
|
|
|
haveValue = true;
|
|
|
cachedValue = v;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this->CacheManager->AddCacheEntry(var, value.c_str(),
|
|
|
+ this->State->AddCacheEntry(var, value.c_str(),
|
|
|
"No help, variable specified on the command line.", type);
|
|
|
|
|
|
if(this->WarnUnusedCli)
|
|
|
{
|
|
|
if (!haveValue ||
|
|
|
- cachedValue != this->CacheManager
|
|
|
- ->GetInitializedCacheValue(var))
|
|
|
+ cachedValue != this->State->GetInitializedCacheValue(var))
|
|
|
{
|
|
|
this->WatchUnusedCli(var);
|
|
|
}
|
|
|
@@ -401,14 +403,12 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|
|
cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
|
|
|
//go through all cache entries and collect the vars which will be removed
|
|
|
std::vector<std::string> entriesToDelete;
|
|
|
- std::vector<std::string> cacheKeys =
|
|
|
- this->CacheManager->GetCacheEntryKeys();
|
|
|
+ std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
|
|
|
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
|
|
|
it != cacheKeys.end(); ++it)
|
|
|
{
|
|
|
- cmCacheManager::CacheEntryType t =
|
|
|
- this->CacheManager->GetCacheEntryType(*it);
|
|
|
- if(t != cmCacheManager::STATIC)
|
|
|
+ cmState::CacheEntryType t = this->State->GetCacheEntryType(*it);
|
|
|
+ if(t != cmState::STATIC)
|
|
|
{
|
|
|
if (regex.find(it->c_str()))
|
|
|
{
|
|
|
@@ -423,7 +423,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|
|
currentEntry != entriesToDelete.end();
|
|
|
++currentEntry)
|
|
|
{
|
|
|
- this->CacheManager->RemoveCacheEntry(*currentEntry);
|
|
|
+ this->State->RemoveCacheEntry(*currentEntry);
|
|
|
}
|
|
|
}
|
|
|
else if(arg.find("-C",0) == 0)
|
|
|
@@ -917,7 +917,7 @@ void cmake::SetDirectoriesFromFile(const char* arg)
|
|
|
if(this->LoadCache(cachePath))
|
|
|
{
|
|
|
const char* existingValue =
|
|
|
- this->CacheManager->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
|
|
|
+ this->State->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
|
|
|
if (existingValue)
|
|
|
{
|
|
|
this->SetHomeOutputDirectory(cachePath);
|
|
|
@@ -971,14 +971,14 @@ int cmake::AddCMakePaths()
|
|
|
// Save the value in the cache
|
|
|
this->CacheManager->AddCacheEntry
|
|
|
("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(),
|
|
|
- "Path to CMake executable.", cmCacheManager::INTERNAL);
|
|
|
+ "Path to CMake executable.", cmState::INTERNAL);
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
this->CacheManager->AddCacheEntry
|
|
|
("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
|
|
|
- "Path to ctest program executable.", cmCacheManager::INTERNAL);
|
|
|
+ "Path to ctest program executable.", cmState::INTERNAL);
|
|
|
this->CacheManager->AddCacheEntry
|
|
|
("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(),
|
|
|
- "Path to cpack program executable.", cmCacheManager::INTERNAL);
|
|
|
+ "Path to cpack program executable.", cmState::INTERNAL);
|
|
|
#endif
|
|
|
if(!cmSystemTools::FileExists(
|
|
|
(cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str()))
|
|
|
@@ -992,7 +992,7 @@ int cmake::AddCMakePaths()
|
|
|
}
|
|
|
this->CacheManager->AddCacheEntry
|
|
|
("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
|
|
|
- "Path to CMake installation.", cmCacheManager::INTERNAL);
|
|
|
+ "Path to CMake installation.", cmState::INTERNAL);
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -1266,7 +1266,7 @@ struct SaveCacheEntry
|
|
|
std::string key;
|
|
|
std::string value;
|
|
|
std::string help;
|
|
|
- cmCacheManager::CacheEntryType type;
|
|
|
+ cmState::CacheEntryType type;
|
|
|
};
|
|
|
|
|
|
int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|
|
@@ -1279,7 +1279,6 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
- cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator();
|
|
|
std::vector<SaveCacheEntry> saved;
|
|
|
std::ostringstream warning;
|
|
|
warning
|
|
|
@@ -1295,10 +1294,13 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|
|
i++;
|
|
|
save.value = *i;
|
|
|
warning << *i << "\n";
|
|
|
- if(ci.Find(save.key))
|
|
|
+ const char* existingValue =
|
|
|
+ this->CacheManager->GetCacheEntryValue(save.key);
|
|
|
+ if(existingValue)
|
|
|
{
|
|
|
- save.type = ci.GetType();
|
|
|
- if(const char* help = ci.GetProperty("HELPSTRING"))
|
|
|
+ save.type = this->CacheManager->GetCacheEntryType(save.key);
|
|
|
+ if(const char* help =
|
|
|
+ this->CacheManager->GetCacheEntryProperty(save.key, "HELPSTRING"))
|
|
|
{
|
|
|
save.help = help;
|
|
|
}
|
|
|
@@ -1337,7 +1339,7 @@ int cmake::Configure()
|
|
|
AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE",
|
|
|
"Suppress Warnings that are meant for"
|
|
|
" the author of the CMakeLists.txt files.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1345,7 +1347,7 @@ int cmake::Configure()
|
|
|
AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE",
|
|
|
"Suppress Warnings that are meant for"
|
|
|
" the author of the CMakeLists.txt files.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
}
|
|
|
int ret = this->ActualConfigure();
|
|
|
@@ -1381,7 +1383,7 @@ int cmake::ActualConfigure()
|
|
|
this->GetHomeDirectory(),
|
|
|
"Start directory with the top level CMakeLists.txt file for this "
|
|
|
"project",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
|
|
|
// no generator specified on the command line
|
|
|
@@ -1490,11 +1492,11 @@ int cmake::ActualConfigure()
|
|
|
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR",
|
|
|
this->GlobalGenerator->GetName().c_str(),
|
|
|
"Name of generator.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
|
|
|
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
|
|
|
"Name of external makefile project generator.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
|
|
|
if(const char* platformName =
|
|
|
@@ -1522,7 +1524,7 @@ int cmake::ActualConfigure()
|
|
|
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
|
|
|
this->GeneratorPlatform.c_str(),
|
|
|
"Name of generator platform.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
|
|
|
if(const char* tsName =
|
|
|
@@ -1550,7 +1552,7 @@ int cmake::ActualConfigure()
|
|
|
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
|
|
|
this->GeneratorToolset.c_str(),
|
|
|
"Name of generator toolset.",
|
|
|
- cmCacheManager::INTERNAL);
|
|
|
+ cmState::INTERNAL);
|
|
|
}
|
|
|
|
|
|
// reset any system configuration information, except for when we are
|
|
|
@@ -1576,49 +1578,51 @@ int cmake::ActualConfigure()
|
|
|
// project requires compatibility with CMake 2.4. We detect this
|
|
|
// here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY
|
|
|
// variable created when CMP0001 is not set to NEW.
|
|
|
- if(this->GetCacheManager()
|
|
|
+ if(this->State
|
|
|
->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
|
|
|
{
|
|
|
- if(!this->CacheManager->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH"))
|
|
|
+ if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH"))
|
|
|
{
|
|
|
- this->CacheManager->AddCacheEntry
|
|
|
+ this->State->AddCacheEntry
|
|
|
("LIBRARY_OUTPUT_PATH", "",
|
|
|
"Single output directory for building all libraries.",
|
|
|
- cmCacheManager::PATH);
|
|
|
+ cmState::PATH);
|
|
|
}
|
|
|
- if(!this->CacheManager
|
|
|
+ if(!this->State
|
|
|
->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH"))
|
|
|
{
|
|
|
- this->CacheManager->AddCacheEntry
|
|
|
+ this->State->AddCacheEntry
|
|
|
("EXECUTABLE_OUTPUT_PATH", "",
|
|
|
"Single output directory for building all executables.",
|
|
|
- cmCacheManager::PATH);
|
|
|
+ cmState::PATH);
|
|
|
}
|
|
|
}
|
|
|
- if(!this->CacheManager
|
|
|
+ if(!this->State
|
|
|
->GetInitializedCacheValue("CMAKE_USE_RELATIVE_PATHS"))
|
|
|
{
|
|
|
- this->CacheManager->AddCacheEntry
|
|
|
+ this->State->AddCacheEntry
|
|
|
("CMAKE_USE_RELATIVE_PATHS", "OFF",
|
|
|
"If true, cmake will use relative paths in makefiles and projects.",
|
|
|
- cmCacheManager::BOOL);
|
|
|
- if (!this->CacheManager->GetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS",
|
|
|
- "ADVANCED"))
|
|
|
+ cmState::BOOL);
|
|
|
+ if (!this->State->GetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS",
|
|
|
+ "ADVANCED"))
|
|
|
{
|
|
|
- this->CacheManager->SetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS",
|
|
|
- "ADVANCED", "1");
|
|
|
+ this->State->SetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS",
|
|
|
+ "ADVANCED", "1");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(cmSystemTools::GetFatalErrorOccured() &&
|
|
|
- (!this->CacheManager->GetInitializedCacheValue("CMAKE_MAKE_PROGRAM") ||
|
|
|
- cmSystemTools::IsOff(this->CacheManager->
|
|
|
- GetInitializedCacheValue("CMAKE_MAKE_PROGRAM"))))
|
|
|
+ if(cmSystemTools::GetFatalErrorOccured())
|
|
|
{
|
|
|
- // We must have a bad generator selection. Wipe the cache entry so the
|
|
|
- // user can select another.
|
|
|
- this->CacheManager->RemoveCacheEntry("CMAKE_GENERATOR");
|
|
|
- this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR");
|
|
|
+ const char* makeProgram =
|
|
|
+ this->State->GetInitializedCacheValue("CMAKE_MAKE_PROGRAM");
|
|
|
+ if (!makeProgram || cmSystemTools::IsOff(makeProgram))
|
|
|
+ {
|
|
|
+ // We must have a bad generator selection. Wipe the cache entry so the
|
|
|
+ // user can select another.
|
|
|
+ this->State->RemoveCacheEntry("CMAKE_GENERATOR");
|
|
|
+ this->State->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
@@ -1824,7 +1828,7 @@ void cmake::AddCacheEntry(const std::string& key, const char* value,
|
|
|
{
|
|
|
this->CacheManager->AddCacheEntry(key, value,
|
|
|
helpString,
|
|
|
- cmCacheManager::CacheEntryType(type));
|
|
|
+ cmState::CacheEntryType(type));
|
|
|
}
|
|
|
|
|
|
const char* cmake::GetCacheDefinition(const std::string& name) const
|
|
|
@@ -1896,7 +1900,7 @@ void cmake::AddDefaultGenerators()
|
|
|
bool cmake::ParseCacheEntry(const std::string& entry,
|
|
|
std::string& var,
|
|
|
std::string& value,
|
|
|
- cmCacheManager::CacheEntryType& type)
|
|
|
+ cmState::CacheEntryType& type)
|
|
|
{
|
|
|
return cmCacheManager::ParseEntry(entry, var, value, type);
|
|
|
}
|
|
|
@@ -2246,7 +2250,7 @@ void cmake::TruncateOutputLog(const char* fname)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if ( !this->CacheManager->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR") )
|
|
|
+ if (!this->State->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"))
|
|
|
{
|
|
|
cmSystemTools::RemoveFile(fullPath);
|
|
|
return;
|
|
|
@@ -2351,8 +2355,7 @@ const char *cmake::GetProperty(const std::string& prop,
|
|
|
std::string output = "";
|
|
|
if ( prop == "CACHE_VARIABLES" )
|
|
|
{
|
|
|
- std::vector<std::string> cacheKeys =
|
|
|
- this->CacheManager->GetCacheEntryKeys();
|
|
|
+ std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
|
|
|
this->SetProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
|
|
|
}
|
|
|
else if ( prop == "COMMANDS" )
|
|
|
@@ -2507,7 +2510,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
|
|
|
// we have to find the module directory, so we can copy the files
|
|
|
this->AddCMakePaths();
|
|
|
std::string modulesPath =
|
|
|
- this->CacheManager->GetInitializedCacheValue("CMAKE_ROOT");
|
|
|
+ this->State->GetInitializedCacheValue("CMAKE_ROOT");
|
|
|
modulesPath += "/Modules";
|
|
|
std::string inFile = modulesPath;
|
|
|
inFile += "/SystemInformation.cmake";
|
|
|
@@ -2717,7 +2720,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
|
|
if(t == cmake::AUTHOR_WARNING)
|
|
|
{
|
|
|
// Allow suppression of these warnings.
|
|
|
- const char* suppress = this->CacheManager->GetCacheEntryValue(
|
|
|
+ const char* suppress = this->State->GetCacheEntryValue(
|
|
|
"CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
|
|
if(suppress && cmSystemTools::IsOn(suppress))
|
|
|
{
|
|
|
@@ -2835,7 +2838,7 @@ int cmake::Build(const std::string& dir,
|
|
|
return 1;
|
|
|
}
|
|
|
const char* cachedGenerator =
|
|
|
- this->CacheManager->GetCacheEntryValue("CMAKE_GENERATOR");
|
|
|
+ this->State->GetCacheEntryValue("CMAKE_GENERATOR");
|
|
|
if(!cachedGenerator)
|
|
|
{
|
|
|
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
|
|
|
@@ -2852,7 +2855,7 @@ int cmake::Build(const std::string& dir,
|
|
|
std::string output;
|
|
|
std::string projName;
|
|
|
const char* cachedProjectName =
|
|
|
- this->CacheManager->GetCacheEntryValue("CMAKE_PROJECT_NAME");
|
|
|
+ this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME");
|
|
|
if(!cachedProjectName)
|
|
|
{
|
|
|
std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n";
|
|
|
@@ -2861,7 +2864,7 @@ int cmake::Build(const std::string& dir,
|
|
|
projName = cachedProjectName;
|
|
|
bool verbose = false;
|
|
|
const char* cachedVerbose =
|
|
|
- this->CacheManager->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
|
|
|
+ this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
|
|
|
if(cachedVerbose)
|
|
|
{
|
|
|
verbose = cmSystemTools::IsOn(cachedVerbose);
|