Commit db1303aa authored by Bill Hoffman's avatar Bill Hoffman

ENH: big change, only allow commands access to the cache via the cmMakefile...

ENH: big change, only allow commands access to the cache via the cmMakefile class and GetDefinition, also the cmMakefile is the only way for commands to add to the cache.  Also, some changes to configure.in that check for for scoping
parent 61ec323b
...@@ -533,7 +533,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager() ...@@ -533,7 +533,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
switch(value.m_Type ) switch(value.m_Type )
{ {
case cmCacheManager::BOOL: case cmCacheManager::BOOL:
if(cmCacheManager::GetInstance()->IsOn(key)) if(cmSystemTools::IsOn(value.m_Value.c_str()))
{ {
m_CacheEntriesList.AddProperty(key, m_CacheEntriesList.AddProperty(key,
"ON", "ON",
......
...@@ -50,7 +50,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args) ...@@ -50,7 +50,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args)
} }
const char* define = args[0].c_str(); const char* define = args[0].c_str();
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(define); = m_Makefile->GetDefinition(define);
if(cacheValue) if(cacheValue)
{ {
return true; return true;
...@@ -73,12 +73,11 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args) ...@@ -73,12 +73,11 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args)
makecommand = makeprogram; makecommand = makeprogram;
makecommand += " -k"; makecommand += " -k";
} }
cmCacheManager::GetInstance()-> m_Makefile->AddCacheDefinition(define,
AddCacheEntry(define, makecommand.c_str(),
makecommand.c_str(), "Command used to build entire project "
"Command used to build entire project from the command line.", "from the command line.",
cmCacheManager::STRING); cmCacheManager::STRING);
m_Makefile->AddDefinition(define, makecommand.c_str());
return true; return true;
} }
...@@ -49,7 +49,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args) ...@@ -49,7 +49,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
return false; return false;
} }
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue("BUILDNAME"); = m_Makefile->GetDefinition("BUILDNAME");
if(cacheValue) if(cacheValue)
{ {
// do we need to correct the value? // do we need to correct the value?
...@@ -60,16 +60,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args) ...@@ -60,16 +60,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
cmSystemTools::ReplaceString(cv,"/", "_"); cmSystemTools::ReplaceString(cv,"/", "_");
cmSystemTools::ReplaceString(cv,"(", "_"); cmSystemTools::ReplaceString(cv,"(", "_");
cmSystemTools::ReplaceString(cv,")", "_"); cmSystemTools::ReplaceString(cv,")", "_");
cmCacheManager::GetInstance()-> m_Makefile->AddCacheDefinition("BUILDNAME",
AddCacheEntry("BUILDNAME", cv.c_str(),
cv.c_str(), "Name of build.",
"Name of build.", cmCacheManager::STRING);
cmCacheManager::STRING);
m_Makefile->AddDefinition("BUILDNAME", cv.c_str());
}
else
{
m_Makefile->AddDefinition("BUILDNAME", cacheValue);
} }
return true; return true;
} }
...@@ -101,13 +95,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args) ...@@ -101,13 +95,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
cmSystemTools::ReplaceString(buildname, cmSystemTools::ReplaceString(buildname,
")", "_"); ")", "_");
cmCacheManager::GetInstance()-> m_Makefile->AddCacheDefinition("BUILDNAME",
AddCacheEntry("BUILDNAME", buildname.c_str(),
buildname.c_str(), "Name of build.",
"Name of build.", cmCacheManager::STRING);
cmCacheManager::STRING);
m_Makefile->AddDefinition("BUILDNAME", buildname.c_str());
return true; return true;
} }
...@@ -408,15 +408,14 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, ...@@ -408,15 +408,14 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
std::string cmCableWrapTclCommand::GetGccXmlFromCache() const std::string cmCableWrapTclCommand::GetGccXmlFromCache() const
{ {
const char* gccxml = const char* gccxml =
cmCacheManager::GetInstance()->GetCacheValue("GCCXML"); m_Makefile->GetDefinition("GCCXML");
if(gccxml) if(gccxml)
{ return gccxml; } { return gccxml; }
m_Makefile->AddDefinition("GCCXML","NOTFOUND"); m_Makefile->AddCacheDefinition("GCCXML",
cmCacheManager::GetInstance()->AddCacheEntry("GCCXML", "NOTFOUND",
"NOTFOUND", "Path to GCC-XML executable.",
"Path to GCC-XML executable.", cmCacheManager::FILEPATH);
cmCacheManager::FILEPATH);
return "NOTFOUND"; return "NOTFOUND";
} }
...@@ -428,12 +427,11 @@ std::string cmCableWrapTclCommand::GetGccXmlFromCache() const ...@@ -428,12 +427,11 @@ std::string cmCableWrapTclCommand::GetGccXmlFromCache() const
std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const
{ {
const char* gccxmlFlags = const char* gccxmlFlags =
cmCacheManager::GetInstance()->GetCacheValue("GCCXML_FLAGS"); m_Makefile->GetDefinition("GCCXML_FLAGS");
if(gccxmlFlags) if(gccxmlFlags)
{ return gccxmlFlags; } { return gccxmlFlags; }
m_Makefile->AddDefinition("GCCXML_FLAGS",""); m_Makefile->AddCacheDefinition(
cmCacheManager::GetInstance()->AddCacheEntry(
"GCCXML_FLAGS", "GCCXML_FLAGS",
"", "",
"Flags to GCC-XML to get it to parse the native compiler's headers.", "Flags to GCC-XML to get it to parse the native compiler's headers.",
...@@ -449,14 +447,13 @@ std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const ...@@ -449,14 +447,13 @@ std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const
std::string cmCableWrapTclCommand::GetCableFromCache() const std::string cmCableWrapTclCommand::GetCableFromCache() const
{ {
const char* cable = const char* cable =
cmCacheManager::GetInstance()->GetCacheValue("CABLE"); m_Makefile->GetDefinition("CABLE");
if(cable) if(cable)
{ return cable; } { return cable; }
m_Makefile->AddDefinition("CABLE","NOTFOUND"); m_Makefile->AddCacheDefinition("CABLE",
cmCacheManager::GetInstance()->AddCacheEntry("CABLE", "NOTFOUND",
"NOTFOUND", "Path to CABLE executable.",
"Path to CABLE executable.", cmCacheManager::FILEPATH);
cmCacheManager::FILEPATH);
return "NOTFOUND"; return "NOTFOUND";
} }
...@@ -375,18 +375,6 @@ const char* cmCacheManager::GetCacheValue(const char* key) const ...@@ -375,18 +375,6 @@ const char* cmCacheManager::GetCacheValue(const char* key) const
} }
bool cmCacheManager::IsOn(const char* key) const
{
if(!m_Cache.count(key))
{
return false;
}
const std::string &v = m_Cache.find(key)->second.m_Value;
return cmSystemTools::IsOn(v.c_str());
}
void cmCacheManager::PrintCache(std::ostream& out) const void cmCacheManager::PrintCache(std::ostream& out) const
{ {
out << "=================================================" << std::endl; out << "=================================================" << std::endl;
......
...@@ -70,55 +70,55 @@ public: ...@@ -70,55 +70,55 @@ public:
* can be different than just a path input * can be different than just a path input
*/ */
static CacheEntryType StringToType(const char*); static CacheEntryType StringToType(const char*);
//! Singleton pattern get instance of the cmCacheManager. ///! Singleton pattern get instance of the cmCacheManager.
static cmCacheManager* GetInstance(); static cmCacheManager* GetInstance();
//! Load a cache for given makefile. Loads from ouput home. ///! Load a cache for given makefile. Loads from ouput home.
bool LoadCache(cmMakefile*); bool LoadCache(cmMakefile*);
//! Load a cache for given makefile. Loads from path/CMakeCache.txt. ///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const char* path); bool LoadCache(const char* path);
bool LoadCache(const char* path, bool internal); bool LoadCache(const char* path, bool internal);
//! Put cache definitions into makefile ///! Put cache definitions into makefile
void DefineCache(cmMakefile*); void DefineCache(cmMakefile*);
//! Save cache for given makefile. Saves to ouput home CMakeCache.txt. ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt.
bool SaveCache(cmMakefile*) ; bool SaveCache(cmMakefile*) ;
//! Save cache for given makefile. Saves to ouput path/CMakeCache.txt ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
bool SaveCache(const char* path) ; bool SaveCache(const char* path) ;
///! Print the cache to a stream
void PrintCache(std::ostream&) const;
//! Add an entry into the cache ///! Get the cache map ivar.
void AddCacheEntry(const char* key, const char* value, const CacheEntryMap &GetCacheMap() const { return m_Cache; }
const char* helpString, CacheEntryType type);
//! Add a BOOL entry into the cache ///! Get a cache entry object for a key
void AddCacheEntry(const char* key, bool, const char* helpString); CacheEntry *GetCacheEntry(const char *key);
//! Remove an entry from the cache ///! Remove an entry from the cache
void RemoveCacheEntry(const char* key); void RemoveCacheEntry(const char* key);
//! Print the cache to a stream protected:
CacheEntry *GetCacheEntry(const char *key); ///! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value,
const char* helpString, CacheEntryType type);
///! Add a BOOL entry into the cache
void AddCacheEntry(const char* key, bool, const char* helpString);
//! Get a value from the cache given a key ///! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const; const char* GetCacheValue(const char* key) const;
//! Test a boolean cache entry to see if it is true or false, returns false
// if no entry.
bool IsOn(const char*) const;
//! Print the cache to a stream
void PrintCache(std::ostream&) const;
//! Get the cache map ivar.
const CacheEntryMap &GetCacheMap() const { return m_Cache; }
private: private:
static void OutputHelpString(std::ofstream& fout, static void OutputHelpString(std::ofstream& fout,
const std::string& helpString); const std::string& helpString);
static cmCacheManager* s_Instance; static cmCacheManager* s_Instance;
CacheEntryMap m_Cache; CacheEntryMap m_Cache;
// Only cmake and cmMakefile should be able to add cache values
// the commands should never use the cmCacheManager directly
friend class cmMakefile; // allow access to add cache values
friend class cmake; // allow access to add cache values
}; };
#endif #endif
#undef CMAKE_NO_STD_NAMESPACE #undef CMAKE_NO_STD_NAMESPACE
#undef CMAKE_NO_ANSI_STREAM_HEADERS #undef CMAKE_NO_ANSI_STREAM_HEADERS
#undef CMAKE_NO_ANSI_FOR_SCOPE
...@@ -61,7 +61,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args) ...@@ -61,7 +61,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args)
// If the cache entry already exists, we are done. // If the cache entry already exists, we are done.
std::string cacheName = args[1]; std::string cacheName = args[1];
const char* cacheValue = const char* cacheValue =
cmCacheManager::GetInstance()->GetCacheValue(cacheName.c_str()); m_Makefile->GetDefinition(cacheName.c_str());
if(cacheValue && (std::string(cacheValue) != "")) if(cacheValue && (std::string(cacheValue) != ""))
{ return true; } { return true; }
...@@ -95,8 +95,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args) ...@@ -95,8 +95,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args)
#endif #endif
// Add the cache entry with the flags found. // Add the cache entry with the flags found.
m_Makefile->AddDefinition(cacheName.c_str(), m_Flags.c_str()); m_Makefile->AddCacheDefinition(
cmCacheManager::GetInstance()->AddCacheEntry(
cacheName.c_str(), cacheName.c_str(),
m_Flags.c_str(), m_Flags.c_str(),
"Flags to GCC-XML to get it to parse the native compiler's headers.", "Flags to GCC-XML to get it to parse the native compiler's headers.",
......
...@@ -371,7 +371,7 @@ void cmDSPWriter::WriteDSPEndGroup(std::ostream& fout) ...@@ -371,7 +371,7 @@ void cmDSPWriter::WriteDSPEndGroup(std::ostream& fout)
void cmDSPWriter::SetBuildType(BuildType b, const char *libName) void cmDSPWriter::SetBuildType(BuildType b, const char *libName)
{ {
std::string root= cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT"); std::string root= m_Makefile->GetDefinition("CMAKE_ROOT");
const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
if( def) if( def)
......
...@@ -220,7 +220,7 @@ void cmDSWWriter::WriteProject(std::ostream& fout, ...@@ -220,7 +220,7 @@ void cmDSWWriter::WriteProject(std::ostream& fout,
{ {
// is the library part of this DSW ? If so add dependency // is the library part of this DSW ? If so add dependency
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(j->first.c_str()); = m_Makefile->GetDefinition(j->first.c_str());
if(cacheValue) if(cacheValue)
{ {
fout << "Begin Project Dependency\n"; fout << "Begin Project Dependency\n";
......
...@@ -62,15 +62,9 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args) ...@@ -62,15 +62,9 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args)
std::string helpString = "Where can the "; std::string helpString = "Where can the ";
helpString += args[1] + " file be found"; helpString += args[1] + " file be found";
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(define); = m_Makefile->GetDefinition(define);
if(cacheValue && strcmp(cacheValue, "NOTFOUND")) if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{ {
m_Makefile->AddDefinition(define, cacheValue);
// update help string if changed
cmCacheManager::GetInstance()->AddCacheEntry(define,
cacheValue,
helpString.c_str(),
cmCacheManager::FILEPATH);
return true; return true;
} }
// if it is not in the cache, then search the system path // if it is not in the cache, then search the system path
...@@ -95,11 +89,10 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args) ...@@ -95,11 +89,10 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args)
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
// Save the value in the cache // Save the value in the cache
m_Makefile->AddDefinition(define, tryPath.c_str()); m_Makefile->AddCacheDefinition(define,
cmCacheManager::GetInstance()->AddCacheEntry(define, tryPath.c_str(),
tryPath.c_str(), helpString.c_str(),
helpString.c_str(), cmCacheManager::FILEPATH);
cmCacheManager::FILEPATH);
return true; return true;
} }
} }
......
...@@ -118,14 +118,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args) ...@@ -118,14 +118,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args)
} }
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str()); = m_Makefile->GetDefinition(args[0].c_str());
if(cacheValue && strcmp(cacheValue, "NOTFOUND")) if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{ {
m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
cacheValue,
helpString.c_str(),
cmCacheManager::FILEPATH);
return true; return true;
} }
...@@ -137,18 +132,17 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args) ...@@ -137,18 +132,17 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args)
path); path);
if(library != "") if(library != "")
{ {
m_Makefile->AddDefinition(args[0].c_str(), library.c_str()); m_Makefile->AddCacheDefinition(args[0].c_str(),
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), library.c_str(),
library.c_str(), helpString.c_str(),
helpString.c_str(), cmCacheManager::FILEPATH);
cmCacheManager::FILEPATH);
return true; return true;
} }
} }
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND", "NOTFOUND",
helpString.c_str(), helpString.c_str(),
cmCacheManager::FILEPATH); cmCacheManager::FILEPATH);
return true; return true;
} }
...@@ -55,14 +55,9 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args) ...@@ -55,14 +55,9 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
std::string helpString = "What is the path where the file "; std::string helpString = "What is the path where the file ";
helpString += args[1] + " can be found"; helpString += args[1] + " can be found";
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str()); = m_Makefile->GetDefinition(args[0].c_str());
if(cacheValue && strcmp(cacheValue, "NOTFOUND")) if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{ {
m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
cacheValue,
helpString.c_str(),
cmCacheManager::PATH);
return true; return true;
} }
...@@ -88,19 +83,18 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args) ...@@ -88,19 +83,18 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
path[k] = cmSystemTools::CollapseFullPath(path[k].c_str()); path[k] = cmSystemTools::CollapseFullPath(path[k].c_str());
m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); m_Makefile->AddCacheDefinition(args[0].c_str(),
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), path[k].c_str(),
path[k].c_str(), helpString.c_str(),
helpString.c_str(), cmCacheManager::PATH);
cmCacheManager::PATH);
return true; return true;
} }
} }
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND", "NOTFOUND",
helpString.c_str(), helpString.c_str(),
cmCacheManager::PATH); cmCacheManager::PATH);
return true; return true;
} }
...@@ -59,10 +59,9 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args) ...@@ -59,10 +59,9 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args)
// Now check and see if the value has been stored in the cache // Now check and see if the value has been stored in the cache
// already, if so use that value and don't look for the program // already, if so use that value and don't look for the program
const char* cacheValue const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(define); = m_Makefile->GetDefinition(define);
if(cacheValue && strcmp(cacheValue, "NOTFOUND")) if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{ {
m_Makefile->AddDefinition(define, cacheValue);
return true; return true;
} }
std::vector<std::string> path; std::vector<std::string> path;
...@@ -120,18 +119,18 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args) ...@@ -120,18 +119,18 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args)
if(result != "") if(result != "")
{ {
// Save the value in the cache // Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry(define, m_Makefile->AddCacheDefinition(define,
result.c_str(), result.c_str(),
"Path to a program.", "Path to a program.",
cmCacheManager::FILEPATH); cmCacheManager::FILEPATH);
m_Makefile->AddDefinition(define, result.c_str());
return true; return true;
} }
} }
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND", "NOTFOUND",
"Path to a program", "Path to a program",
cmCacheManager::FILEPATH); cmCacheManager::FILEPATH);
return true; return true;
} }
...@@ -70,7 +70,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string>& args) ...@@ -70,7 +70,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string>& args)
m_Makefile->AddLinkLibrary(i->c_str()); m_Makefile->AddLinkLibrary(i->c_str());
} }
const char* dir = cmCacheManager::GetInstance()->GetCacheValue(i->c_str()); const char* dir = m_Makefile->GetDefinition(i->c_str());
if( dir ) if( dir )
{ {
m_Makefile->AddLinkDirectory( dir ); m_Makefile->AddLinkDirectory( dir );
......
...@@ -82,14 +82,14 @@ void cmMSProjectGenerator::SetLocal(bool local) ...@@ -82,14 +82,14 @@ void cmMSProjectGenerator::SetLocal(bool local)
void cmMSProjectGenerator::ComputeSystemInfo() void cmMSProjectGenerator::ComputeSystemInfo()
{ {
// now load the settings // now load the settings
if(!cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT")) if(!m_Makefile->GetDefinition("CMAKE_ROOT"))
{ {
cmSystemTools::Error( cmSystemTools::Error(
"CMAKE_ROOT has not been defined, bad GUI or driver program"); "CMAKE_ROOT has not been defined, bad GUI or driver program");
return; return;
} }
std::string fpath = std::string fpath =
cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT"); m_Makefile->GetDefinition("CMAKE_ROOT");
fpath += "/Templates/CMakeWindowsSystemConfig.cmake"; fpath += "/Templates/CMakeWindowsSystemConfig.cmake";
m_Makefile->ReadListFile(NULL,fpath.c_str()); m_Makefile->ReadListFile(NULL,fpath.c_str());
} }
...@@ -571,12 +571,23 @@ void cmMakefile::AddIncludeDirectory(const char* inc) ...@@ -571,12 +571,23 @@ void cmMakefile::AddIncludeDirectory(const char* inc)
} }
} }
void cmMakefile::AddDefinition(const char* name, const char* value) void cmMakefile::AddDefinition(const char* name, const char* value)
{ {
m_Definitions.erase( DefinitionMap::key_type(name)); m_Definitions.erase( DefinitionMap::key_type(name));
m_Definitions.insert(DefinitionMap::value_type(name, value)); m_Definitions.insert(DefinitionMap::value_type(name, value));
} }
void cmMakefile::AddCacheDefinition(const char* name, const char* value,
const char* doc,
cmCacheManager::CacheEntryType type)
{
cmCacheManager::GetInstance()->AddCacheEntry(name, value, doc, type);
this->AddDefinition(name, value);
}
void cmMakefile::AddDefinition(const char* name, bool value) void cmMakefile::AddDefinition(const char* name, bool value)
{ {
if(value) if(value)
...@@ -591,6 +602,13 @@ void cmMakefile::AddDefinition(const char* name, bool value) ...@@ -591,6 +602,13 @@ void cmMakefile::AddDefinition(const char* name, bool value)
} }
} }
void cmMakefile::AddCacheDefinition(const char* name, bool value, const char* doc)
{
cmCacheManager::GetInstance()->AddCacheEntry(name, value, doc);
this->AddDefinition(name, value);
}
void cmMakefile::SetProjectName(const char* p) void cmMakefile::SetProjectName(const char* p)
{ {
m_ProjectName = p; m_ProjectName = p;
...@@ -769,6 +787,12 @@ void cmMakefile::ExpandVariables() ...@@ -769,6 +787,12 @@ void cmMakefile::ExpandVariables()
} }
} }
bool cmMakefile::IsOn(const char* name)
{
const char* value = this->GetDefinition(name);
return cmSystemTools::IsOn(value);
}
const char* cmMakefile::GetDefinition(const char* name) const char* cmMakefile::GetDefinition(const char* name)
{ {
DefinitionMap::iterator pos = m_Definitions.find(name); DefinitionMap::iterator pos = m_Definitions.find(name);
...@@ -776,7 +800,7 @@ const char* cmMakefile::GetDefinition(const char* name) ...@@ -776,7 +800,7 @@ const char* cmMakefile::GetDefinition(const char* name)
{ {
return (*pos).second.c_str(); return (*pos).second.c_str();
} }
return 0; return cmCacheManager::GetInstance()->GetCacheValue(name);
} }
int cmMakefile::DumpDocumentationToFile(const char *fileName) int cmMakefile::DumpDocumentationToFile(const char *fileName)
......
...@@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmSourceGroup.h" #include "cmSourceGroup.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmCacheManager.h"
class cmFunctionBlocker; class cmFunctionBlocker;
class cmCommand;