summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-08-08 11:54:46 -0400
committerBill Hoffman <bill.hoffman@kitware.com>2001-08-08 11:54:46 -0400
commitdb1303aa7d00f49a0fdf66f120eb3e6cb0e445fe (patch)
treead569e72f02849e50e625faa1350bb05a3af08f9 /Source
parent61ec323b6a1c4e5a44331014447e3d1d31dc1b6b (diff)
downloadcmake-db1303aa7d00f49a0fdf66f120eb3e6cb0e445fe.tar.gz
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
Diffstat (limited to 'Source')
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp2
-rw-r--r--Source/cmBuildCommand.cxx13
-rw-r--r--Source/cmBuildNameCommand.cxx27
-rw-r--r--Source/cmCableWrapTclCommand.cxx27
-rw-r--r--Source/cmCacheManager.cxx12
-rw-r--r--Source/cmCacheManager.h52
-rw-r--r--Source/cmConfigure.h.in2
-rw-r--r--Source/cmConfigureGccXmlCommand.cxx5
-rw-r--r--Source/cmDSPWriter.cxx2
-rw-r--r--Source/cmDSWWriter.cxx2
-rw-r--r--Source/cmFindFileCommand.cxx17
-rw-r--r--Source/cmFindLibraryCommand.cxx24
-rw-r--r--Source/cmFindPathCommand.cxx24
-rw-r--r--Source/cmFindProgramCommand.cxx21
-rw-r--r--Source/cmLinkLibrariesCommand.cxx2
-rw-r--r--Source/cmMSProjectGenerator.cxx4
-rw-r--r--Source/cmMakefile.cxx26
-rw-r--r--Source/cmMakefile.h15
-rw-r--r--Source/cmOptionCommand.cxx15
-rw-r--r--Source/cmProjectCommand.cxx18
-rw-r--r--Source/cmSetCommand.cxx17
-rw-r--r--Source/cmSiteNameCommand.cxx17
-rw-r--r--Source/cmStandardIncludes.h18
-rw-r--r--Source/cmSystemTools.cxx13
-rw-r--r--Source/cmUnixMakefileGenerator.cxx14
-rw-r--r--Source/cmUtilitySourceCommand.cxx21
-rw-r--r--Source/cmVTKWrapJavaCommand.cxx2
-rw-r--r--Source/cmVTKWrapPythonCommand.cxx2
-rw-r--r--Source/cmVTKWrapTclCommand.cxx8
29 files changed, 210 insertions, 212 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index f03e0f2719..92096680a6 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -533,7 +533,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
switch(value.m_Type )
{
case cmCacheManager::BOOL:
- if(cmCacheManager::GetInstance()->IsOn(key))
+ if(cmSystemTools::IsOn(value.m_Value.c_str()))
{
m_CacheEntriesList.AddProperty(key,
"ON",
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index 1f06b955cc..8d752372d4 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -50,7 +50,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args)
}
const char* define = args[0].c_str();
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(define);
+ = m_Makefile->GetDefinition(define);
if(cacheValue)
{
return true;
@@ -73,12 +73,11 @@ bool cmBuildCommand::InitialPass(std::vector<std::string>& args)
makecommand = makeprogram;
makecommand += " -k";
}
- cmCacheManager::GetInstance()->
- AddCacheEntry(define,
- makecommand.c_str(),
- "Command used to build entire project from the command line.",
- cmCacheManager::STRING);
- m_Makefile->AddDefinition(define, makecommand.c_str());
+ m_Makefile->AddCacheDefinition(define,
+ makecommand.c_str(),
+ "Command used to build entire project "
+ "from the command line.",
+ cmCacheManager::STRING);
return true;
}
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 9bf4b1a35b..5016825bf1 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -49,7 +49,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
return false;
}
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue("BUILDNAME");
+ = m_Makefile->GetDefinition("BUILDNAME");
if(cacheValue)
{
// do we need to correct the value?
@@ -60,16 +60,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
cmSystemTools::ReplaceString(cv,"/", "_");
cmSystemTools::ReplaceString(cv,"(", "_");
cmSystemTools::ReplaceString(cv,")", "_");
- cmCacheManager::GetInstance()->
- AddCacheEntry("BUILDNAME",
- cv.c_str(),
- "Name of build.",
- cmCacheManager::STRING);
- m_Makefile->AddDefinition("BUILDNAME", cv.c_str());
- }
- else
- {
- m_Makefile->AddDefinition("BUILDNAME", cacheValue);
+ m_Makefile->AddCacheDefinition("BUILDNAME",
+ cv.c_str(),
+ "Name of build.",
+ cmCacheManager::STRING);
}
return true;
}
@@ -101,13 +95,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
cmSystemTools::ReplaceString(buildname,
")", "_");
- cmCacheManager::GetInstance()->
- AddCacheEntry("BUILDNAME",
- buildname.c_str(),
- "Name of build.",
- cmCacheManager::STRING);
-
- m_Makefile->AddDefinition("BUILDNAME", buildname.c_str());
+ m_Makefile->AddCacheDefinition("BUILDNAME",
+ buildname.c_str(),
+ "Name of build.",
+ cmCacheManager::STRING);
return true;
}
diff --git a/Source/cmCableWrapTclCommand.cxx b/Source/cmCableWrapTclCommand.cxx
index c1227b9973..b77825fe35 100644
--- a/Source/cmCableWrapTclCommand.cxx
+++ b/Source/cmCableWrapTclCommand.cxx
@@ -408,15 +408,14 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
std::string cmCableWrapTclCommand::GetGccXmlFromCache() const
{
const char* gccxml =
- cmCacheManager::GetInstance()->GetCacheValue("GCCXML");
+ m_Makefile->GetDefinition("GCCXML");
if(gccxml)
{ return gccxml; }
- m_Makefile->AddDefinition("GCCXML","NOTFOUND");
- cmCacheManager::GetInstance()->AddCacheEntry("GCCXML",
- "NOTFOUND",
- "Path to GCC-XML executable.",
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition("GCCXML",
+ "NOTFOUND",
+ "Path to GCC-XML executable.",
+ cmCacheManager::FILEPATH);
return "NOTFOUND";
}
@@ -428,12 +427,11 @@ std::string cmCableWrapTclCommand::GetGccXmlFromCache() const
std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const
{
const char* gccxmlFlags =
- cmCacheManager::GetInstance()->GetCacheValue("GCCXML_FLAGS");
+ m_Makefile->GetDefinition("GCCXML_FLAGS");
if(gccxmlFlags)
{ return gccxmlFlags; }
- m_Makefile->AddDefinition("GCCXML_FLAGS","");
- cmCacheManager::GetInstance()->AddCacheEntry(
+ m_Makefile->AddCacheDefinition(
"GCCXML_FLAGS",
"",
"Flags to GCC-XML to get it to parse the native compiler's headers.",
@@ -449,14 +447,13 @@ std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const
std::string cmCableWrapTclCommand::GetCableFromCache() const
{
const char* cable =
- cmCacheManager::GetInstance()->GetCacheValue("CABLE");
+ m_Makefile->GetDefinition("CABLE");
if(cable)
{ return cable; }
- m_Makefile->AddDefinition("CABLE","NOTFOUND");
- cmCacheManager::GetInstance()->AddCacheEntry("CABLE",
- "NOTFOUND",
- "Path to CABLE executable.",
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition("CABLE",
+ "NOTFOUND",
+ "Path to CABLE executable.",
+ cmCacheManager::FILEPATH);
return "NOTFOUND";
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 289961d9e7..3715f096f3 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -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
{
out << "=================================================" << std::endl;
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index a3a013a5b5..bb7a971c8c 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -70,55 +70,55 @@ public:
* can be different than just a path input
*/
static CacheEntryType StringToType(const char*);
- //! Singleton pattern get instance of the cmCacheManager.
+ ///! Singleton pattern get instance of the cmCacheManager.
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*);
- //! 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 internal);
- //! Put cache definitions into makefile
+ ///! Put cache definitions into makefile
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*) ;
- //! 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) ;
+
+ ///! Print the cache to a stream
+ void PrintCache(std::ostream&) const;
- //! Add an entry into the cache
- void AddCacheEntry(const char* key, const char* value,
- const char* helpString, CacheEntryType type);
+ ///! Get the cache map ivar.
+ const CacheEntryMap &GetCacheMap() const { return m_Cache; }
- //! Add a BOOL entry into the cache
- void AddCacheEntry(const char* key, bool, const char* helpString);
+ ///! Get a cache entry object for a key
+ CacheEntry *GetCacheEntry(const char *key);
- //! Remove an entry from the cache
+ ///! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
- //! Print the cache to a stream
- CacheEntry *GetCacheEntry(const char *key);
+protected:
+ ///! 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;
- //! 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:
static void OutputHelpString(std::ofstream& fout,
const std::string& helpString);
static cmCacheManager* s_Instance;
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
diff --git a/Source/cmConfigure.h.in b/Source/cmConfigure.h.in
index 0c3844168a..99595fcaff 100644
--- a/Source/cmConfigure.h.in
+++ b/Source/cmConfigure.h.in
@@ -1,2 +1,4 @@
#undef CMAKE_NO_STD_NAMESPACE
#undef CMAKE_NO_ANSI_STREAM_HEADERS
+#undef CMAKE_NO_ANSI_FOR_SCOPE
+
diff --git a/Source/cmConfigureGccXmlCommand.cxx b/Source/cmConfigureGccXmlCommand.cxx
index 6523e5d616..69e2dd5161 100644
--- a/Source/cmConfigureGccXmlCommand.cxx
+++ b/Source/cmConfigureGccXmlCommand.cxx
@@ -61,7 +61,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args)
// If the cache entry already exists, we are done.
std::string cacheName = args[1];
const char* cacheValue =
- cmCacheManager::GetInstance()->GetCacheValue(cacheName.c_str());
+ m_Makefile->GetDefinition(cacheName.c_str());
if(cacheValue && (std::string(cacheValue) != ""))
{ return true; }
@@ -95,8 +95,7 @@ bool cmConfigureGccXmlCommand::InitialPass(std::vector<std::string>& args)
#endif
// Add the cache entry with the flags found.
- m_Makefile->AddDefinition(cacheName.c_str(), m_Flags.c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(
+ m_Makefile->AddCacheDefinition(
cacheName.c_str(),
m_Flags.c_str(),
"Flags to GCC-XML to get it to parse the native compiler's headers.",
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index 67f1890e96..bbd1fb04e4 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -371,7 +371,7 @@ void cmDSPWriter::WriteDSPEndGroup(std::ostream& fout)
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");
if( def)
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index 92cc9d4559..6a2f678bcd 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -220,7 +220,7 @@ void cmDSWWriter::WriteProject(std::ostream& fout,
{
// is the library part of this DSW ? If so add dependency
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(j->first.c_str());
+ = m_Makefile->GetDefinition(j->first.c_str());
if(cacheValue)
{
fout << "Begin Project Dependency\n";
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx
index 4bb76e4df2..80bc161e49 100644
--- a/Source/cmFindFileCommand.cxx
+++ b/Source/cmFindFileCommand.cxx
@@ -62,15 +62,9 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args)
std::string helpString = "Where can the ";
helpString += args[1] + " file be found";
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(define);
+ = m_Makefile->GetDefinition(define);
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;
}
// if it is not in the cache, then search the system path
@@ -95,11 +89,10 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args)
if(cmSystemTools::FileExists(tryPath.c_str()))
{
// Save the value in the cache
- m_Makefile->AddDefinition(define, tryPath.c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(define,
- tryPath.c_str(),
- helpString.c_str(),
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition(define,
+ tryPath.c_str(),
+ helpString.c_str(),
+ cmCacheManager::FILEPATH);
return true;
}
}
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index f347ec9bfd..f27fc074ab 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -118,14 +118,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args)
}
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
+ = m_Makefile->GetDefinition(args[0].c_str());
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;
}
@@ -137,18 +132,17 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args)
path);
if(library != "")
{
- m_Makefile->AddDefinition(args[0].c_str(), library.c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- library.c_str(),
- helpString.c_str(),
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ library.c_str(),
+ helpString.c_str(),
+ cmCacheManager::FILEPATH);
return true;
}
}
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- "NOTFOUND",
- helpString.c_str(),
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ "NOTFOUND",
+ helpString.c_str(),
+ cmCacheManager::FILEPATH);
return true;
}
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index c1b4935dc5..cd73ea19df 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -55,14 +55,9 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
std::string helpString = "What is the path where the file ";
helpString += args[1] + " can be found";
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
+ = m_Makefile->GetDefinition(args[0].c_str());
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;
}
@@ -88,19 +83,18 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
if(cmSystemTools::FileExists(tryPath.c_str()))
{
path[k] = cmSystemTools::CollapseFullPath(path[k].c_str());
- m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- path[k].c_str(),
- helpString.c_str(),
- cmCacheManager::PATH);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ path[k].c_str(),
+ helpString.c_str(),
+ cmCacheManager::PATH);
return true;
}
}
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- "NOTFOUND",
- helpString.c_str(),
- cmCacheManager::PATH);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ "NOTFOUND",
+ helpString.c_str(),
+ cmCacheManager::PATH);
return true;
}
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index cf66aee332..d40d7f93ff 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -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
// already, if so use that value and don't look for the program
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(define);
+ = m_Makefile->GetDefinition(define);
if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
{
- m_Makefile->AddDefinition(define, cacheValue);
return true;
}
std::vector<std::string> path;
@@ -120,18 +119,18 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args)
if(result != "")
{
// Save the value in the cache
- cmCacheManager::GetInstance()->AddCacheEntry(define,
- result.c_str(),
- "Path to a program.",
- cmCacheManager::FILEPATH);
- m_Makefile->AddDefinition(define, result.c_str());
+ m_Makefile->AddCacheDefinition(define,
+ result.c_str(),
+ "Path to a program.",
+ cmCacheManager::FILEPATH);
+
return true;
}
}
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- "NOTFOUND",
- "Path to a program",
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ "NOTFOUND",
+ "Path to a program",
+ cmCacheManager::FILEPATH);
return true;
}
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index 246a5d3550..39a809690a 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -70,7 +70,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string>& args)
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 )
{
m_Makefile->AddLinkDirectory( dir );
diff --git a/Source/cmMSProjectGenerator.cxx b/Source/cmMSProjectGenerator.cxx
index 339fe6ace2..1f67d5dcbd 100644
--- a/Source/cmMSProjectGenerator.cxx
+++ b/Source/cmMSProjectGenerator.cxx
@@ -82,14 +82,14 @@ void cmMSProjectGenerator::SetLocal(bool local)
void cmMSProjectGenerator::ComputeSystemInfo()
{
// now load the settings
- if(!cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT"))
+ if(!m_Makefile->GetDefinition("CMAKE_ROOT"))
{
cmSystemTools::Error(
"CMAKE_ROOT has not been defined, bad GUI or driver program");
return;
}
std::string fpath =
- cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
+ m_Makefile->GetDefinition("CMAKE_ROOT");
fpath += "/Templates/CMakeWindowsSystemConfig.cmake";
m_Makefile->ReadListFile(NULL,fpath.c_str());
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f8603c4ec4..804498e38d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -571,12 +571,23 @@ void cmMakefile::AddIncludeDirectory(const char* inc)
}
}
+
void cmMakefile::AddDefinition(const char* name, const char* value)
{
m_Definitions.erase( DefinitionMap::key_type(name));
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)
{
if(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)
{
m_ProjectName = p;
@@ -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)
{
DefinitionMap::iterator pos = m_Definitions.find(name);
@@ -776,7 +800,7 @@ const char* cmMakefile::GetDefinition(const char* name)
{
return (*pos).second.c_str();
}
- return 0;
+ return cmCacheManager::GetInstance()->GetCacheValue(name);
}
int cmMakefile::DumpDocumentationToFile(const char *fileName)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 78e42c7df0..5119599ee7 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cmSystemTools.h"
#include "cmSourceGroup.h"
#include "cmTarget.h"
+#include "cmCacheManager.h"
+
class cmFunctionBlocker;
class cmCommand;
class cmMakefileGenerator;
@@ -213,11 +215,17 @@ public:
* can be used in CMake to refer to lists, directories, etc.
*/
void AddDefinition(const char* name, const char* value);
+ ///! Add a definition to this makefile and the global cmake cache.
+ void AddCacheDefinition(const char* name, const char* value,
+ const char* doc,
+ cmCacheManager::CacheEntryType type);
/**
* Add bool variable definition to the build.
*/
void AddDefinition(const char* name, bool);
+ ///! Add a definition to this makefile and the global cmake cache.
+ void AddCacheDefinition(const char* name, bool, const char* doc);
/**
* Specify the name of the project for this build.
@@ -440,8 +448,15 @@ public:
/**
* Given a variable name, return its value (as a string).
+ * If the variable is not found in this makefile instance, the
+ * cache is then queried.
*/
const char* GetDefinition(const char*);
+
+ /** Test a boolean cache entry to see if it is true or false,
+ * returns false if no entry defined.
+ */
+ bool IsOn(const char* name);
/**
* Get a list of preprocessor define flags.
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 7a0e051a3a..db3c0071a0 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -52,7 +52,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string>& args)
// 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
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
+ = m_Makefile->GetDefinition(args[0].c_str());
if(!cacheValue)
{
const char* initialValue = "Off";
@@ -60,17 +60,14 @@ bool cmOptionCommand::InitialPass(std::vector<std::string>& args)
{
initialValue = args[2].c_str();
}
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- cmSystemTools::IsOn(initialValue),
- args[1].c_str());
- m_Makefile->AddDefinition(args[0].c_str(), initialValue);
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ cmSystemTools::IsOn(initialValue),
+ args[1].c_str());
}
else
{
- m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
- cmCacheManager::GetInstance()->
- AddCacheEntry(args[0].c_str(),
- cmSystemTools::IsOn(cacheValue), args[1].c_str());
+ m_Makefile->AddCacheDefinition(args[0].c_str(),
+ cmSystemTools::IsOn(cacheValue), args[1].c_str());
}
return true;
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 96e17e6093..30ebef3597 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -55,18 +55,12 @@ bool cmProjectCommand::InitialPass(std::vector<std::string>& args)
std::string srcdir = args[0];
srcdir += "_SOURCE_DIR";
- m_Makefile->AddDefinition(bindir.c_str(),
- m_Makefile->GetCurrentOutputDirectory());
- cmCacheManager::GetInstance()->
- AddCacheEntry(bindir.c_str(),
- m_Makefile->GetCurrentOutputDirectory(),
- "Value Computed by CMake", cmCacheManager::STATIC);
- m_Makefile->AddDefinition(srcdir.c_str(),
- m_Makefile->GetCurrentDirectory());
- cmCacheManager::GetInstance()->
- AddCacheEntry(srcdir.c_str(),
- m_Makefile->GetCurrentDirectory(),
- "Value Computed by CMake", cmCacheManager::STATIC);
+ m_Makefile->AddCacheDefinition(bindir.c_str(),
+ m_Makefile->GetCurrentOutputDirectory(),
+ "Value Computed by CMake", cmCacheManager::STATIC);
+ m_Makefile->AddCacheDefinition(srcdir.c_str(),
+ m_Makefile->GetCurrentDirectory(),
+ "Value Computed by CMake", cmCacheManager::STATIC);
bindir = "PROJECT_BINARY_DIR";
srcdir = "PROJECT_SOURCE_DIR";
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 90e2442c60..00e1bc5cf0 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -115,7 +115,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string>& args)
m_Makefile->ExpandVariablesInString(value);
// get the current cache value for the variable
const char* cacheValue =
- cmCacheManager::GetInstance()->GetCacheValue(variable);
+ m_Makefile->GetDefinition(variable);
if(cacheValue)
{
// if it is not a cached value, or it is a cached
@@ -126,15 +126,18 @@ bool cmSetCommand::InitialPass(std::vector<std::string>& args)
return true;
}
}
- // add the definition
- m_Makefile->AddDefinition(variable, value.c_str());
// if it is meant to be in the cache then define it in the cache
if(cache)
{
- cmCacheManager::GetInstance()->AddCacheEntry(variable,
- value.c_str(),
- docstring,
- type);
+ m_Makefile->AddCacheDefinition(variable,
+ value.c_str(),
+ docstring,
+ type);
+ }
+ else
+ {
+ // add the definition
+ m_Makefile->AddDefinition(variable, value.c_str());
}
return true;
}
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index fe81cd73cb..da69ec1177 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -49,19 +49,19 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
return false;
}
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue("SITE");
+ = m_Makefile->GetDefinition("SITE");
if(cacheValue)
{
m_Makefile->AddDefinition("SITE", cacheValue);
return true;
}
- const char* hostname = cmCacheManager::GetInstance()->GetCacheValue("HOSTNAME");
+ const char* hostname = m_Makefile->GetDefinition("HOSTNAME");
if(!hostname)
{
hostname = "hostname";
}
- const char* nslookup = cmCacheManager::GetInstance()->GetCacheValue("NSLOOKUP");
+ const char* nslookup = m_Makefile->GetDefinition("NSLOOKUP");
if(!nslookup)
{
nslookup = "nslookup";
@@ -101,13 +101,12 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
}
}
- cmCacheManager::GetInstance()->
- AddCacheEntry("SITE",
- siteName.c_str(),
- "Name of the computer/site where compile is being run",
- cmCacheManager::STRING);
+ m_Makefile->
+ AddCacheDefinition("SITE",
+ siteName.c_str(),
+ "Name of the computer/site where compile is being run",
+ cmCacheManager::STRING);
- m_Makefile->AddDefinition("SITE", siteName.c_str());
return true;
}
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index dded33bd2c..70c280a932 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -54,8 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#pragma warning ( disable : 4503 )
-// for loop scoping hack
-#define for if(false) {} else for
+#define CMAKE_NO_ANSI_FOR_SCOPE
#endif
#ifdef __ICL
@@ -72,6 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <strstream.h>
#endif
+// we must have stl with the standard include style
#include <vector>
#include <string>
#include <iterator>
@@ -81,13 +81,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <list>
#include <set>
+// include the "c" string header
#include <string.h>
+// if std:: is not supported, then just #define it away
#ifdef CMAKE_NO_STD_NAMESPACE
#define std
-#define for if(false) {} else for
#endif
+// if the compiler does not support ansi for scoping of vars use a
+// #define hack
+#ifdef CMAKE_NO_ANSI_FOR_SCOPE
+#define for if(false) {} else for
+#endif
// check for the 720 compiler on the SGI
// which has some strange properties that I don't think are worth
@@ -100,7 +106,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# endif
#endif
-
# ifdef CM_SGI_CC_720
// the 720 sgi compiler has std:: but not for the stream library,
// so we have to bring it into the std namespace by hand.
@@ -124,9 +129,6 @@ inline bool operator!=(std::string const& a, const char* b)
inline bool operator==(std::string const& a, const char* b)
{ return (a==std::string(b)); }
-// for scoping is not ISO, so use the for hack
-#define for if(false) {} else for
-
-# endif
+# endif // end CM_SGI_CC_720
#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 9755aca462..bd2eb70ffb 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -643,7 +643,18 @@ void cmSystemTools::Error(const char* m1, const char* m2,
void cmSystemTools::Message(const char* m1, const char *title)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
- ::MessageBox(0, m1, title, MB_OK);
+ static bool disableMessages = false;
+ if(disableMessages)
+ {
+ return;
+ }
+ std::string message = m1;
+ message += "\n\n(Press Cancel to suppress any further messages.)";
+ if(::MessageBox(0, message.c_str(), title,
+ MB_OKCANCEL) == IDCANCEL)
+ {
+ disableMessages = true;
+ }
#endif
std::cerr << m1 << std::endl;
}
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 53923dec32..ad6b774a3a 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -555,7 +555,7 @@ void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
if( ! emitted.insert(lib2->first).second ) continue;
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(lib2->first.c_str());
+ = m_Makefile->GetDefinition(lib2->first.c_str());
if(cacheValue )
{
// if there is a cache value then this is a library that cmake
@@ -587,7 +587,7 @@ void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
// add the correct extension
std::string ltname = lib2->first+"_LIBRARY_TYPE";
const char* libType
- = cmCacheManager::GetInstance()->GetCacheValue(ltname.c_str());
+ = m_Makefile->GetDefinition(ltname.c_str());
if(libType && std::string(libType) == "SHARED")
{
libpath += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
@@ -609,7 +609,7 @@ void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
if( ! emitted.insert(lib2->first).second ) continue;
const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue(lib2->first.c_str());
+ = m_Makefile->GetDefinition(lib2->first.c_str());
// if cache and not the current directory add a rule, to
// jump into the directory and build for the first time
if(cacheValue
@@ -621,7 +621,7 @@ void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
// add the correct extension
std::string ltname = lib2->first+"_LIBRARY_TYPE";
const char* libType
- = cmCacheManager::GetInstance()->GetCacheValue(ltname.c_str());
+ = m_Makefile->GetDefinition(ltname.c_str());
if(libType && std::string(libType) == "SHARED")
{
library += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
@@ -1002,7 +1002,7 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
void cmUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
{
const char* root
- = cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
+ = m_Makefile->GetDefinition("CMAKE_ROOT");
fout << "INSTALL = " << root << "/Templates/install-sh -c\n";
fout << "INSTALL_PROGRAM = ${INSTALL}\n";
fout << "INSTALL_DATA = ${INSTALL} -m 644\n";
@@ -1012,7 +1012,7 @@ void cmUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
fout << "\t@echo \"Installing ...\"\n";
const char* prefix
- = cmCacheManager::GetInstance()->GetCacheValue("CMAKE_INSTALL_PREFIX");
+ = m_Makefile->GetDefinition("CMAKE_INSTALL_PREFIX");
if (!prefix)
{
prefix = "/usr/local";
@@ -1362,7 +1362,7 @@ void cmUnixMakefileGenerator::ComputeSystemInfo()
cmd += m_Makefile->GetHomeOutputDirectory();
cmd += "; ";
const char* root
- = cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
+ = m_Makefile->GetDefinition("CMAKE_ROOT");
cmd += root;
cmd += "/Templates/configure";
cmSystemTools::RunCommand(cmd.c_str(), output);
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index fb9769455b..7b3dde145b 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -54,7 +54,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string>& args)
// The first argument is the cache entry name.
std::string cacheEntry = *arg++;
const char* cacheValue =
- cmCacheManager::GetInstance()->GetCacheValue(cacheEntry.c_str());
+ m_Makefile->GetDefinition(cacheEntry.c_str());
// If it exists already, we are done.
// unless this is Major
if(cacheValue &&
@@ -111,20 +111,17 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string>& args)
+utilityName+cmSystemTools::GetExecutableExtension();
// Enter the value into the cache.
- cmCacheManager::GetInstance()->AddCacheEntry(cacheEntry.c_str(),
- utilityExecutable.c_str(),
- "Path to an internal program.",
- cmCacheManager::FILEPATH);
+ m_Makefile->AddCacheDefinition(cacheEntry.c_str(),
+ utilityExecutable.c_str(),
+ "Path to an internal program.",
+ cmCacheManager::FILEPATH);
// add a value into the cache that maps from the
// full path to the name of the project
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
- cmCacheManager::GetInstance()->AddCacheEntry(utilityExecutable.c_str(),
- utilityName.c_str(),
- "Executable to project name.",
- cmCacheManager::INTERNAL);
-
- // Set the definition in the makefile.
- m_Makefile->AddDefinition(cacheEntry.c_str(), utilityExecutable.c_str());
+ m_Makefile->AddCacheDefinition(utilityExecutable.c_str(),
+ utilityName.c_str(),
+ "Executable to project name.",
+ cmCacheManager::INTERNAL);
return true;
}
diff --git a/Source/cmVTKWrapJavaCommand.cxx b/Source/cmVTKWrapJavaCommand.cxx
index 2a91878a2b..1deccb1b80 100644
--- a/Source/cmVTKWrapJavaCommand.cxx
+++ b/Source/cmVTKWrapJavaCommand.cxx
@@ -51,7 +51,7 @@ bool cmVTKWrapJavaCommand::InitialPass(std::vector<std::string>& args)
// 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
- if(!cmCacheManager::GetInstance()->IsOn("VTK_WRAP_JAVA"))
+ if(!m_Makefile->IsOn("VTK_WRAP_JAVA"))
{
return true;
}
diff --git a/Source/cmVTKWrapPythonCommand.cxx b/Source/cmVTKWrapPythonCommand.cxx
index 705a8a4511..3f8b7d49cf 100644
--- a/Source/cmVTKWrapPythonCommand.cxx
+++ b/Source/cmVTKWrapPythonCommand.cxx
@@ -51,7 +51,7 @@ bool cmVTKWrapPythonCommand::InitialPass(std::vector<std::string>& args)
// 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
- if(!cmCacheManager::GetInstance()->IsOn("VTK_WRAP_PYTHON"))
+ if(!m_Makefile->IsOn("VTK_WRAP_PYTHON"))
{
return true;
}
diff --git a/Source/cmVTKWrapTclCommand.cxx b/Source/cmVTKWrapTclCommand.cxx
index 8c76017a37..4342a820e8 100644
--- a/Source/cmVTKWrapTclCommand.cxx
+++ b/Source/cmVTKWrapTclCommand.cxx
@@ -49,16 +49,16 @@ bool cmVTKWrapTclCommand::InitialPass(std::vector<std::string>& args)
return false;
}
+ // keep the library name
+ m_LibraryName = args[0];
+
// 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
- if(!cmCacheManager::GetInstance()->IsOn("VTK_WRAP_TCL"))
+ if(!m_Makefile->IsOn("VTK_WRAP_TCL"))
{
return true;
}
- // keep the library name
- m_LibraryName = args[0];
-
// extract the sources and commands parameters
std::vector<std::string> sources;
bool doing_sources = true;