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

This commit is contained in:
Bill Hoffman 2001-08-08 11:54:46 -04:00
parent 61ec323b6a
commit db1303aa7d
34 changed files with 284 additions and 215 deletions

View File

@ -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",

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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
///! Print the cache to a stream
void PrintCache(std::ostream&) const;
///! Get the cache map ivar.
const CacheEntryMap &GetCacheMap() const { return m_Cache; }
///! Get a cache entry object for a key
CacheEntry *GetCacheEntry(const char *key);
///! Remove an entry from the cache
void RemoveCacheEntry(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
///! Add a BOOL entry into the cache
void AddCacheEntry(const char* key, bool, const char* helpString);
//! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
//! Print the cache to a stream
CacheEntry *GetCacheEntry(const char *key);
//! 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

View File

@ -1,2 +1,4 @@
#undef CMAKE_NO_STD_NAMESPACE
#undef CMAKE_NO_ANSI_STREAM_HEADERS
#undef CMAKE_NO_ANSI_FOR_SCOPE

View File

@ -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.",

View File

@ -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)

View File

@ -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";

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 );

View File

@ -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());
}

View File

@ -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)

View File

@ -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.
*/

View File

@ -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());
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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,21 +111,18 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string>& args)
+utilityName+cmSystemTools::GetExecutableExtension();
// Enter the value into the cache.
cmCacheManager::GetInstance()->AddCacheEntry(cacheEntry.c_str(),
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(),
m_Makefile->AddCacheDefinition(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());
return true;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -50,4 +50,5 @@ SET (CMAKE_X_CFLAGS "@X_CFLAGS@" CACHE STRING "X11 extra flags")
SET (CMAKE_HAS_X @CMAKE_HAS_X@ CACHE INTERNAL "Is X11 around")
SET (CMAKE_NO_ANSI_STREAM_HEADERS @CMAKE_NO_ANSI_STREAM_HEADERS@ CACHE INTERNAL "does the compiler support headers like iostream ")
SET (CMAKE_NO_STD_NAMESPACE @CMAKE_NO_STD_NAMESPACE@ CACHE INTERNAL "does the compiler support std:: ")
SET (CMAKE_NO_ANSI_FOR_SCOPE @CMAKE_NO_ANSI_FOR_SCOPE@ CACHE INTERNAL "does the compiler support ansi for scoping.")
SET (CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@ CACHE INTERNAL "Is the compile GNU C++")

23
Templates/configure vendored
View File

@ -2961,6 +2961,24 @@ fi
# check to see if for scoping is supported
if test $ac_cv_prog_gxx = no; then
echo $ac_n "checking ansi for scope support ""... $ac_c" 1>&6
echo "configure:2968: checking ansi for scope support " >&5
rm -rf conftest.*
cat > conftest.cc <<!
void foo() { for(int i;;); for(int i;;); }
!
if test -z "`${CXX} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
echo "$ac_t""yes" 1>&6
else
CMAKE_NO_ANSI_FOR_SCOPE="1"
echo "$ac_t""no" 1>&6
fi
fi
if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
SHLIB_CFLAGS="-fPIC"
fi
@ -2971,7 +2989,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2975: checking for $ac_word" >&5
echo "configure:2993: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RUNMAKE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -3011,7 +3029,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:3015: checking for $ac_word" >&5
echo "configure:3033: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_CMAKE_AR_TMP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -3249,6 +3267,7 @@ s%@CMAKE_ANSI_CFLAGS@%$CMAKE_ANSI_CFLAGS%g
s%@CMAKE_TEMPLATE_FLAGS@%$CMAKE_TEMPLATE_FLAGS%g
s%@CMAKE_NO_STD_NAMESPACE@%$CMAKE_NO_STD_NAMESPACE%g
s%@CMAKE_NO_ANSI_STREAM_HEADERS@%$CMAKE_NO_ANSI_STREAM_HEADERS%g
s%@CMAKE_NO_ANSI_FOR_SCOPE@%$CMAKE_NO_ANSI_FOR_SCOPE%g
s%@RUNMAKE@%$RUNMAKE%g
s%@CMAKE_AR_TMP@%$CMAKE_AR_TMP%g
s%@CMAKE_AR@%$CMAKE_AR%g

View File

@ -536,6 +536,23 @@ fi
AC_SUBST(CMAKE_NO_ANSI_STREAM_HEADERS)
# check to see if for scoping is supported
if test $ac_cv_prog_gxx = no; then
AC_MSG_CHECKING( ansi for scope support )
rm -rf conftest.*
cat > conftest.cc <<!
void foo() { for(int i;;); for(int i;;); }
!
if test -z "`${CXX} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
echo "$ac_t""yes" 1>&6
else
CMAKE_NO_ANSI_FOR_SCOPE="1"
echo "$ac_t""no" 1>&6
fi
fi
AC_SUBST(CMAKE_NO_ANSI_FOR_SCOPE)
if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
SHLIB_CFLAGS="-fPIC"
fi

21
configure vendored
View File

@ -983,13 +983,32 @@ EOF
fi
fi
# check to see if for scoping is supported
if test $ac_cv_prog_gxx = no; then
echo $ac_n "checking ansi for scope support ""... $ac_c" 1>&6
echo "configure:990: checking ansi for scope support " >&5
rm -rf conftest.*
cat > conftest.cc <<!
void foo() { for(int i;;); for(int i;;); }
!
if test -z "`${CXX} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
echo "$ac_t""yes" 1>&6
else
cat >> confdefs.h <<\EOF
#define CMAKE_NO_ANSI_FOR_SCOPE 1
EOF
echo "$ac_t""no" 1>&6
fi
fi
# find make to use to build cmake, prefer gmake
for ac_prog in gmake make
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:993: checking for $ac_word" >&5
echo "configure:1012: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RUNMAKE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else

View File

@ -91,6 +91,21 @@ void foo() { std::list<int> l; }
fi
fi
# check to see if for scoping is supported
if test $ac_cv_prog_gxx = no; then
AC_MSG_CHECKING( ansi for scope support )
rm -rf conftest.*
cat > conftest.cc <<!
void foo() { for(int i;;); for(int i;;); }
!
if test -z "`${CXX} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
echo "$ac_t""yes" 1>&6
else
AC_DEFINE(CMAKE_NO_ANSI_FOR_SCOPE)
echo "$ac_t""no" 1>&6
fi
fi
# find make to use to build cmake, prefer gmake
AC_PATH_PROGS(RUNMAKE, gmake make)