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()
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",
......
......@@ -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,
m_Makefile->AddCacheDefinition(define,
makecommand.c_str(),
"Command used to build entire project from the command line.",
"Command used to build entire project "
"from the command line.",
cmCacheManager::STRING);
m_Makefile->AddDefinition(define, makecommand.c_str());
return true;
}
......@@ -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",
m_Makefile->AddCacheDefinition("BUILDNAME",
cv.c_str(),
"Name of build.",
cmCacheManager::STRING);
m_Makefile->AddDefinition("BUILDNAME", cv.c_str());
}
else
{
m_Makefile->AddDefinition("BUILDNAME", cacheValue);
}
return true;
}
......@@ -101,13 +95,10 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
cmSystemTools::ReplaceString(buildname,
")", "_");
cmCacheManager::GetInstance()->
AddCacheEntry("BUILDNAME",
m_Makefile->AddCacheDefinition("BUILDNAME",
buildname.c_str(),
"Name of build.",
cmCacheManager::STRING);
m_Makefile->AddDefinition("BUILDNAME", buildname.c_str());
return true;
}
......@@ -408,12 +408,11 @@ 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",
m_Makefile->AddCacheDefinition("GCCXML",
"NOTFOUND",
"Path to GCC-XML executable.",
cmCacheManager::FILEPATH);
......@@ -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,12 +447,11 @@ 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",
m_Makefile->AddCacheDefinition("CABLE",
"NOTFOUND",
"Path to CABLE executable.",
cmCacheManager::FILEPATH);
......
......@@ -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;
......
......@@ -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) ;
//! 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);
///! Print the cache to a stream
void PrintCache(std::ostream&) const;
//! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
///! Get the cache map ivar.
const CacheEntryMap &GetCacheMap() const { return m_Cache; }
//! Print the cache to a stream
///! Get a cache entry object for a key
CacheEntry *GetCacheEntry(const char *key);
//! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const;
///! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
//! Test a boolean cache entry to see if it is true or false, returns false
// if no entry.
bool IsOn(const char*) const;
protected:
///! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value,
const char* helpString, CacheEntryType type);
//! Print the cache to a stream
void PrintCache(std::ostream&) const;
///! Add a BOOL entry into the cache
void AddCacheEntry(const char* key, bool, const char* helpString);
//! Get the cache map ivar.
const CacheEntryMap &GetCacheMap() const { return m_Cache; }
///! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const;
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
#undef CMAKE_NO_STD_NAMESPACE
#undef CMAKE_NO_ANSI_STREAM_HEADERS
#undef CMAKE_NO_ANSI_FOR_SCOPE
......@@ -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.",
......
......@@ -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)
......
......@@ -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";
......
......@@ -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,8 +89,7 @@ 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,
m_Makefile->AddCacheDefinition(define,
tryPath.c_str(),
helpString.c_str(),
cmCacheManager::FILEPATH);
......
......@@ -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,15 +132,14 @@ 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(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
library.c_str(),
helpString.c_str(),
cmCacheManager::FILEPATH);
return true;
}
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND",
helpString.c_str(),
cmCacheManager::FILEPATH);
......
......@@ -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,8 +83,7 @@ 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(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
path[k].c_str(),
helpString.c_str(),
cmCacheManager::PATH);
......@@ -97,7 +91,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
}
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND",
helpString.c_str(),
cmCacheManager::PATH);
......
......@@ -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,15 +119,15 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args)
if(result != "")
{
// Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry(define,
m_Makefile->AddCacheDefinition(define,
result.c_str(),
"Path to a program.",
cmCacheManager::FILEPATH);
m_Makefile->AddDefinition(define, result.c_str());
return true;
}
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
"NOTFOUND",
"Path to a program",
cmCacheManager::FILEPATH);
......
......@@ -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 );
......
......@@ -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());
}
......@@ -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)
......
......@@ -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,9 +448,16 @@ 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.
*/
......
......@@ -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,16 +60,13 @@ bool cmOptionCommand::InitialPass(std::vector<std::string>& args)
{
initialValue = args[2].c_str();
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
cmSystemTools::IsOn(initialValue),
args[1].c_str());
m_Makefile->AddDefinition(args[0].c_str(), initialValue);
}
else
{
m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
cmCacheManager::GetInstance()->
AddCacheEntry(args[0].c_str(),
m_Makefile->AddCacheDefinition(args[0].c_str(),
cmSystemTools::IsOn(cacheValue), args[1].c_str());
}
......
......@@ -55,16 +55,10 @@ 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->AddCacheDefinition(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->AddCacheDefinition(srcdir.c_str(),
m_Makefile->GetCurrentDirectory(),
"Value Computed by CMake", cmCacheManager::STATIC);
......
......@@ -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,16 +126,19 @@ 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,
m_Makefile->AddCacheDefinition(variable,
value.c_str(),
docstring,
type);
}
else
{
// add the definition
m_Makefile->AddDefinition(variable, value.c_str());
}
return true;
}
......@@ -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",
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;
}
......@@ -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
......@@ -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;
}
......