STYLE: Fix some style issues

This commit is contained in:
Andy Cedilnik 2006-03-10 13:06:26 -05:00
parent f01afc89f5
commit 634343c3e8
41 changed files with 978 additions and 844 deletions

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -39,7 +39,7 @@ cmCPackGenerators::cmCPackGenerators()
cmCPackGenerators::~cmCPackGenerators() cmCPackGenerators::~cmCPackGenerators()
{ {
std::vector<cmCPackGenericGenerator*>::iterator it; std::vector<cmCPackGenericGenerator*>::iterator it;
for ( it = m_Generators.begin(); it != m_Generators.end(); ++ it ) for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it )
{ {
delete *it; delete *it;
} }
@ -53,8 +53,8 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name)
{ {
return 0; return 0;
} }
m_Generators.push_back(gen); this->Generators.push_back(gen);
gen->SetLogger(m_Logger); gen->SetLogger(this->Logger);
return gen; return gen;
} }
@ -67,8 +67,8 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal(
return 0; return 0;
} }
cmCPackGenerators::t_GeneratorCreatorsMap::iterator it cmCPackGenerators::t_GeneratorCreatorsMap::iterator it
= m_GeneratorCreators.find(name); = this->GeneratorCreators.find(name);
if ( it == m_GeneratorCreators.end() ) if ( it == this->GeneratorCreators.end() )
{ {
return 0; return 0;
} }
@ -81,9 +81,9 @@ void cmCPackGenerators::RegisterGenerator(const char* name,
{ {
if ( !name || !createGenerator ) if ( !name || !createGenerator )
{ {
cmCPack_Log(m_Logger, cmCPackLog::LOG_ERROR, "Cannot register generator" cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
<< std::endl); "Cannot register generator" << std::endl);
return; return;
} }
m_GeneratorCreators[name] = createGenerator; this->GeneratorCreators[name] = createGenerator;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -44,15 +44,15 @@ public:
void RegisterGenerator(const char* name, void RegisterGenerator(const char* name,
CreateGeneratorCall* createGenerator); CreateGeneratorCall* createGenerator);
void SetLogger(cmCPackLog* logger) { m_Logger = logger; } void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
private: private:
cmCPackGenericGenerator* NewGeneratorInternal(const char* name); cmCPackGenericGenerator* NewGeneratorInternal(const char* name);
std::vector<cmCPackGenericGenerator*> m_Generators; std::vector<cmCPackGenericGenerator*> Generators;
typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap; typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap;
t_GeneratorCreatorsMap m_GeneratorCreators; t_GeneratorCreatorsMap GeneratorCreators;
cmCPackLog* m_Logger; cmCPackLog* Logger;
}; };
#endif #endif

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -31,21 +31,21 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackGenericGenerator::cmCPackGenericGenerator() cmCPackGenericGenerator::cmCPackGenericGenerator()
{ {
m_GeneratorVerbose = false; this->GeneratorVerbose = false;
m_MakefileMap = 0; this->MakefileMap = 0;
m_Logger = 0; this->Logger = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackGenericGenerator::~cmCPackGenericGenerator() cmCPackGenericGenerator::~cmCPackGenericGenerator()
{ {
m_MakefileMap = 0; this->MakefileMap = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackGenericGenerator::PrepareNames() int cmCPackGenericGenerator::PrepareNames()
{ {
this->SetOption("CPACK_GENERATOR", m_Name.c_str()); this->SetOption("CPACK_GENERATOR", this->Name.c_str());
std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
tempDirectory += "/_CPack_Packages/"; tempDirectory += "/_CPack_Packages/";
tempDirectory += this->GetOption("CPACK_GENERATOR"); tempDirectory += this->GetOption("CPACK_GENERATOR");
@ -157,7 +157,7 @@ int cmCPackGenericGenerator::InstallProject()
std::string output; std::string output;
int retVal = 1; int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output, bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0); &retVal, 0, this->GeneratorVerbose, 0);
if ( !resB || retVal ) if ( !resB || retVal )
{ {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@ -272,12 +272,12 @@ void cmCPackGenericGenerator::SetOption(const char* op, const char* value)
} }
if ( !value ) if ( !value )
{ {
m_MakefileMap->RemoveDefinition(op); this->MakefileMap->RemoveDefinition(op);
return; return;
} }
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass() cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
<< "::SetOption(" << op << ", " << value << ")" << std::endl); << "::SetOption(" << op << ", " << value << ")" << std::endl);
m_MakefileMap->AddDefinition(op, value); this->MakefileMap->AddDefinition(op, value);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -346,15 +346,15 @@ int cmCPackGenericGenerator::ProcessGenerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf) int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf)
{ {
m_MakefileMap = mf; this->MakefileMap = mf;
m_Name = name; this->Name = name;
return 1; return 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* cmCPackGenericGenerator::GetOption(const char* op) const char* cmCPackGenericGenerator::GetOption(const char* op)
{ {
return m_MakefileMap->GetDefinition(op); return this->MakefileMap->GetDefinition(op);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -363,18 +363,18 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
int found = 0; int found = 0;
// Find our own executable. // Find our own executable.
std::vector<cmStdString> failures; std::vector<cmStdString> failures;
m_CPackSelf = arg0; this->CPackSelf = arg0;
cmSystemTools::ConvertToUnixSlashes(m_CPackSelf); cmSystemTools::ConvertToUnixSlashes(this->CPackSelf);
failures.push_back(m_CPackSelf); failures.push_back(this->CPackSelf);
m_CPackSelf = cmSystemTools::FindProgram(m_CPackSelf.c_str()); this->CPackSelf = cmSystemTools::FindProgram(this->CPackSelf.c_str());
if(!cmSystemTools::FileExists(m_CPackSelf.c_str())) if(!cmSystemTools::FileExists(this->CPackSelf.c_str()))
{ {
failures.push_back(m_CPackSelf); failures.push_back(this->CPackSelf);
m_CPackSelf = "/usr/local/bin/ctest"; this->CPackSelf = "/usr/local/bin/ctest";
} }
if(!cmSystemTools::FileExists(m_CPackSelf.c_str())) if(!cmSystemTools::FileExists(this->CPackSelf.c_str()))
{ {
failures.push_back(m_CPackSelf); failures.push_back(this->CPackSelf);
cmOStringStream msg; cmOStringStream msg;
msg << "CTEST can not find the command line program ctest.\n"; msg << "CTEST can not find the command line program ctest.\n";
msg << " argv[0] = \"" << arg0 << "\"\n"; msg << " argv[0] = \"" << arg0 << "\"\n";
@ -388,33 +388,33 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
} }
std::string dir; std::string dir;
std::string file; std::string file;
if(cmSystemTools::SplitProgramPath(m_CPackSelf.c_str(), if(cmSystemTools::SplitProgramPath(this->CPackSelf.c_str(),
dir, file, true)) dir, file, true))
{ {
m_CMakeSelf = dir += "/cmake"; this->CMakeSelf = dir += "/cmake";
m_CMakeSelf += cmSystemTools::GetExecutableExtension(); this->CMakeSelf += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(m_CMakeSelf.c_str())) if(cmSystemTools::FileExists(this->CMakeSelf.c_str()))
{ {
found = 1; found = 1;
} }
} }
if ( !found ) if ( !found )
{ {
failures.push_back(m_CMakeSelf); failures.push_back(this->CMakeSelf);
#ifdef CMAKE_BUILD_DIR #ifdef CMAKE_BUILD_DIR
std::string intdir = "."; std::string intdir = ".";
#ifdef CMAKE_INTDIR #ifdef CMAKE_INTDIR
intdir = CMAKE_INTDIR; intdir = CMAKE_INTDIR;
#endif #endif
m_CMakeSelf = CMAKE_BUILD_DIR; this->CMakeSelf = CMAKE_BUILD_DIR;
m_CMakeSelf += "/bin/"; this->CMakeSelf += "/bin/";
m_CMakeSelf += intdir; this->CMakeSelf += intdir;
m_CMakeSelf += "/cmake"; this->CMakeSelf += "/cmake";
m_CMakeSelf += cmSystemTools::GetExecutableExtension(); this->CMakeSelf += cmSystemTools::GetExecutableExtension();
#endif #endif
if(!cmSystemTools::FileExists(m_CMakeSelf.c_str())) if(!cmSystemTools::FileExists(this->CMakeSelf.c_str()))
{ {
failures.push_back(m_CMakeSelf); failures.push_back(this->CMakeSelf);
cmOStringStream msg; cmOStringStream msg;
msg << "CTEST can not find the command line program cmake.\n"; msg << "CTEST can not find the command line program cmake.\n";
msg << " argv[0] = \"" << arg0 << "\"\n"; msg << " argv[0] = \"" << arg0 << "\"\n";
@ -439,14 +439,14 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
if(modules.empty() || !cmSystemTools::FileExists(modules.c_str())) if(modules.empty() || !cmSystemTools::FileExists(modules.c_str()))
{ {
// next try exe/.. // next try exe/..
cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str());
std::string::size_type slashPos = cMakeRoot.rfind("/"); std::string::size_type slashPos = cMakeRoot.rfind("/");
if(slashPos != std::string::npos) if(slashPos != std::string::npos)
{ {
cMakeRoot = cMakeRoot.substr(0, slashPos); cMakeRoot = cMakeRoot.substr(0, slashPos);
} }
// is there no Modules direcory there? // is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl); << modules.c_str() << std::endl);
} }
@ -481,8 +481,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
#endif #endif
if (!cmSystemTools::FileExists(modules.c_str())) if (!cmSystemTools::FileExists(modules.c_str()))
{ {
// try // try
cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str());
cMakeRoot += CMAKE_DATA_DIR; cMakeRoot += CMAKE_DATA_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
@ -491,9 +491,9 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
if(!cmSystemTools::FileExists(modules.c_str())) if(!cmSystemTools::FileExists(modules.c_str()))
{ {
// next try exe // next try exe
cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str());
// is there no Modules direcory there? // is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl); << modules.c_str() << std::endl);
} }
@ -506,10 +506,10 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
cMakeRoot.c_str()); cMakeRoot.c_str());
return 0; return 0;
} }
m_CMakeRoot = cMakeRoot; this->CMakeRoot = cMakeRoot;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< m_CMakeRoot.c_str() << std::endl); << this->CMakeRoot.c_str() << std::endl);
this->SetOption("CMAKE_ROOT", m_CMakeRoot.c_str()); this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str());
return 1; return 1;
} }
@ -526,34 +526,34 @@ int cmCPackGenericGenerator::CompressFiles(const char* outFileName,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* cmCPackGenericGenerator::GetInstallPath() const char* cmCPackGenericGenerator::GetInstallPath()
{ {
if ( !m_InstallPath.empty() ) if ( !this->InstallPath.empty() )
{ {
return m_InstallPath.c_str(); return this->InstallPath.c_str();
} }
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles"); const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles");
const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive"); const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive");
if ( prgfiles ) if ( prgfiles )
{ {
m_InstallPath = prgfiles; this->InstallPath = prgfiles;
} }
else if ( sysDrive ) else if ( sysDrive )
{ {
m_InstallPath = sysDrive; this->InstallPath = sysDrive;
m_InstallPath += "/Program Files"; this->InstallPath += "/Program Files";
} }
else else
{ {
m_InstallPath = "c:/Program Files"; this->InstallPath = "c:/Program Files";
} }
m_InstallPath += "/"; this->InstallPath += "/";
m_InstallPath += this->GetOption("CPACK_PACKAGE_NAME"); this->InstallPath += this->GetOption("CPACK_PACKAGE_NAME");
m_InstallPath += "-"; this->InstallPath += "-";
m_InstallPath += this->GetOption("CPACK_PACKAGE_VERSION"); this->InstallPath += this->GetOption("CPACK_PACKAGE_VERSION");
#else #else
m_InstallPath = "/usr/local/"; this->InstallPath = "/usr/local/";
#endif #endif
return m_InstallPath.c_str(); return this->InstallPath.c_str();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -561,7 +561,7 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
{ {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
<< name << std::endl); << name << std::endl);
std::string ffile = m_MakefileMap->GetModulesFile(name); std::string ffile = this->MakefileMap->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
<< ffile.c_str() << std::endl); << ffile.c_str() << std::endl);
return ffile; return ffile;
@ -571,6 +571,6 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
bool cmCPackGenericGenerator::ConfigureFile(const char* inName, bool cmCPackGenericGenerator::ConfigureFile(const char* inName,
const char* outName) const char* outName)
{ {
return m_MakefileMap->ConfigureFile(inName, outName, return this->MakefileMap->ConfigureFile(inName, outName,
false, true, false) == 1; false, true, false) == 1;
} }

View File

@ -29,7 +29,7 @@
do { \ do { \
cmOStringStream cmCPackLog_msg; \ cmOStringStream cmCPackLog_msg; \
cmCPackLog_msg << msg; \ cmCPackLog_msg << msg; \
m_Logger->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\ this->Logger->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\
} while ( 0 ) } while ( 0 )
#ifdef cerr #ifdef cerr
@ -56,7 +56,7 @@ public:
/** /**
* If verbose then more informaiton is printed out * If verbose then more informaiton is printed out
*/ */
void SetVerbose(bool val) { m_GeneratorVerbose = val; } void SetVerbose(bool val) { this->GeneratorVerbose = val; }
/** /**
* Do the actual processing. Subclass has to override it. * Do the actual processing. Subclass has to override it.
@ -83,7 +83,7 @@ public:
int FindRunningCMake(const char* arg0); int FindRunningCMake(const char* arg0);
//! Set the logger //! Set the logger
void SetLogger(cmCPackLog* log) { m_Logger = log; } void SetLogger(cmCPackLog* log) { this->Logger = log; }
protected: protected:
int PrepareNames(); int PrepareNames();
@ -99,19 +99,19 @@ protected:
virtual std::string FindTemplate(const char* name); virtual std::string FindTemplate(const char* name);
virtual bool ConfigureFile(const char* inName, const char* outName); virtual bool ConfigureFile(const char* inName, const char* outName);
bool m_GeneratorVerbose; bool GeneratorVerbose;
std::string m_Name; std::string Name;
std::string m_InstallPath; std::string InstallPath;
std::string m_CPackSelf; std::string CPackSelf;
std::string m_CMakeSelf; std::string CMakeSelf;
std::string m_CMakeRoot; std::string CMakeRoot;
cmCPackLog* m_Logger; cmCPackLog* Logger;
private: private:
cmMakefile* m_MakefileMap; cmMakefile* MakefileMap;
}; };
#endif #endif

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -22,19 +22,19 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackLog::cmCPackLog() cmCPackLog::cmCPackLog()
{ {
m_Verbose = false; this->Verbose = false;
m_Debug = false; this->Debug = false;
m_Quiet = false; this->Quiet = false;
m_NewLine = true; this->NewLine = true;
m_LastTag = cmCPackLog::NOTAG; this->LastTag = cmCPackLog::NOTAG;
#undef cerr #undef cerr
#undef cout #undef cout
m_DefaultOutput = &std::cout; this->DefaultOutput = &std::cout;
m_DefaultError = &std::cerr; this->DefaultError = &std::cerr;
m_LogOutput = 0; this->LogOutput = 0;
m_LogOutputCleanup = false; this->LogOutputCleanup = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -46,12 +46,12 @@ cmCPackLog::~cmCPackLog()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCPackLog::SetLogOutputStream(std::ostream* os) void cmCPackLog::SetLogOutputStream(std::ostream* os)
{ {
if ( m_LogOutputCleanup && m_LogOutput ) if ( this->LogOutputCleanup && this->LogOutput )
{ {
delete m_LogOutput; delete this->LogOutput;
} }
m_LogOutputCleanup = false; this->LogOutputCleanup = false;
m_LogOutput = os; this->LogOutput = os;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -72,7 +72,7 @@ bool cmCPackLog::SetLogOutputFile(const char* fname)
{ {
return false; return false;
} }
m_LogOutputCleanup = true; this->LogOutputCleanup = true;
return true; return true;
} }
@ -84,7 +84,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
bool display = false; bool display = false;
// Display file and line number if debug // Display file and line number if debug
bool useFileAndLine = m_Debug; bool useFileAndLine = this->Debug;
bool output = false; bool output = false;
bool debug = false; bool debug = false;
@ -95,7 +95,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
// When writing in file, add list of tags whenever tag changes. // When writing in file, add list of tags whenever tag changes.
std::string tagString; std::string tagString;
bool needTagString = false; bool needTagString = false;
if ( m_LogOutput && m_LastTag != tag ) if ( this->LogOutput && this->LastTag != tag )
{ {
needTagString = true; needTagString = true;
} }
@ -130,7 +130,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
tagString = "ERROR"; tagString = "ERROR";
} }
} }
if ( tag & LOG_DEBUG && m_Debug ) if ( tag & LOG_DEBUG && this->Debug )
{ {
debug = true; debug = true;
display = true; display = true;
@ -141,7 +141,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
} }
useFileAndLine = true; useFileAndLine = true;
} }
if ( tag & LOG_VERBOSE && m_Verbose ) if ( tag & LOG_VERBOSE && this->Verbose )
{ {
verbose = true; verbose = true;
display = true; display = true;
@ -151,73 +151,74 @@ void cmCPackLog::Log(int tag, const char* file, int line,
tagString = "VERBOSE"; tagString = "VERBOSE";
} }
} }
if ( m_Quiet ) if ( this->Quiet )
{ {
display = false; display = false;
} }
if ( m_LogOutput ) if ( this->LogOutput )
{ {
if ( needTagString ) if ( needTagString )
{ {
*m_LogOutput << "[" << file << ":" << line << " " << tagString << "] "; *this->LogOutput << "[" << file << ":" << line << " "
<< tagString << "] ";
} }
m_LogOutput->write(msg, length); this->LogOutput->write(msg, length);
} }
m_LastTag = tag; this->LastTag = tag;
if ( !display ) if ( !display )
{ {
return; return;
} }
if ( m_NewLine ) if ( this->NewLine )
{ {
if ( error && !m_ErrorPrefix.empty() ) if ( error && !this->ErrorPrefix.empty() )
{ {
*m_DefaultError << m_ErrorPrefix.c_str(); *this->DefaultError << this->ErrorPrefix.c_str();
} }
else if ( warning && !m_WarningPrefix.empty() ) else if ( warning && !this->WarningPrefix.empty() )
{ {
*m_DefaultError << m_WarningPrefix.c_str(); *this->DefaultError << this->WarningPrefix.c_str();
} }
else if ( output && !m_OutputPrefix.empty() ) else if ( output && !this->OutputPrefix.empty() )
{ {
*m_DefaultOutput << m_OutputPrefix.c_str(); *this->DefaultOutput << this->OutputPrefix.c_str();
} }
else if ( verbose && !m_VerbosePrefix.empty() ) else if ( verbose && !this->VerbosePrefix.empty() )
{ {
*m_DefaultOutput << m_VerbosePrefix.c_str(); *this->DefaultOutput << this->VerbosePrefix.c_str();
} }
else if ( debug && !m_DebugPrefix.empty() ) else if ( debug && !this->DebugPrefix.empty() )
{ {
*m_DefaultOutput << m_DebugPrefix.c_str(); *this->DefaultOutput << this->DebugPrefix.c_str();
} }
else if ( !m_Prefix.empty() ) else if ( !this->Prefix.empty() )
{ {
*m_DefaultOutput << m_Prefix.c_str(); *this->DefaultOutput << this->Prefix.c_str();
} }
if ( useFileAndLine ) if ( useFileAndLine )
{ {
if ( error || warning ) if ( error || warning )
{ {
*m_DefaultError << file << ":" << line << " "; *this->DefaultError << file << ":" << line << " ";
} }
else else
{ {
*m_DefaultOutput << file << ":" << line << " "; *this->DefaultOutput << file << ":" << line << " ";
} }
} }
} }
if ( error || warning ) if ( error || warning )
{ {
m_DefaultError->write(msg, length); this->DefaultError->write(msg, length);
m_DefaultError->flush(); this->DefaultError->flush();
} }
else else
{ {
m_DefaultOutput->write(msg, length); this->DefaultOutput->write(msg, length);
m_DefaultOutput->flush(); this->DefaultOutput->flush();
} }
if ( msg[length-1] == '\n' || length > 2 ) if ( msg[length-1] == '\n' || length > 2 )
{ {
m_NewLine = true; this->NewLine = true;
} }
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -78,26 +78,26 @@ public:
//! Set Verbose //! Set Verbose
void VerboseOn() { this->SetVerbose(true); } void VerboseOn() { this->SetVerbose(true); }
void VerboseOff() { this->SetVerbose(true); } void VerboseOff() { this->SetVerbose(true); }
void SetVerbose(bool verb) { m_Verbose = verb; } void SetVerbose(bool verb) { this->Verbose = verb; }
bool GetVerbose() { return m_Verbose; } bool GetVerbose() { return this->Verbose; }
//! Set Debug //! Set Debug
void DebugOn() { this->SetDebug(true); } void DebugOn() { this->SetDebug(true); }
void DebugOff() { this->SetDebug(true); } void DebugOff() { this->SetDebug(true); }
void SetDebug(bool verb) { m_Debug = verb; } void SetDebug(bool verb) { this->Debug = verb; }
bool GetDebug() { return m_Debug; } bool GetDebug() { return this->Debug; }
//! Set Quiet //! Set Quiet
void QuietOn() { this->SetQuiet(true); } void QuietOn() { this->SetQuiet(true); }
void QuietOff() { this->SetQuiet(true); } void QuietOff() { this->SetQuiet(true); }
void SetQuiet(bool verb) { m_Quiet = verb; } void SetQuiet(bool verb) { this->Quiet = verb; }
bool GetQuiet() { return m_Quiet; } bool GetQuiet() { return this->Quiet; }
//! Set the output stream //! Set the output stream
void SetOutputStream(std::ostream* os) { m_DefaultOutput = os; } void SetOutputStream(std::ostream* os) { this->DefaultOutput = os; }
//! Set the error stream //! Set the error stream
void SetErrorStream(std::ostream* os) { m_DefaultError = os; } void SetErrorStream(std::ostream* os) { this->DefaultError = os; }
//! Set the log output stream //! Set the log output stream
void SetLogOutputStream(std::ostream* os); void SetLogOutputStream(std::ostream* os);
@ -108,36 +108,36 @@ public:
//! Set the various prefixes for the logging. SetPrefix sets the generic //! Set the various prefixes for the logging. SetPrefix sets the generic
// prefix that overwrittes missing ones. // prefix that overwrittes missing ones.
void SetPrefix(std::string pfx) { m_Prefix = pfx; } void SetPrefix(std::string pfx) { this->Prefix = pfx; }
void SetOutputPrefix(std::string pfx) { m_OutputPrefix = pfx; } void SetOutputPrefix(std::string pfx) { this->OutputPrefix = pfx; }
void SetVerbosePrefix(std::string pfx) { m_VerbosePrefix = pfx; } void SetVerbosePrefix(std::string pfx) { this->VerbosePrefix = pfx; }
void SetDebugPrefix(std::string pfx) { m_DebugPrefix = pfx; } void SetDebugPrefix(std::string pfx) { this->DebugPrefix = pfx; }
void SetWarningPrefix(std::string pfx) { m_WarningPrefix = pfx; } void SetWarningPrefix(std::string pfx) { this->WarningPrefix = pfx; }
void SetErrorPrefix(std::string pfx) { m_ErrorPrefix = pfx; } void SetErrorPrefix(std::string pfx) { this->ErrorPrefix = pfx; }
private: private:
bool m_Verbose; bool Verbose;
bool m_Debug; bool Debug;
bool m_Quiet; bool Quiet;
bool m_NewLine; bool NewLine;
int m_LastTag; int LastTag;
std::string m_Prefix; std::string Prefix;
std::string m_OutputPrefix; std::string OutputPrefix;
std::string m_VerbosePrefix; std::string VerbosePrefix;
std::string m_DebugPrefix; std::string DebugPrefix;
std::string m_WarningPrefix; std::string WarningPrefix;
std::string m_ErrorPrefix; std::string ErrorPrefix;
std::ostream *m_DefaultOutput; std::ostream *DefaultOutput;
std::ostream *m_DefaultError; std::ostream *DefaultError;
std::string m_LogOutputFileName; std::string LogOutputFileName;
std::ostream *m_LogOutput; std::ostream *LogOutput;
// Do we need to cleanup log output stream // Do we need to cleanup log output stream
bool m_LogOutputCleanup; bool LogOutputCleanup;
}; };
class cmCPackLogWrite class cmCPackLogWrite

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -99,7 +99,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
std::string output; std::string output;
int retVal = 1; int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0); &retVal, 0, this->GeneratorVerbose, 0);
if ( !res || retVal ) if ( !res || retVal )
{ {
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
@ -147,7 +147,7 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
std::string output; std::string output;
int retVal = 1; int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
&output, &retVal, 0, m_GeneratorVerbose, 0); &output, &retVal, 0, this->GeneratorVerbose, 0);
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
if ( !resS || retVal || !versionRex.find(output)) if ( !resS || retVal || !versionRex.find(output))

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/

View File

@ -95,7 +95,7 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
std::string output; std::string output;
int retVal = 1; int retVal = 1;
//bool res = cmSystemTools::RunSingleCommand(pkgCmd.str().c_str(), &output, //bool res = cmSystemTools::RunSingleCommand(pkgCmd.str().c_str(), &output,
//&retVal, 0, m_GeneratorVerbose, 0); //&retVal, 0, this->GeneratorVerbose, 0);
bool res = true; bool res = true;
retVal = system(pkgCmd.str().c_str()); retVal = system(pkgCmd.str().c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
@ -120,7 +120,7 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
<< "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
<< "\" \"" << outFileName << "\""; << "\" \"" << outFileName << "\"";
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0); &retVal, 0, this->GeneratorVerbose, 0);
if ( !res || retVal ) if ( !res || retVal )
{ {
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -60,13 +60,13 @@ class cmCPackTGZ_Data
public: public:
cmCPackTGZ_Data(cmCPackTGZGenerator* gen) : cmCPackTGZ_Data(cmCPackTGZGenerator* gen) :
OutputStream(0), Generator(gen), OutputStream(0), Generator(gen),
m_CompressionLevel(Z_DEFAULT_COMPRESSION) {} CompressionLevel(Z_DEFAULT_COMPRESSION) {}
std::ostream* OutputStream; std::ostream* OutputStream;
cmCPackTGZGenerator* Generator; cmCPackTGZGenerator* Generator;
char m_CompressedBuffer[cmCPackTGZ_Data_BlockSize]; char CompressedBuffer[cmCPackTGZ_Data_BlockSize];
int m_CompressionLevel; int CompressionLevel;
z_stream m_ZLibStream; z_stream ZLibStream;
uLong m_CRC; uLong CRC;
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -84,11 +84,11 @@ int cmCPackTGZ_Data_Open(void *client_data, const char* pathname,
{ {
cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data; cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data;
mydata->m_ZLibStream.zalloc = Z_NULL; mydata->ZLibStream.zalloc = Z_NULL;
mydata->m_ZLibStream.zfree = Z_NULL; mydata->ZLibStream.zfree = Z_NULL;
mydata->m_ZLibStream.opaque = Z_NULL; mydata->ZLibStream.opaque = Z_NULL;
int strategy = Z_DEFAULT_STRATEGY; int strategy = Z_DEFAULT_STRATEGY;
if ( deflateInit2(&mydata->m_ZLibStream, mydata->m_CompressionLevel, if ( deflateInit2(&mydata->ZLibStream, mydata->CompressionLevel,
Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy) != Z_OK ) Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy) != Z_OK )
{ {
return -1; return -1;
@ -102,13 +102,13 @@ int cmCPackTGZ_Data_Open(void *client_data, const char* pathname,
{ {
return -1; return -1;
} }
if ( !cmCPackTGZGeneratorForward::GenerateHeader(mydata->Generator,gf)) if ( !cmCPackTGZGeneratorForward::GenerateHeader(mydata->Generator,gf))
{ {
return -1; return -1;
} }
mydata->m_CRC = crc32(0L, Z_NULL, 0); mydata->CRC = crc32(0L, Z_NULL, 0);
return 0; return 0;
} }
@ -118,27 +118,27 @@ ssize_t cmCPackTGZ_Data_Write(void *client_data, void *buff, size_t n)
{ {
cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data; cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data;
mydata->m_ZLibStream.avail_in = n; mydata->ZLibStream.avail_in = n;
mydata->m_ZLibStream.next_in = reinterpret_cast<Bytef*>(buff); mydata->ZLibStream.next_in = reinterpret_cast<Bytef*>(buff);
do { do {
mydata->m_ZLibStream.avail_out = cmCPackTGZ_Data_BlockSize; mydata->ZLibStream.avail_out = cmCPackTGZ_Data_BlockSize;
mydata->m_ZLibStream.next_out mydata->ZLibStream.next_out
= reinterpret_cast<Bytef*>(mydata->m_CompressedBuffer); = reinterpret_cast<Bytef*>(mydata->CompressedBuffer);
// no bad return value // no bad return value
int ret = deflate(&mydata->m_ZLibStream, (n?Z_NO_FLUSH:Z_FINISH)); int ret = deflate(&mydata->ZLibStream, (n?Z_NO_FLUSH:Z_FINISH));
if(ret == Z_STREAM_ERROR) if(ret == Z_STREAM_ERROR)
{ {
return 0; return 0;
} }
size_t compressedSize size_t compressedSize
= cmCPackTGZ_Data_BlockSize - mydata->m_ZLibStream.avail_out; = cmCPackTGZ_Data_BlockSize - mydata->ZLibStream.avail_out;
mydata->OutputStream->write( mydata->OutputStream->write(
reinterpret_cast<const char*>(mydata->m_CompressedBuffer), reinterpret_cast<const char*>(mydata->CompressedBuffer),
compressedSize); compressedSize);
} while ( mydata->m_ZLibStream.avail_out == 0 ); } while ( mydata->ZLibStream.avail_out == 0 );
if ( !*mydata->OutputStream ) if ( !*mydata->OutputStream )
{ {
@ -146,7 +146,7 @@ ssize_t cmCPackTGZ_Data_Write(void *client_data, void *buff, size_t n)
} }
if ( n ) if ( n )
{ {
mydata->m_CRC = crc32(mydata->m_CRC, reinterpret_cast<Bytef *>(buff), n); mydata->CRC = crc32(mydata->CRC, reinterpret_cast<Bytef *>(buff), n);
} }
return n; return n;
} }
@ -160,19 +160,19 @@ int cmCPackTGZ_Data_Close(void *client_data)
char buffer[8]; char buffer[8];
int n; int n;
uLong x = mydata->m_CRC; uLong x = mydata->CRC;
for (n = 0; n < 4; n++) { for (n = 0; n < 4; n++) {
buffer[n] = (int)(x & 0xff); buffer[n] = (int)(x & 0xff);
x >>= 8; x >>= 8;
} }
x = mydata->m_ZLibStream.total_in; x = mydata->ZLibStream.total_in;
for (n = 0; n < 4; n++) { for (n = 0; n < 4; n++) {
buffer[n+4] = (int)(x & 0xff); buffer[n+4] = (int)(x & 0xff);
x >>= 8; x >>= 8;
} }
mydata->OutputStream->write(buffer, 8); mydata->OutputStream->write(buffer, 8);
(void)deflateEnd(&mydata->m_ZLibStream); (void)deflateEnd(&mydata->ZLibStream);
delete mydata->OutputStream; delete mydata->OutputStream;
mydata->OutputStream = 0; mydata->OutputStream = 0;
return (0); return (0);
@ -204,7 +204,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName,
if (tar_open(&t, realName, if (tar_open(&t, realName,
&gztype, &gztype,
flags, 0644, flags, 0644,
(m_GeneratorVerbose?TAR_VERBOSE:0) (this->GeneratorVerbose?TAR_VERBOSE:0)
| 0) == -1) | 0) == -1)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): "

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -105,12 +105,12 @@ int cpackUnknownArgument(const char*, void*)
struct cpackDefinitions struct cpackDefinitions
{ {
typedef std::map<cmStdString, cmStdString> MapType; typedef std::map<cmStdString, cmStdString> MapType;
MapType m_Map; MapType Map;
cmCPackLog *m_Log; cmCPackLog *Log;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int cpackDefinitionArgument(const char* argument, const char* cValue, int cpackDefinitionArgument(const char* argument, const char* cValue,
void* call_data) void* call_data)
{ {
(void)argument; (void)argument;
@ -119,14 +119,14 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
size_t pos = value.find_first_of("="); size_t pos = value.find_first_of("=");
if ( pos == std::string::npos ) if ( pos == std::string::npos )
{ {
cmCPack_Log(def->m_Log, cmCPackLog::LOG_ERROR, cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
"Please specify CPack definitions as: KEY=VALUE" << std::endl); "Please specify CPack definitions as: KEY=VALUE" << std::endl);
return 0; return 0;
} }
std::string key = value.substr(0, pos); std::string key = value.substr(0, pos);
value = value.c_str() + pos + 1; value = value.c_str() + pos + 1;
def->m_Map[key] = value; def->Map[key] = value;
cmCPack_Log(def->m_Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
<< key.c_str() << " to \"" << value.c_str() << "\"" << std::endl); << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
return 1; return 1;
} }
@ -168,7 +168,7 @@ int main (int argc, char *argv[])
std::string cpackConfigFile; std::string cpackConfigFile;
cpackDefinitions definitions; cpackDefinitions definitions;
definitions.m_Log = &log; definitions.Log = &log;
cpackConfigFile = ""; cpackConfigFile = "";
@ -296,8 +296,8 @@ int main (int argc, char *argv[])
mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
} }
cpackDefinitions::MapType::iterator cdit; cpackDefinitions::MapType::iterator cdit;
for ( cdit = definitions.m_Map.begin(); for ( cdit = definitions.Map.begin();
cdit != definitions.m_Map.end(); cdit != definitions.Map.end();
++cdit ) ++cdit )
{ {
mf->AddDefinition(cdit->first.c_str(), cdit->second.c_str()); mf->AddDefinition(cdit->first.c_str(), cdit->second.c_str());

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -19,7 +19,8 @@
#include "cmTarget.h" #include "cmTarget.h"
// cmAddCustomCommandCommand // cmAddCustomCommandCommand
bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args) bool cmAddCustomCommandCommand::InitialPass(
std::vector<std::string> const& args)
{ {
/* Let's complain at the end of this function about the lack of a particular /* Let's complain at the end of this function about the lack of a particular
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
@ -42,7 +43,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
cmCustomCommandLines commandLines; cmCustomCommandLines commandLines;
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD; cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
enum tdoing { enum tdoing {
doing_source, doing_source,
doing_command, doing_command,
@ -198,7 +199,8 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
if(source.empty() && !target.empty() && !output.empty()) if(source.empty() && !target.empty() && !output.empty())
{ {
this->SetError("Wrong syntax. A TARGET and OUTPUT can not both be specified."); this->SetError(
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
return false; return false;
} }

View File

@ -9,15 +9,16 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#include "cmAddCustomTargetCommand.h" #include "cmAddCustomTargetCommand.h"
// cmAddCustomTargetCommand // cmAddCustomTargetCommand
bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args) bool cmAddCustomTargetCommand::InitialPass(
std::vector<std::string> const& args)
{ {
if(args.size() < 1 ) if(args.size() < 1 )
{ {
@ -118,7 +119,7 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
// Add the utility target to the makefile. // Add the utility target to the makefile.
const char* no_output = 0; const char* no_output = 0;
m_Makefile->AddUtilityCommand(args[0].c_str(), all, no_output, m_Makefile->AddUtilityCommand(args[0].c_str(), all, no_output,
working_directory.c_str(), depends, working_directory.c_str(), depends,
commandLines); commandLines);

View File

@ -9,15 +9,16 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#include "cmAddDefinitionsCommand.h" #include "cmAddDefinitionsCommand.h"
// cmAddDefinitionsCommand // cmAddDefinitionsCommand
bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args) bool cmAddDefinitionsCommand::InitialPass(
std::vector<std::string> const& args)
{ {
// it is OK to have no arguments // it is OK to have no arguments
if(args.size() < 1 ) if(args.size() < 1 )

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -22,8 +22,8 @@
/** \class cmAddDefinitionsCommand /** \class cmAddDefinitionsCommand
* \brief Specify a list of compiler defines * \brief Specify a list of compiler defines
* *
* cmAddDefinitionsCommand specifies a list of compiler defines. These defines will * cmAddDefinitionsCommand specifies a list of compiler defines. These defines
* be added to the compile command. * will be added to the compile command.
*/ */
class cmAddDefinitionsCommand : public cmCommand class cmAddDefinitionsCommand : public cmCommand
{ {
@ -31,7 +31,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
return new cmAddDefinitionsCommand; return new cmAddDefinitionsCommand;
} }
@ -46,15 +46,15 @@ public:
* The name of the command as specified in CMakeList.txt. * The name of the command as specified in CMakeList.txt.
*/ */
virtual const char* GetName() {return "ADD_DEFINITIONS";} virtual const char* GetName() {return "ADD_DEFINITIONS";}
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Adds -D define flags to the command line of C and C++ compilers."; return "Adds -D define flags to the command line of C and C++ compilers.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -67,7 +67,7 @@ public:
"but the -D flag is accepted most C/C++ compilers. " "but the -D flag is accepted most C/C++ compilers. "
"Other flags may not be as portable."; "Other flags may not be as portable.";
} }
cmTypeMacro(cmAddDefinitionsCommand, cmCommand); cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
}; };

View File

@ -9,15 +9,16 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#include "cmAddDependenciesCommand.h" #include "cmAddDependenciesCommand.h"
// cmDependenciesCommand // cmDependenciesCommand
bool cmAddDependenciesCommand::InitialPass(std::vector<std::string> const& args) bool cmAddDependenciesCommand::InitialPass(
std::vector<std::string> const& args)
{ {
if(args.size() < 2 ) if(args.size() < 2 )
{ {
@ -44,7 +45,7 @@ bool cmAddDependenciesCommand::InitialPass(std::vector<std::string> const& args)
this->SetError(error.c_str()); this->SetError(error.c_str());
return false; return false;
} }
return true; return true;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -31,7 +31,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
return new cmAddExecutableCommand; return new cmAddExecutableCommand;
} }
@ -50,11 +50,12 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Add an executable to the project using the specified source files."; return
"Add an executable to the project using the specified source files.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -68,15 +69,15 @@ public:
"specified.\n" "specified.\n"
"After specifying the executable name, WIN32 and/or MACOSX_BUNDLE can " "After specifying the executable name, WIN32 and/or MACOSX_BUNDLE can "
"be specified. WIN32 indicates that the executable (when compiled on " "be specified. WIN32 indicates that the executable (when compiled on "
"windows) is a windows app (using WinMain) not a console app (using main). " "windows) is a windows app (using WinMain) not a console app "
"The variable CMAKE_MFC_FLAG be used if the windows app uses MFC. " "(using main). The variable CMAKE_MFC_FLAG be used if the windows app "
"This variable can be set to the following values:\n" "uses MFC. This variable can be set to the following values:\n"
" 0: Use Standard Windows Libraries\n" " 0: Use Standard Windows Libraries\n"
" 1: Use MFC in a Static Library \n" " 1: Use MFC in a Static Library \n"
" 2: Use MFC in a Shared DLL \n" " 2: Use MFC in a Shared DLL \n"
"MACOSX_BUNDLE indicates that when build on Mac OSX, executable should " "MACOSX_BUNDLE indicates that when build on Mac OSX, executable should "
"be in the bundle form. The MACOSX_BUNDLE also allows several variables " "be in the bundle form. The MACOSX_BUNDLE also allows several "
"to be specified:\n" "variables to be specified:\n"
" MACOSX_BUNDLE_INFO_STRING\n" " MACOSX_BUNDLE_INFO_STRING\n"
" MACOSX_BUNDLE_ICON_FILE\n" " MACOSX_BUNDLE_ICON_FILE\n"
" MACOSX_BUNDLE_GUI_IDENTIFIER\n" " MACOSX_BUNDLE_GUI_IDENTIFIER\n"
@ -87,7 +88,7 @@ public:
" MACOSX_BUNDLE_COPYRIGHT\n" " MACOSX_BUNDLE_COPYRIGHT\n"
; ;
} }
cmTypeMacro(cmAddExecutableCommand, cmCommand); cmTypeMacro(cmAddExecutableCommand, cmCommand);
}; };

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -32,8 +32,9 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
= m_Makefile->GetDefinition(define); = m_Makefile->GetDefinition(define);
std::string makeprogram = args[1]; std::string makeprogram = args[1];
std::string makecommand std::string makecommand
= m_Makefile->GetLocalGenerator()->GetGlobalGenerator()->GenerateBuildCommand( = m_Makefile->GetLocalGenerator()
makeprogram.c_str(), m_Makefile->GetProjectName(), 0, ->GetGlobalGenerator()->GenerateBuildCommand(
makeprogram.c_str(), m_Makefile->GetProjectName(), 0,
0, "Release", true); 0, "Release", true);
if(cacheValue) if(cacheValue)

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -22,7 +22,7 @@
/** \class cmBuildNameCommand /** \class cmBuildNameCommand
* \brief BuildName a CMAKE variable * \brief BuildName a CMAKE variable
* *
* cmBuildNameCommand sets a variable to a value with expansion. * cmBuildNameCommand sets a variable to a value with expansion.
*/ */
class cmBuildNameCommand : public cmCommand class cmBuildNameCommand : public cmCommand
{ {
@ -30,7 +30,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
return new cmBuildNameCommand; return new cmBuildNameCommand;
} }
@ -50,15 +50,16 @@ public:
* The name of the command as specified in CMakeList.txt. * The name of the command as specified in CMakeList.txt.
*/ */
virtual const char* GetName() {return "BUILD_NAME";} virtual const char* GetName() {return "BUILD_NAME";}
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead."; return
"Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -70,7 +71,7 @@ public:
"and compiler settings. These values are now available through the " "and compiler settings. These values are now available through the "
"CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables."; "CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables.";
} }
cmTypeMacro(cmBuildNameCommand, cmCommand); cmTypeMacro(cmBuildNameCommand, cmCommand);
}; };

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -67,7 +67,8 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args)
} }
// Save the required version string. // Save the required version string.
m_Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION", version_string.c_str()); m_Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
version_string.c_str());
// Get the current version number. // Get the current version number.
int current_major = m_Makefile->GetMajorVersion(); int current_major = m_Makefile->GetMajorVersion();
@ -102,9 +103,11 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args)
{ {
e << "WARNING: "; e << "WARNING: ";
} }
e << "This project requires version " << version_string.c_str() << " of CMake. " e << "This project requires version " << version_string.c_str()
<< " of CMake. "
<< "You are running version " << "You are running version "
<< current_major << "." << current_minor << "." << current_patch << ".\n"; << current_major << "." << current_minor << "." << current_patch
<< ".\n";
if(fatal_error) if(fatal_error)
{ {
cmSystemTools::Error(e.str().c_str()); cmSystemTools::Error(e.str().c_str());

View File

@ -9,12 +9,12 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
/* /*
this file contains the implementation of the C API to CMake. Generally this file contains the implementation of the C API to CMake. Generally
these routines just manipulate arguments and then call the associated these routines just manipulate arguments and then call the associated
methods on the CMake classes. */ methods on the CMake classes. */
@ -24,9 +24,9 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
extern "C" extern "C"
{ {
void CCONV *cmGetClientData(void *info) void CCONV *cmGetClientData(void *info)
{ {
return ((cmLoadedCommandInfo *)info)->ClientData; return ((cmLoadedCommandInfo *)info)->ClientData;
@ -74,12 +74,11 @@ void CCONV cmAddDefinition(void *arg, const char* name, const char* value)
} }
/* Add a definition to this makefile and the global cmake cache. */ /* Add a definition to this makefile and the global cmake cache. */
void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* value, void CCONV cmAddCacheDefinition(void *arg, const char* name,
const char* doc, const char* value, const char* doc, int type)
int type)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
switch (type) switch (type)
{ {
case CM_CACHE_BOOL: case CM_CACHE_BOOL:
@ -135,7 +134,7 @@ const char* CCONV cmGetStartOutputDirectory(void *arg)
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
return mf->GetStartOutputDirectory(); return mf->GetStartOutputDirectory();
} }
const char* CCONV cmGetCurrentDirectory(void *arg) const char* CCONV cmGetCurrentDirectory(void *arg)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
return mf->GetCurrentDirectory(); return mf->GetCurrentDirectory();
@ -170,14 +169,15 @@ void CCONV cmAddDefineFlag(void *arg, const char* definition)
mf->AddDefineFlag(definition); mf->AddDefineFlag(definition);
} }
void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt, const char* d) void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt,
const char* d)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
mf->AddLinkDirectoryForTarget(tgt,d); mf->AddLinkDirectoryForTarget(tgt,d);
} }
void CCONV cmAddExecutable(void *arg, const char *exename, void CCONV cmAddExecutable(void *arg, const char *exename,
int numSrcs, const char **srcs, int win32) int numSrcs, const char **srcs, int win32)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
@ -368,11 +368,11 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
cctype, no_comment, no_working_dir); cctype, no_comment, no_working_dir);
} }
void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt, const char*value, void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt,
int libtype) const char*value, int libtype)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
switch (libtype) switch (libtype)
{ {
case CM_LIBRARY_GENERAL: case CM_LIBRARY_GENERAL:
@ -400,13 +400,13 @@ void CCONV cmAddLibrary(void *arg, const char *libname, int shared,
mf->AddLibrary(libname, (shared ? true : false), srcs2); mf->AddLibrary(libname, (shared ? true : false), srcs2);
} }
char CCONV *cmExpandVariablesInString(void *arg, const char *source, char CCONV *cmExpandVariablesInString(void *arg, const char *source,
int escapeQuotes, int atOnly) int escapeQuotes, int atOnly)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
std::string barf = source; std::string barf = source;
std::string result = std::string result =
mf->ExpandVariablesInString(barf, mf->ExpandVariablesInString(barf,
(escapeQuotes ? true : false), (escapeQuotes ? true : false),
(atOnly ? true : false)); (atOnly ? true : false));
char *res = static_cast<char *>(malloc(result.size() + 1)); char *res = static_cast<char *>(malloc(result.size() + 1));
@ -419,7 +419,7 @@ char CCONV *cmExpandVariablesInString(void *arg, const char *source,
} }
int CCONV cmExecuteCommand(void *arg, const char *name, int CCONV cmExecuteCommand(void *arg, const char *name,
int numArgs, const char **args) int numArgs, const char **args)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
@ -434,7 +434,7 @@ int CCONV cmExecuteCommand(void *arg, const char *name,
return mf->ExecuteCommand(lff); return mf->ExecuteCommand(lff);
} }
void CCONV cmExpandSourceListArguments(void *arg, void CCONV cmExpandSourceListArguments(void *arg,
int numArgs, int numArgs,
const char **args, const char **args,
int *resArgc, int *resArgc,
@ -540,7 +540,8 @@ int CCONV cmSourceFileGetPropertyAsBool(void *arg,const char *prop)
return (sf->GetPropertyAsBool(prop) ? 1: 0); return (sf->GetPropertyAsBool(prop) ? 1: 0);
} }
void CCONV cmSourceFileSetProperty(void *arg,const char *prop, const char *val) void CCONV cmSourceFileSetProperty(void *arg,const char *prop,
const char *val)
{ {
cmSourceFile *sf = static_cast<cmSourceFile *>(arg); cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
sf->SetProperty(prop,val); sf->SetProperty(prop,val);
@ -573,7 +574,7 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
sf->SetName(name,dir, srcs, hdrs); sf->SetName(name,dir, srcs, hdrs);
} }
void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir, void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
const char *ext, int headerFileOnly) const char *ext, int headerFileOnly)
{ {
cmSourceFile *sf = static_cast<cmSourceFile *>(arg); cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
@ -584,7 +585,7 @@ void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
char * CCONV cmGetFilenameWithoutExtension(const char *name) char * CCONV cmGetFilenameWithoutExtension(const char *name)
{ {
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name); std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
char *result = (char *)malloc(sres.size()+1); char *result = (char *)malloc(sres.size()+1);
strcpy(result,sres.c_str()); strcpy(result,sres.c_str());
return result; return result;
} }
@ -592,7 +593,7 @@ char * CCONV cmGetFilenameWithoutExtension(const char *name)
char * CCONV cmGetFilenamePath(const char *name) char * CCONV cmGetFilenamePath(const char *name)
{ {
std::string sres = cmSystemTools::GetFilenamePath(name); std::string sres = cmSystemTools::GetFilenamePath(name);
char *result = (char *)malloc(sres.size()+1); char *result = (char *)malloc(sres.size()+1);
strcpy(result,sres.c_str()); strcpy(result,sres.c_str());
return result; return result;
} }
@ -600,7 +601,7 @@ char * CCONV cmGetFilenamePath(const char *name)
char * CCONV cmCapitalized(const char *name) char * CCONV cmCapitalized(const char *name)
{ {
std::string sres = cmSystemTools::Capitalized(name); std::string sres = cmSystemTools::Capitalized(name);
char *result = (char *)malloc(sres.size()+1); char *result = (char *)malloc(sres.size()+1);
strcpy(result,sres.c_str()); strcpy(result,sres.c_str());
return result; return result;
} }
@ -661,7 +662,7 @@ cmCAPI cmStaticCAPI =
cmGetStartDirectory, cmGetStartDirectory,
cmGetStartOutputDirectory, cmGetStartOutputDirectory,
cmIsOn, cmIsOn,
cmAddSource, cmAddSource,
cmCreateSourceFile, cmCreateSourceFile,
cmDestroySourceFile, cmDestroySourceFile,
@ -674,7 +675,7 @@ cmCAPI cmStaticCAPI =
cmSourceFileSetName, cmSourceFileSetName,
cmSourceFileSetName2, cmSourceFileSetName2,
cmSourceFileSetProperty, cmSourceFileSetProperty,
cmCapitalized, cmCapitalized,
cmCopyFileIfDifferent, cmCopyFileIfDifferent,
cmGetFilenameWithoutExtension, cmGetFilenameWithoutExtension,

View File

@ -9,18 +9,18 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
/* This header file defines the API that loadable commands can use. In many /* This header file defines the API that loadable commands can use. In many
of these commands C++ instances of cmMakefile of cmSourceFile are passed of these commands C++ instances of cmMakefile of cmSourceFile are passed
in as arguments or returned. In these cases they are passed as a void * in as arguments or returned. In these cases they are passed as a void *
argument. In the function prototypes mf is used to represent a makefile argument. In the function prototypes mf is used to represent a makefile
and sf is used to represent a source file. The functions are grouped and sf is used to represent a source file. The functions are grouped
loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4) loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4)
cmSystemTools. Within each grouping functions are listed alphabetically */ cmSystemTools. Within each grouping functions are listed alphabetically */
/*=========================================================================*/ /*=========================================================================*/
#ifndef cmCPluginAPI_h #ifndef cmCPluginAPI_h
#define cmCPluginAPI_h #define cmCPluginAPI_h
@ -42,7 +42,7 @@ this is the structure of function entry points that a plugin may call. This
structure must be kept in sync with the static decaled at the bottom of structure must be kept in sync with the static decaled at the bottom of
cmCPLuginAPI.cxx cmCPLuginAPI.cxx
=========================================================================*/ =========================================================================*/
typedef struct typedef struct
{ {
/*========================================================================= /*=========================================================================
Here we define the set of functions that a plugin may call. The first goup Here we define the set of functions that a plugin may call. The first goup
@ -62,14 +62,14 @@ typedef struct
void (CCONV *SetClientData) (void *info, void *cd); void (CCONV *SetClientData) (void *info, void *cd);
/* when an error occurs, call this function to set the error string */ /* when an error occurs, call this function to set the error string */
void (CCONV *SetError) (void *info, const char *err); void (CCONV *SetError) (void *info, const char *err);
/*========================================================================= /*=========================================================================
The following functions all directly map to methods in the cmMakefile The following functions all directly map to methods in the cmMakefile
class. See cmMakefile.h for descriptions of what each method does. All of class. See cmMakefile.h for descriptions of what each method does. All of
these methods take the void * makefile pointer as their first argument. these methods take the void * makefile pointer as their first argument.
=========================================================================*/ =========================================================================*/
void (CCONV *AddCacheDefinition) (void *mf, const char* name, void (CCONV *AddCacheDefinition) (void *mf, const char* name,
const char* value, const char* value,
const char* doc, int cachetype); const char* doc, int cachetype);
void (CCONV *AddCustomCommand) (void *mf, const char* source, void (CCONV *AddCustomCommand) (void *mf, const char* source,
const char* command, const char* command,
@ -78,26 +78,28 @@ typedef struct
int numOutputs, const char **outputs, int numOutputs, const char **outputs,
const char *target); const char *target);
void (CCONV *AddDefineFlag) (void *mf, const char* definition); void (CCONV *AddDefineFlag) (void *mf, const char* definition);
void (CCONV *AddDefinition) (void *mf, const char* name, const char* value); void (CCONV *AddDefinition) (void *mf, const char* name,
void (CCONV *AddExecutable) (void *mf, const char *exename, const char* value);
void (CCONV *AddExecutable) (void *mf, const char *exename,
int numSrcs, const char **srcs, int win32); int numSrcs, const char **srcs, int win32);
void (CCONV *AddLibrary) (void *mf, const char *libname, void (CCONV *AddLibrary) (void *mf, const char *libname,
int shared, int numSrcs, const char **srcs); int shared, int numSrcs, const char **srcs);
void (CCONV *AddLinkDirectoryForTarget) (void *mf, const char *tgt, void (CCONV *AddLinkDirectoryForTarget) (void *mf, const char *tgt,
const char* d); const char* d);
void (CCONV *AddLinkLibraryForTarget) (void *mf, const char *tgt, void (CCONV *AddLinkLibraryForTarget) (void *mf, const char *tgt,
const char *libname, int libtype); const char *libname, int libtype);
void (CCONV *AddUtilityCommand) (void *mf, const char* utilityName, void (CCONV *AddUtilityCommand) (void *mf, const char* utilityName,
const char *command, const char *arguments, const char *command, const char *arguments,
int all, int numDepends, const char **depends, int all, int numDepends, const char **depends,
int numOutputs, const char **outputs); int numOutputs, const char **outputs);
int (CCONV *CommandExists) (void *mf, const char* name); int (CCONV *CommandExists) (void *mf, const char* name);
int (CCONV *ExecuteCommand) (void *mf, const char *name, int (CCONV *ExecuteCommand) (void *mf, const char *name,
int numArgs, const char **args); int numArgs, const char **args);
void (CCONV *ExpandSourceListArguments) (void *mf,int argc, const char **argv, void (CCONV *ExpandSourceListArguments) (void *mf,int argc,
const char **argv,
int *resArgc, char ***resArgv, int *resArgc, char ***resArgv,
unsigned int startArgumentIndex); unsigned int startArgumentIndex);
char *(CCONV *ExpandVariablesInString) (void *mf, const char *source, char *(CCONV *ExpandVariablesInString) (void *mf, const char *source,
int escapeQuotes, int atOnly); int escapeQuotes, int atOnly);
unsigned int (CCONV *GetCacheMajorVersion) (void *mf); unsigned int (CCONV *GetCacheMajorVersion) (void *mf);
unsigned int (CCONV *GetCacheMinorVersion) (void *mf); unsigned int (CCONV *GetCacheMinorVersion) (void *mf);
@ -112,14 +114,14 @@ typedef struct
const char* (CCONV *GetStartDirectory) (void *mf); const char* (CCONV *GetStartDirectory) (void *mf);
const char* (CCONV *GetStartOutputDirectory) (void *mf); const char* (CCONV *GetStartOutputDirectory) (void *mf);
int (CCONV *IsOn) (void *mf, const char* name); int (CCONV *IsOn) (void *mf, const char* name);
/*========================================================================= /*=========================================================================
The following functions are designed to operate or manipulate The following functions are designed to operate or manipulate
cmSourceFiles. Please see cmSourceFile.h for additional information on many cmSourceFiles. Please see cmSourceFile.h for additional information on many
of these methods. Some of these methods are in cmMakefile.h. of these methods. Some of these methods are in cmMakefile.h.
=========================================================================*/ =========================================================================*/
void *(CCONV *AddSource) (void *mf, void *sf); void *(CCONV *AddSource) (void *mf, void *sf);
void *(CCONV *CreateSourceFile) (); void *(CCONV *CreateSourceFile) ();
void (CCONV *DestroySourceFile) (void *sf); void (CCONV *DestroySourceFile) (void *sf);
void *(CCONV *GetSource) (void *mf, const char* sourceName); void *(CCONV *GetSource) (void *mf, const char* sourceName);
@ -128,17 +130,19 @@ typedef struct
int (CCONV *SourceFileGetPropertyAsBool) (void *sf, const char *prop); int (CCONV *SourceFileGetPropertyAsBool) (void *sf, const char *prop);
const char *(CCONV *SourceFileGetSourceName) (void *sf); const char *(CCONV *SourceFileGetSourceName) (void *sf);
const char *(CCONV *SourceFileGetFullPath) (void *sf); const char *(CCONV *SourceFileGetFullPath) (void *sf);
void (CCONV *SourceFileSetName) (void *sf, const char* name, const char* dir, void (CCONV *SourceFileSetName) (void *sf, const char* name,
const char* dir,
int numSourceExtensions, int numSourceExtensions,
const char **sourceExtensions, const char **sourceExtensions,
int numHeaderExtensions, int numHeaderExtensions,
const char **headerExtensions); const char **headerExtensions);
void (CCONV *SourceFileSetName2) (void *sf, const char* name, const char* dir, void (CCONV *SourceFileSetName2) (void *sf, const char* name,
const char* dir,
const char *ext, int headerFileOnly); const char *ext, int headerFileOnly);
void (CCONV *SourceFileSetProperty) (void *sf, const char *prop, void (CCONV *SourceFileSetProperty) (void *sf, const char *prop,
const char *value); const char *value);
/*========================================================================= /*=========================================================================
The following methods are from cmSystemTools.h see that file for specific The following methods are from cmSystemTools.h see that file for specific
documentation on each method. documentation on each method.
@ -149,7 +153,7 @@ typedef struct
char *(CCONV *GetFilenamePath)(const char *); char *(CCONV *GetFilenamePath)(const char *);
void (CCONV *RemoveFile)(const char *f1); void (CCONV *RemoveFile)(const char *f1);
void (CCONV *Free)(void *); void (CCONV *Free)(void *);
/*========================================================================= /*=========================================================================
The following are new functions added after 1.6 The following are new functions added after 1.6
=========================================================================*/ =========================================================================*/
@ -162,21 +166,21 @@ typedef struct
const char* command, const char* command,
int numArgs, const char **args, int numArgs, const char **args,
int commandType); int commandType);
/* display status information */ /* display status information */
void (CCONV *DisplaySatus) (void *info, const char *message); void (CCONV *DisplaySatus) (void *info, const char *message);
/* this is the end of the C function stub API structure */ /* this is the end of the C function stub API structure */
} cmCAPI; } cmCAPI;
/*========================================================================= /*=========================================================================
CM_PLUGIN_EXPORT should be used by plugins CM_PLUGIN_EXPORT should be used by plugins
=========================================================================*/ =========================================================================*/
#ifdef _WIN32 #ifdef _WIN32
#define CM_PLUGIN_EXPORT __declspec( dllexport ) #define CM_PLUGIN_EXPORT __declspec( dllexport )
#else #else
#define CM_PLUGIN_EXPORT #define CM_PLUGIN_EXPORT
#endif #endif
/*========================================================================= /*=========================================================================
@ -203,16 +207,16 @@ define the different types of custom commands for a target
#define CM_PRE_BUILD 0 #define CM_PRE_BUILD 0
#define CM_PRE_LINK 1 #define CM_PRE_LINK 1
#define CM_POST_BUILD 2 #define CM_POST_BUILD 2
/*========================================================================= /*=========================================================================
Finally we define the key data structures and function prototypes Finally we define the key data structures and function prototypes
=========================================================================*/ =========================================================================*/
typedef const char* (CCONV *CM_DOC_FUNCTION)(); typedef const char* (CCONV *CM_DOC_FUNCTION)();
typedef int (CCONV *CM_INITIAL_PASS_FUNCTION)(void *info, void *mf, typedef int (CCONV *CM_INITIAL_PASS_FUNCTION)(void *info, void *mf,
int argc, char *[]); int argc, char *[]);
typedef void (CCONV *CM_FINAL_PASS_FUNCTION)(void *info, void *mf); typedef void (CCONV *CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
typedef void (CCONV *CM_DESTRUCTOR_FUNCTION)(void *info); typedef void (CCONV *CM_DESTRUCTOR_FUNCTION)(void *info);
typedef struct { typedef struct {
unsigned long reserved1; /* Reserved for future use. DO NOT USE. */ unsigned long reserved1; /* Reserved for future use. DO NOT USE. */
unsigned long reserved2; /* Reserved for future use. DO NOT USE. */ unsigned long reserved2; /* Reserved for future use. DO NOT USE. */
@ -222,14 +226,14 @@ Finally we define the key data structures and function prototypes
CM_FINAL_PASS_FUNCTION FinalPass; CM_FINAL_PASS_FUNCTION FinalPass;
CM_DESTRUCTOR_FUNCTION Destructor; CM_DESTRUCTOR_FUNCTION Destructor;
CM_DOC_FUNCTION GetTerseDocumentation; CM_DOC_FUNCTION GetTerseDocumentation;
CM_DOC_FUNCTION GetFullDocumentation; CM_DOC_FUNCTION GetFullDocumentation;
const char *Name; const char *Name;
char *Error; char *Error;
void *ClientData; void *ClientData;
} cmLoadedCommandInfo; } cmLoadedCommandInfo;
typedef void (CCONV *CM_INIT_FUNCTION)(cmLoadedCommandInfo *); typedef void (CCONV *CM_INIT_FUNCTION)(cmLoadedCommandInfo *);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -28,7 +28,7 @@
# include <windows.h> # include <windows.h>
#endif // _WIN32 #endif // _WIN32
const char* cmCacheManagerTypes[] = const char* cmCacheManagerTypes[] =
{ "BOOL", { "BOOL",
"PATH", "PATH",
"FILEPATH", "FILEPATH",
@ -80,14 +80,16 @@ bool cmCacheManager::LoadCache(const char* path,
return this->LoadCache(path, internal, emptySet, emptySet); return this->LoadCache(path, internal, emptySet, emptySet);
} }
bool cmCacheManager::ParseEntry(const char* entry, bool cmCacheManager::ParseEntry(const char* entry,
std::string& var, std::string& var,
std::string& value) std::string& value)
{ {
// input line is: key:type=value // input line is: key:type=value
static cmsys::RegularExpression reg("^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); static cmsys::RegularExpression reg(
"^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
// input line is: "key":type=value // input line is: "key":type=value
static cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); static cmsys::RegularExpression regQuoted(
"^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
bool flag = false; bool flag = false;
if(regQuoted.find(entry)) if(regQuoted.find(entry))
{ {
@ -104,27 +106,29 @@ bool cmCacheManager::ParseEntry(const char* entry,
// if value is enclosed in single quotes ('foo') then remove them // if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab // it is used to enclose trailing space or tab
if (flag && if (flag &&
value.size() >= 2 && value.size() >= 2 &&
value[0] == '\'' && value[0] == '\'' &&
value[value.size() - 1] == '\'') value[value.size() - 1] == '\'')
{ {
value = value.substr(1, value = value.substr(1,
value.size() - 2); value.size() - 2);
} }
return flag; return flag;
} }
bool cmCacheManager::ParseEntry(const char* entry, bool cmCacheManager::ParseEntry(const char* entry,
std::string& var, std::string& var,
std::string& value, std::string& value,
CacheEntryType& type) CacheEntryType& type)
{ {
// input line is: key:type=value // input line is: key:type=value
static cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); static cmsys::RegularExpression reg(
"^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
// input line is: "key":type=value // input line is: "key":type=value
static cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); static cmsys::RegularExpression regQuoted(
"^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
bool flag = false; bool flag = false;
if(regQuoted.find(entry)) if(regQuoted.find(entry))
{ {
@ -143,12 +147,12 @@ bool cmCacheManager::ParseEntry(const char* entry,
// if value is enclosed in single quotes ('foo') then remove them // if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab // it is used to enclose trailing space or tab
if (flag && if (flag &&
value.size() >= 2 && value.size() >= 2 &&
value[0] == '\'' && value[0] == '\'' &&
value[value.size() - 1] == '\'') value[value.size() - 1] == '\'')
{ {
value = value.substr(1, value = value.substr(1,
value.size() - 2); value.size() - 2);
} }
@ -186,7 +190,7 @@ bool cmCacheManager::LoadCache(const char* path,
this->CleanCMakeFiles(path); this->CleanCMakeFiles(path);
return false; return false;
} }
std::ifstream fin(cacheFile.c_str()); std::ifstream fin(cacheFile.c_str());
if(!fin) if(!fin)
{ {
@ -232,7 +236,7 @@ bool cmCacheManager::LoadCache(const char* path,
// If the entry is not internal to the cache being loaded // If the entry is not internal to the cache being loaded
// or if it is in the list of internal entries to be // or if it is in the list of internal entries to be
// imported, load it. // imported, load it.
if ( internal || (e.m_Type != INTERNAL) || if ( internal || (e.m_Type != INTERNAL) ||
(includes.find(entryKey) != includes.end()) ) (includes.find(entryKey) != includes.end()) )
{ {
// If we are loading the cache from another project, // If we are loading the cache from another project,
@ -250,12 +254,14 @@ bool cmCacheManager::LoadCache(const char* path,
} }
if ( e.m_Type == cmCacheManager::INTERNAL && if ( e.m_Type == cmCacheManager::INTERNAL &&
(entryKey.size() > strlen("-ADVANCED")) && (entryKey.size() > strlen("-ADVANCED")) &&
strcmp(entryKey.c_str() + (entryKey.size() - strlen("-ADVANCED")), strcmp(entryKey.c_str() + (entryKey.size() -
"-ADVANCED") == 0 ) strlen("-ADVANCED")), "-ADVANCED") == 0 )
{ {
std::string value = e.m_Value; std::string value = e.m_Value;
std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED"))); std::string akey
cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str()); = entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED")));
cmCacheManager::CacheIterator it
= this->GetCacheIterator(akey.c_str());
if ( it.IsAtEnd() ) if ( it.IsAtEnd() )
{ {
e.m_Type = cmCacheManager::UNINITIALIZED; e.m_Type = cmCacheManager::UNINITIALIZED;
@ -269,12 +275,14 @@ bool cmCacheManager::LoadCache(const char* path,
} }
else if ( e.m_Type == cmCacheManager::INTERNAL && else if ( e.m_Type == cmCacheManager::INTERNAL &&
(entryKey.size() > strlen("-MODIFIED")) && (entryKey.size() > strlen("-MODIFIED")) &&
strcmp(entryKey.c_str() + (entryKey.size() - strlen("-MODIFIED")), strcmp(entryKey.c_str() + (entryKey.size() -
"-MODIFIED") == 0 ) strlen("-MODIFIED")), "-MODIFIED") == 0 )
{ {
std::string value = e.m_Value; std::string value = e.m_Value;
std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-MODIFIED"))); std::string akey
cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str()); = entryKey.substr(0, (entryKey.size() - strlen("-MODIFIED")));
cmCacheManager::CacheIterator it
= this->GetCacheIterator(akey.c_str());
if ( it.IsAtEnd() ) if ( it.IsAtEnd() )
{ {
e.m_Type = cmCacheManager::UNINITIALIZED; e.m_Type = cmCacheManager::UNINITIALIZED;
@ -310,7 +318,7 @@ bool cmCacheManager::LoadCache(const char* path,
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0", this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0",
"Major version of cmake used to create the " "Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);
} }
// check to make sure the cache directory has not // check to make sure the cache directory has not
// been moved // been moved
@ -322,27 +330,27 @@ bool cmCacheManager::LoadCache(const char* path,
currentcwd += "/CMakeCache.txt"; currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt";
if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str())) if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str()))
{ {
std::string message = std::string message =
std::string("The current CMakeCache.txt directory ") + std::string("The current CMakeCache.txt directory ") +
currentcwd + std::string(" is different than the directory ") + currentcwd + std::string(" is different than the directory ") +
std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) + std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) +
std::string(" where CMackeCache.txt was created. This may result " std::string(" where CMackeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you " "in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt"); "are not sure, reedit the CMakeCache.txt");
cmSystemTools::Error(message.c_str()); cmSystemTools::Error(message.c_str());
} }
} }
return true; return true;
} }
bool cmCacheManager::SaveCache(cmMakefile* mf) bool cmCacheManager::SaveCache(cmMakefile* mf)
{ {
return this->SaveCache(mf->GetHomeOutputDirectory()); return this->SaveCache(mf->GetHomeOutputDirectory());
} }
bool cmCacheManager::SaveCache(const char* path) bool cmCacheManager::SaveCache(const char* path)
{ {
std::string cacheFile = path; std::string cacheFile = path;
cacheFile += "/CMakeCache.txt"; cacheFile += "/CMakeCache.txt";
@ -350,14 +358,14 @@ bool cmCacheManager::SaveCache(const char* path)
tempFile += ".tmp"; tempFile += ".tmp";
std::ofstream fout(tempFile.c_str()); std::ofstream fout(tempFile.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Unable to open cache file for save. ", cmSystemTools::Error("Unable to open cache file for save. ",
cacheFile.c_str()); cacheFile.c_str());
cmSystemTools::ReportLastSystemError(""); cmSystemTools::ReportLastSystemError("");
return false; return false;
} }
// before writing the cache, update the version numbers // before writing the cache, update the version numbers
// to the // to the
char temp[1024]; char temp[1024];
sprintf(temp, "%d", cmMakefile::GetMinorVersion()); sprintf(temp, "%d", cmMakefile::GetMinorVersion());
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp, this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
@ -368,7 +376,8 @@ bool cmCacheManager::SaveCache(const char* path)
"Major version of cmake used to create the " "Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);
this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION", cmMakefile::GetReleaseVersion(), this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION",
cmMakefile::GetReleaseVersion(),
"Major version of cmake used to create the " "Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);
@ -387,19 +396,25 @@ bool cmCacheManager::SaveCache(const char* path)
fout << "# This is the CMakeCache file.\n" fout << "# This is the CMakeCache file.\n"
<< "# For build in directory: " << currentcwd << "\n"; << "# For build in directory: " << currentcwd << "\n";
cmCacheManager::CacheEntry* cmakeCacheEntry = this->GetCacheEntry("CMAKE_COMMAND"); cmCacheManager::CacheEntry* cmakeCacheEntry
= this->GetCacheEntry("CMAKE_COMMAND");
if ( cmakeCacheEntry ) if ( cmakeCacheEntry )
{ {
fout << "# It was generated by CMake: " << cmakeCacheEntry->m_Value << std::endl; fout << "# It was generated by CMake: " << cmakeCacheEntry->m_Value
<< std::endl;
} }
fout << "# You can edit this file to change values found and used by cmake.\n" fout << "# You can edit this file to change values found and used by cmake."
<< "# If you do not want to change any of the values, simply exit the editor.\n" << std::endl
<< "# If you do want to change a value, simply edit, save, and exit the editor.\n" << "# If you do not want to change any of the values, simply exit the "
"editor." << std::endl
<< "# If you do want to change a value, simply edit, save, and exit "
"the editor." << std::endl
<< "# The syntax for the file is as follows:\n" << "# The syntax for the file is as follows:\n"
<< "# KEY:TYPE=VALUE\n" << "# KEY:TYPE=VALUE\n"
<< "# KEY is the name of a variable in the cache.\n" << "# KEY is the name of a variable in the cache.\n"
<< "# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.\n" << "# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT "
"TYPE!." << std::endl
<< "# VALUE is the current value for the KEY.\n\n"; << "# VALUE is the current value for the KEY.\n\n";
fout << "########################\n"; fout << "########################\n";
@ -410,20 +425,20 @@ bool cmCacheManager::SaveCache(const char* path)
for( std::map<cmStdString, CacheEntry>::const_iterator i = m_Cache.begin(); for( std::map<cmStdString, CacheEntry>::const_iterator i = m_Cache.begin();
i != m_Cache.end(); ++i) i != m_Cache.end(); ++i)
{ {
const CacheEntry& ce = (*i).second; const CacheEntry& ce = (*i).second;
CacheEntryType t = ce.m_Type; CacheEntryType t = ce.m_Type;
if(t == cmCacheManager::UNINITIALIZED || !ce.m_Initialized) if(t == cmCacheManager::UNINITIALIZED || !ce.m_Initialized)
{ {
/* /*
// This should be added in, but is not for now. // This should be added in, but is not for now.
cmSystemTools::Error("Cache entry \"", (*i).first.c_str(), cmSystemTools::Error("Cache entry \"", (*i).first.c_str(),
"\" is uninitialized"); "\" is uninitialized");
*/ */
} }
else if(t != INTERNAL) else if(t != INTERNAL)
{ {
// Format is key:type=value // Format is key:type=value
std::map<cmStdString,cmStdString>::const_iterator it = std::map<cmStdString,cmStdString>::const_iterator it =
ce.m_Properties.find("HELPSTRING"); ce.m_Properties.find("HELPSTRING");
if ( it == ce.m_Properties.end() ) if ( it == ce.m_Properties.end() )
{ {
@ -434,7 +449,7 @@ bool cmCacheManager::SaveCache(const char* path)
cmCacheManager::OutputHelpString(fout, it->second); cmCacheManager::OutputHelpString(fout, it->second);
} }
std::string key; std::string key;
// support : in key name by double quoting // support : in key name by double quoting
if((*i).first.find(':') != std::string::npos || if((*i).first.find(':') != std::string::npos ||
(*i).first.find("//") == 0) (*i).first.find("//") == 0)
{ {
@ -450,7 +465,7 @@ bool cmCacheManager::SaveCache(const char* path)
<< cmCacheManagerTypes[t] << "="; << cmCacheManagerTypes[t] << "=";
// if value has trailing space or tab, enclose it in single quotes // if value has trailing space or tab, enclose it in single quotes
if (ce.m_Value.size() && if (ce.m_Value.size() &&
(ce.m_Value[ce.m_Value.size() - 1] == ' ' || (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
ce.m_Value[ce.m_Value.size() - 1] == '\t')) ce.m_Value[ce.m_Value.size() - 1] == '\t'))
{ {
fout << '\'' << ce.m_Value << '\''; fout << '\'' << ce.m_Value << '\'';
@ -491,7 +506,7 @@ bool cmCacheManager::SaveCache(const char* path)
helpstring += i.GetName(); helpstring += i.GetName();
rkey += "-ADVANCED"; rkey += "-ADVANCED";
cmCacheManager::OutputHelpString(fout, helpstring.c_str()); cmCacheManager::OutputHelpString(fout, helpstring.c_str());
// support : in key name by double quoting // support : in key name by double quoting
if(rkey.find(':') != std::string::npos || if(rkey.find(':') != std::string::npos ||
rkey.find("//") == 0) rkey.find("//") == 0)
{ {
@ -519,7 +534,7 @@ bool cmCacheManager::SaveCache(const char* path)
helpstring += i.GetName(); helpstring += i.GetName();
rkey += "-MODIFIED"; rkey += "-MODIFIED";
cmCacheManager::OutputHelpString(fout, helpstring.c_str()); cmCacheManager::OutputHelpString(fout, helpstring.c_str());
// support : in key name by double quoting // support : in key name by double quoting
if(rkey.find(':') != std::string::npos || if(rkey.find(':') != std::string::npos ||
rkey.find("//") == 0) rkey.find("//") == 0)
{ {
@ -550,7 +565,7 @@ bool cmCacheManager::SaveCache(const char* path)
helpstring = ""; helpstring = "";
} }
cmCacheManager::OutputHelpString(fout, helpstring.c_str()); cmCacheManager::OutputHelpString(fout, helpstring.c_str());
// support : in key name by double quoting // support : in key name by double quoting
if(rkey.find(':') != std::string::npos || if(rkey.find(':') != std::string::npos ||
rkey.find("//") == 0) rkey.find("//") == 0)
{ {
@ -567,7 +582,7 @@ bool cmCacheManager::SaveCache(const char* path)
// if value has trailing space or tab, enclose it in single quotes // if value has trailing space or tab, enclose it in single quotes
std::string value = i.GetValue(); std::string value = i.GetValue();
if (value.size() && if (value.size() &&
(value[value.size() - 1] == ' ' || (value[value.size() - 1] == ' ' ||
value[value.size() - 1] == '\t')) value[value.size() - 1] == '\t'))
{ {
fout << '\'' << value << '\''; fout << '\'' << value << '\'';
@ -576,7 +591,7 @@ bool cmCacheManager::SaveCache(const char* path)
{ {
fout << value; fout << value;
} }
fout << "\n"; fout << "\n";
} }
} }
fout << "\n"; fout << "\n";
@ -591,15 +606,16 @@ bool cmCacheManager::SaveCache(const char* path)
std::ofstream checkCache(checkCacheFile.c_str()); std::ofstream checkCache(checkCacheFile.c_str());
if(!checkCache) if(!checkCache)
{ {
cmSystemTools::Error("Unable to open check cache file for write. ", cmSystemTools::Error("Unable to open check cache file for write. ",
checkCacheFile.c_str()); checkCacheFile.c_str());
return false; return false;
} }
checkCache << "# This file is generated by cmake for dependency checking of the CMakeCache.txt file\n"; checkCache << "# This file is generated by cmake for dependency checking "
"of the CMakeCache.txt file\n";
return true; return true;
} }
bool cmCacheManager::DeleteCache(const char* path) bool cmCacheManager::DeleteCache(const char* path)
{ {
std::string cacheFile = path; std::string cacheFile = path;
cmSystemTools::ConvertToUnixSlashes(cacheFile); cmSystemTools::ConvertToUnixSlashes(cacheFile);
@ -611,7 +627,9 @@ bool cmCacheManager::DeleteCache(const char* path)
cmsys::Directory dir; cmsys::Directory dir;
cmakeFiles += "/CMakeFiles"; cmakeFiles += "/CMakeFiles";
dir.Load(cmakeFiles.c_str()); dir.Load(cmakeFiles.c_str());
for (unsigned long fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) for (unsigned long fileNum = 0;
fileNum < dir.GetNumberOfFiles();
++fileNum)
{ {
if(!cmSystemTools:: if(!cmSystemTools::
FileIsDirectory(dir.GetFile(fileNum))) FileIsDirectory(dir.GetFile(fileNum)))
@ -625,7 +643,7 @@ bool cmCacheManager::DeleteCache(const char* path)
return true; return true;
} }
void cmCacheManager::OutputHelpString(std::ofstream& fout, void cmCacheManager::OutputHelpString(std::ofstream& fout,
const std::string& helpString) const std::string& helpString)
{ {
std::string::size_type end = helpString.size(); std::string::size_type end = helpString.size();
@ -683,7 +701,8 @@ cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
return 0; return 0;
} }
cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char *key) cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
const char *key)
{ {
return CacheIterator(*this, key); return CacheIterator(*this, key);
} }
@ -709,17 +728,19 @@ void cmCacheManager::PrintCache(std::ostream& out) const
{ {
if((*i).second.m_Type != INTERNAL) if((*i).second.m_Type != INTERNAL)
{ {
out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl; out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str()
<< std::endl;
} }
} }
out << "\n\n"; out << "\n\n";
out << "To change values in the CMakeCache, \nedit CMakeCache.txt in your output directory.\n"; out << "To change values in the CMakeCache, "
<< std::endl << "edit CMakeCache.txt in your output directory.\n";
out << "=================================================" << std::endl; out << "=================================================" << std::endl;
} }
void cmCacheManager::AddCacheEntry(const char* key, void cmCacheManager::AddCacheEntry(const char* key,
const char* value, const char* value,
const char* helpString, const char* helpString,
CacheEntryType type) CacheEntryType type)
{ {
@ -729,7 +750,7 @@ void cmCacheManager::AddCacheEntry(const char* key,
e.m_Value = value; e.m_Value = value;
e.m_Initialized = true; e.m_Initialized = true;
} }
else else
{ {
e.m_Value = ""; e.m_Value = "";
} }
@ -743,14 +764,15 @@ void cmCacheManager::AddCacheEntry(const char* key,
{ {
e.m_Properties["HELPSTRING"] = helpString; e.m_Properties["HELPSTRING"] = helpString;
} }
else else
{ {
e.m_Properties["HELPSTRING"] = "(This variable does not exists and should not be used)"; e.m_Properties["HELPSTRING"]
= "(This variable does not exists and should not be used)";
} }
m_Cache[key] = e; m_Cache[key] = e;
} }
void cmCacheManager::AddCacheEntry(const char* key, bool v, void cmCacheManager::AddCacheEntry(const char* key, bool v,
const char* helpString) const char* helpString)
{ {
if(v) if(v)
@ -768,9 +790,9 @@ bool cmCacheManager::CacheIterator::IsAtEnd() const
return m_Position == m_Container.m_Cache.end(); return m_Position == m_Container.m_Cache.end();
} }
void cmCacheManager::CacheIterator::Begin() void cmCacheManager::CacheIterator::Begin()
{ {
m_Position = m_Container.m_Cache.begin(); m_Position = m_Container.m_Cache.begin();
} }
bool cmCacheManager::CacheIterator::Find(const char* key) bool cmCacheManager::CacheIterator::Find(const char* key)
@ -779,11 +801,11 @@ bool cmCacheManager::CacheIterator::Find(const char* key)
return !this->IsAtEnd(); return !this->IsAtEnd();
} }
void cmCacheManager::CacheIterator::Next() void cmCacheManager::CacheIterator::Next()
{ {
if (!this->IsAtEnd()) if (!this->IsAtEnd())
{ {
++m_Position; ++m_Position;
} }
} }
@ -805,7 +827,8 @@ void cmCacheManager::CacheIterator::SetValue(const char* value)
} }
} }
const char* cmCacheManager::CacheIterator::GetProperty(const char* property) const const char* cmCacheManager::CacheIterator::GetProperty(
const char* property) const
{ {
// make sure it is not at the end // make sure it is not at the end
if (this->IsAtEnd()) if (this->IsAtEnd())
@ -815,12 +838,12 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* property) con
if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
{ {
cmSystemTools::Error("Property \"", property, cmSystemTools::Error("Property \"", property,
"\" cannot be accessed through the GetProperty()"); "\" cannot be accessed through the GetProperty()");
return 0; return 0;
} }
const CacheEntry* ent = &this->GetEntry(); const CacheEntry* ent = &this->GetEntry();
std::map<cmStdString,cmStdString>::const_iterator it = std::map<cmStdString,cmStdString>::const_iterator it =
ent->m_Properties.find(property); ent->m_Properties.find(property);
if ( it == ent->m_Properties.end() ) if ( it == ent->m_Properties.end() )
{ {
@ -829,7 +852,7 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* property) con
return it->second.c_str(); return it->second.c_str();
} }
void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
{ {
// make sure it is not at the end // make sure it is not at the end
if (this->IsAtEnd()) if (this->IsAtEnd())
@ -839,7 +862,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") ) if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
{ {
cmSystemTools::Error("Property \"", p, cmSystemTools::Error("Property \"", p,
"\" cannot be accessed through the SetProperty()"); "\" cannot be accessed through the SetProperty()");
return; return;
} }
@ -847,27 +870,28 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
ent->m_Properties[p] = v; ent->m_Properties[p] = v;
} }
bool cmCacheManager::CacheIterator::GetValueAsBool() const bool cmCacheManager::CacheIterator::GetValueAsBool() const
{ {
return cmSystemTools::IsOn(this->GetEntry().m_Value.c_str()); return cmSystemTools::IsOn(this->GetEntry().m_Value.c_str());
} }
bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* property) const bool cmCacheManager::CacheIterator::GetPropertyAsBool(
const char* property) const
{ {
// make sure it is not at the end // make sure it is not at the end
if (this->IsAtEnd()) if (this->IsAtEnd())
{ {
return false; return false;
} }
if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
{ {
cmSystemTools::Error("Property \"", property, cmSystemTools::Error("Property \"", property,
"\" cannot be accessed through the GetPropertyAsBool()"); "\" cannot be accessed through the GetPropertyAsBool()");
return false; return false;
} }
const CacheEntry* ent = &this->GetEntry(); const CacheEntry* ent = &this->GetEntry();
std::map<cmStdString,cmStdString>::const_iterator it = std::map<cmStdString,cmStdString>::const_iterator it =
ent->m_Properties.find(property); ent->m_Properties.find(property);
if ( it == ent->m_Properties.end() ) if ( it == ent->m_Properties.end() )
{ {
@ -877,7 +901,7 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* property) cons
} }
void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
{ {
// make sure it is not at the end // make sure it is not at the end
if (this->IsAtEnd()) if (this->IsAtEnd())
@ -887,7 +911,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") ) if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
{ {
cmSystemTools::Error("Property \"", p, cmSystemTools::Error("Property \"", p,
"\" cannot be accessed through the SetProperty()"); "\" cannot be accessed through the SetProperty()");
return; return;
} }
@ -905,12 +929,12 @@ bool cmCacheManager::CacheIterator::PropertyExists(const char* property) const
if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") ) if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
{ {
cmSystemTools::Error("Property \"", property, cmSystemTools::Error("Property \"", property,
"\" cannot be accessed through the PropertyExists()"); "\" cannot be accessed through the PropertyExists()");
return false; return false;
} }
const CacheEntry* ent = &this->GetEntry(); const CacheEntry* ent = &this->GetEntry();
std::map<cmStdString,cmStdString>::const_iterator it = std::map<cmStdString,cmStdString>::const_iterator it =
ent->m_Properties.find(property); ent->m_Properties.find(property);
if ( it == ent->m_Properties.end() ) if ( it == ent->m_Properties.end() )
{ {

View File

@ -1,7 +1,8 @@
/* A Bison parser, made by GNU Bison 1.875d. */ /* A Bison parser, made by GNU Bison 1.875d. */
/* Skeleton parser for Yacc-like parsing with Bison, /* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -115,7 +116,9 @@ This file must be translated to C and modified to build everywhere.
Run bison like this: Run bison like this:
bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y bison --yacc --name-prefix=cmCommandArgument_yy \
--defines=cmCommandArgumentParserTokens.h \
-ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
Modify cmCommandArgumentParser.cxx: Modify cmCommandArgumentParser.cxx:
- remove TABs - remove TABs
@ -153,7 +156,7 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */ # pragma warning (disable: 4065) /* Switch contains default but no case. */
#endif #endif
@ -1171,7 +1174,6 @@ yyreduce:
{ {
yyval.str = yyGetParser->ExpandSpecialVariable(yyvsp[-2].str,yyvsp[-1].str); yyval.str = yyGetParser->ExpandSpecialVariable(yyvsp[-2].str,yyvsp[-1].str);
//std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
} }
break; break;
@ -1179,7 +1181,6 @@ yyreduce:
{ {
yyval.str = yyGetParser->ExpandVariable(yyvsp[-1].str); yyval.str = yyGetParser->ExpandVariable(yyvsp[-1].str);
//std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
} }
break; break;

View File

@ -9,12 +9,12 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#ifndef cmCommandArgumentParserHelper_h #ifndef cmCommandArgumentParserHelper_h
#define cmCommandArgumentParserHelper_h #define cmCommandArgumentParserHelper_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
@ -22,7 +22,8 @@
#define YYSTYPE cmCommandArgumentParserHelper::ParserType #define YYSTYPE cmCommandArgumentParserHelper::ParserType
#define YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED
#define YY_EXTRA_TYPE cmCommandArgumentParserHelper* #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
#define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) #define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
yyscan_t yyscanner)
/** \class cmCommandArgumentParserHelper /** \class cmCommandArgumentParserHelper
* \brief Helper class for parsing java source files * \brief Helper class for parsing java source files
@ -45,9 +46,10 @@ public:
int ParseString(const char* str, int verb); int ParseString(const char* str, int verb);
// For the lexer: // For the lexer:
void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt, void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
const char* str, int len = 0); const char* str, int len = 0);
bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, char symbol); bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
char symbol);
int LexInput(char* buf, int maxlen); int LexInput(char* buf, int maxlen);
void Error(const char* str); void Error(const char* str);

View File

@ -1,7 +1,8 @@
/* A Bison parser, made by GNU Bison 1.875d. */ /* A Bison parser, made by GNU Bison 1.875d. */
/* Skeleton parser for Yacc-like parsing with Bison, /* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -26,7 +26,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
return false; return false;
} }
std::vector<std::string>::const_iterator i = args.begin(); std::vector<std::string>::const_iterator i = args.begin();
std::string extraInclude; std::string extraInclude;
std::string function; std::string function;
@ -63,7 +63,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
} }
} }
i = tests.begin(); i = tests.begin();
// Name of the source list // Name of the source list
const char* sourceList = i->c_str(); const char* sourceList = i->c_str();
@ -73,7 +73,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
// make sure they specified an extension // make sure they specified an extension
if (cmSystemTools::GetFilenameExtension(*i).size() < 2) if (cmSystemTools::GetFilenameExtension(*i).size() < 2)
{ {
this->SetError("You must specify a file extenion for the test driver file."); this->SetError(
"You must specify a file extenion for the test driver file.");
return false; return false;
} }
std::string driver = m_Makefile->GetCurrentOutputDirectory(); std::string driver = m_Makefile->GetCurrentOutputDirectory();
@ -81,18 +82,18 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
driver += *i; driver += *i;
++i; ++i;
std::string configFile = std::string configFile =
m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
configFile += "/Templates/TestDriver.cxx.in"; configFile += "/Templates/TestDriver.cxx.in";
// Create the test driver file // Create the test driver file
std::vector<std::string>::const_iterator testsBegin = i; std::vector<std::string>::const_iterator testsBegin = i;
std::vector<std::string> tests_func_name; std::vector<std::string> tests_func_name;
// The rest of the arguments consist of a list of test source files. // The rest of the arguments consist of a list of test source files.
// Sadly, they can be in directories. Let's find a unique function // Sadly, they can be in directories. Let's find a unique function
// name for the corresponding test, and push it to the tests_func_name // name for the corresponding test, and push it to the tests_func_name
// list. // list.
// For the moment: // For the moment:
// - replace spaces ' ', ':' and '/' with underscores '_' // - replace spaces ' ', ':' and '/' with underscores '_'
std::string forwardDeclareCode; std::string forwardDeclareCode;
@ -105,7 +106,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
std::string func_name; std::string func_name;
if (cmSystemTools::GetFilenamePath(*i).size() > 0) if (cmSystemTools::GetFilenamePath(*i).size() > 0)
{ {
func_name = cmSystemTools::GetFilenamePath(*i) + "/" + func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i); cmSystemTools::GetFilenameWithoutLastExtension(*i);
} }
else else
@ -121,7 +122,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
forwardDeclareCode += func_name; forwardDeclareCode += func_name;
forwardDeclareCode += "(int, char*[]);\n"; forwardDeclareCode += "(int, char*[]);\n";
} }
std::string functionMapCode; std::string functionMapCode;
int numTests = 0; int numTests = 0;
std::vector<std::string>::iterator j; std::vector<std::string>::iterator j;
@ -130,7 +131,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
std::string func_name; std::string func_name;
if (cmSystemTools::GetFilenamePath(*i).size() > 0) if (cmSystemTools::GetFilenamePath(*i).size() > 0)
{ {
func_name = cmSystemTools::GetFilenamePath(*i) + "/" + func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i); cmSystemTools::GetFilenameWithoutLastExtension(*i);
} }
else else
@ -149,16 +150,21 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
} }
if(extraInclude.size()) if(extraInclude.size())
{ {
m_Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude.c_str()); m_Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
extraInclude.c_str());
} }
if(function.size()) if(function.size())
{ {
m_Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function.c_str()); m_Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
function.c_str());
} }
m_Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode.c_str()); m_Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
m_Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode.c_str()); forwardDeclareCode.c_str());
m_Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
functionMapCode.c_str());
bool res = true; bool res = true;
if ( !m_Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false, true, false) ) if ( !m_Makefile->ConfigureFile(configFile.c_str(), driver.c_str(),
false, true, false) )
{ {
res = false; res = false;
} }
@ -166,22 +172,22 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
// Create the source list // Create the source list
cmSourceFile cfile; cmSourceFile cfile;
std::string sourceListValue; std::string sourceListValue;
cfile.SetProperty("ABSTRACT","0"); cfile.SetProperty("ABSTRACT","0");
cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(), cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(),
m_Makefile->GetCurrentOutputDirectory(), m_Makefile->GetCurrentOutputDirectory(),
cmSystemTools::GetFilenameExtension(args[1]).c_str()+1, cmSystemTools::GetFilenameExtension(args[1]).c_str()+1,
false); false);
m_Makefile->AddSource(cfile); m_Makefile->AddSource(cfile);
sourceListValue = args[1]; sourceListValue = args[1];
for(i = testsBegin; i != tests.end(); ++i) for(i = testsBegin; i != tests.end(); ++i)
{ {
cmSourceFile icfile; cmSourceFile icfile;
icfile.SetProperty("ABSTRACT","0"); icfile.SetProperty("ABSTRACT","0");
icfile.SetName(i->c_str(), icfile.SetName(i->c_str(),
m_Makefile->GetCurrentDirectory(), m_Makefile->GetCurrentDirectory(),
m_Makefile->GetSourceExtensions(), m_Makefile->GetSourceExtensions(),
m_Makefile->GetHeaderExtensions()); m_Makefile->GetHeaderExtensions());
m_Makefile->AddSource(icfile); m_Makefile->AddSource(icfile);
sourceListValue += ";"; sourceListValue += ";";

View File

@ -37,7 +37,8 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
cmCustomCommand::cmCustomCommand(const char* output, cmCustomCommand::cmCustomCommand(const char* output,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDirectory): const char* comment,
const char* workingDirectory):
m_Output(output?output:""), m_Output(output?output:""),
m_Depends(depends), m_Depends(depends),
m_CommandLines(commandLines), m_CommandLines(commandLines),

View File

@ -31,7 +31,7 @@ cmDependsC::cmDependsC():
// yummy look at all those constructor arguments // yummy look at all those constructor arguments
cmDependsC::cmDependsC(std::vector<std::string> const& includes, cmDependsC::cmDependsC(std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex, const char* scanRegex, const char* complainRegex,
std::set<cmStdString> const& generatedFiles, std::set<cmStdString> const& generatedFiles,
const cmStdString& cacheFileName): const cmStdString& cacheFileName):
m_IncludePath(&includes), m_IncludePath(&includes),
m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"),
@ -48,7 +48,8 @@ cmDependsC::~cmDependsC()
{ {
this->WriteCacheFile(); this->WriteCacheFile();
for (std::map<cmStdString, cmIncludeLines*>::iterator it=m_fileCache.begin(); for (std::map<cmStdString, cmIncludeLines*>::iterator it
= m_fileCache.begin();
it!=m_fileCache.end(); ++it) it!=m_fileCache.end(); ++it)
{ {
delete it->second; delete it->second;
@ -154,13 +155,14 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
scanned.insert(fullName); scanned.insert(fullName);
// Check whether this file is already in the cache // Check whether this file is already in the cache
std::map<cmStdString, cmIncludeLines*>::iterator fileIt=m_fileCache.find(fullName); std::map<cmStdString, cmIncludeLines*>::iterator fileIt
= m_fileCache.find(fullName);
if (fileIt!=m_fileCache.end()) if (fileIt!=m_fileCache.end())
{ {
fileIt->second->m_Used=true; fileIt->second->m_Used=true;
dependencies.insert(fullName); dependencies.insert(fullName);
for (std::vector<UnscannedEntry>::const_iterator incIt= for (std::vector<UnscannedEntry>::const_iterator incIt=
fileIt->second->m_UnscannedEntries.begin(); fileIt->second->m_UnscannedEntries.begin();
incIt!=fileIt->second->m_UnscannedEntries.end(); ++incIt) incIt!=fileIt->second->m_UnscannedEntries.end(); ++incIt)
{ {
if (m_Encountered.find(incIt->FileName) == m_Encountered.end()) if (m_Encountered.find(incIt->FileName) == m_Encountered.end())
@ -172,7 +174,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
} }
else else
{ {
// Try to scan the file. Just leave it out if we cannot find // Try to scan the file. Just leave it out if we cannot find
// it. // it.
std::ifstream fin(fullName.c_str()); std::ifstream fin(fullName.c_str());
@ -180,7 +182,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
{ {
// Add this file as a dependency. // Add this file as a dependency.
dependencies.insert(fullName); dependencies.insert(fullName);
// Scan this file for new dependencies. Pass the directory // Scan this file for new dependencies. Pass the directory
// containing the file to handle double-quote includes. // containing the file to handle double-quote includes.
std::string dir = cmSystemTools::GetFilenamePath(fullName); std::string dir = cmSystemTools::GetFilenamePath(fullName);
@ -188,10 +190,10 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
} }
} }
} }
first = false; first = false;
} }
// Write the dependencies to the output stream. // Write the dependencies to the output stream.
internalDepends << obj << std::endl; internalDepends << obj << std::endl;
for(std::set<cmStdString>::iterator i=dependencies.begin(); for(std::set<cmStdString>::iterator i=dependencies.begin();
@ -203,7 +205,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
internalDepends << " " << i->c_str() << std::endl; internalDepends << " " << i->c_str() << std::endl;
} }
makeDepends << std::endl; makeDepends << std::endl;
return true; return true;
} }
@ -219,11 +221,11 @@ void cmDependsC::ReadCacheFile()
{ {
return; return;
} }
std::string line; std::string line;
cmIncludeLines* cacheEntry=0; cmIncludeLines* cacheEntry=0;
bool haveFileName=false; bool haveFileName=false;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
{ {
if (line.empty()) if (line.empty())
@ -238,12 +240,13 @@ void cmDependsC::ReadCacheFile()
haveFileName=true; haveFileName=true;
int newer=0; int newer=0;
cmFileTimeComparison comp; cmFileTimeComparison comp;
bool res=comp.FileTimeCompare(m_cacheFileName.c_str(), line.c_str(), &newer); bool res
= comp.FileTimeCompare(m_cacheFileName.c_str(), line.c_str(), &newer);
if ((res==true) && (newer==1)) //cache is newer than the parsed file if ((res==true) && (newer==1)) //cache is newer than the parsed file
{ {
cacheEntry=new cmIncludeLines; cacheEntry=new cmIncludeLines;
m_fileCache[line]=cacheEntry; m_fileCache[line]=cacheEntry;
} }
} }
else if (cacheEntry!=0) else if (cacheEntry!=0)
@ -274,16 +277,17 @@ void cmDependsC::WriteCacheFile() const
{ {
return; return;
} }
for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt=m_fileCache.begin(); for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt
= m_fileCache.begin();
fileIt!=m_fileCache.end(); ++fileIt) fileIt!=m_fileCache.end(); ++fileIt)
{ {
if (fileIt->second->m_Used) if (fileIt->second->m_Used)
{ {
cacheOut<<fileIt->first.c_str()<<std::endl; cacheOut<<fileIt->first.c_str()<<std::endl;
for (std::vector<UnscannedEntry>::const_iterator for (std::vector<UnscannedEntry>::const_iterator
incIt=fileIt->second->m_UnscannedEntries.begin(); incIt=fileIt->second->m_UnscannedEntries.begin();
incIt!=fileIt->second->m_UnscannedEntries.end(); ++incIt) incIt!=fileIt->second->m_UnscannedEntries.end(); ++incIt)
{ {
cacheOut<<incIt->FileName.c_str()<<std::endl; cacheOut<<incIt->FileName.c_str()<<std::endl;
@ -302,12 +306,13 @@ void cmDependsC::WriteCacheFile() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmDependsC::Scan(std::istream& is, const char* directory, const cmStdString& fullName) void cmDependsC::Scan(std::istream& is, const char* directory,
const cmStdString& fullName)
{ {
cmIncludeLines* newCacheEntry=new cmIncludeLines; cmIncludeLines* newCacheEntry=new cmIncludeLines;
newCacheEntry->m_Used=true; newCacheEntry->m_Used=true;
m_fileCache[fullName]=newCacheEntry; m_fileCache[fullName]=newCacheEntry;
// Read one line at a time. // Read one line at a time.
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(is, line)) while(cmSystemTools::GetLineFromStream(is, line))

View File

@ -32,22 +32,24 @@ public:
cmDependsC(); cmDependsC();
cmDependsC(std::vector<std::string> const& includes, cmDependsC(std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex, const char* scanRegex, const char* complainRegex,
std::set<cmStdString> const& generatedFiles, const cmStdString& cachFileName); std::set<cmStdString> const& generatedFiles,
const cmStdString& cachFileName);
/** Virtual destructor to cleanup subclasses properly. */ /** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDependsC(); virtual ~cmDependsC();
protected: protected:
typedef std::vector<char> t_CharBuffer; typedef std::vector<char> t_CharBuffer;
// Implement writing/checking methods required by superclass. // Implement writing/checking methods required by superclass.
virtual bool WriteDependencies(const char *src, virtual bool WriteDependencies(const char *src,
const char *file, const char *file,
std::ostream& makeDepends, std::ostream& makeDepends,
std::ostream& internalDepends); std::ostream& internalDepends);
// Method to scan a single file. // Method to scan a single file.
void Scan(std::istream& is, const char* directory, const cmStdString& fullName); void Scan(std::istream& is, const char* directory,
const cmStdString& fullName);
// Method to test for the existence of a file. // Method to test for the existence of a file.
bool FileExistsOrIsGenerated(const std::string& fname, bool FileExistsOrIsGenerated(const std::string& fname,

View File

@ -43,7 +43,7 @@ typedef uint32_t flex_uint32_t;
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
typedef int flex_int32_t; typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */ #endif /* ! C99 */
@ -164,8 +164,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#define EOB_ACT_LAST_MATCH 2 #define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n) #define YY_LESS_LINENO(n)
/* Return all but the first "n" matched characters back to the input stream. */ /* Return all but the first "n" matched characters back to the input stream.
*/
#define yyless(n) \ #define yyless(n) \
do \ do \
{ \ { \
@ -174,7 +175,8 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
YY_LESS_LINENO(yyless_macro_arg);\ YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = yyg->yy_hold_char; \ *yy_cp = yyg->yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \ YY_RESTORE_YY_MORE_OFFSET \
yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ yyg->yy_c_buf_p \
= yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \ } \
while ( 0 ) while ( 0 )
@ -231,7 +233,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */ int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */ int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the /* Whether to try to fill the input buffer when we reach the
* end of it. * end of it.
*/ */
@ -248,8 +250,8 @@ struct yy_buffer_state
* possible backing-up. * possible backing-up.
* *
* When we actually see the EOF, we change the status to "new" * When we actually see the EOF, we change the status to "new"
* (via cmDependsFortran_yyrestart()), so that the user can continue scanning by * (via cmDependsFortran_yyrestart()), so that the user can continue
* just pointing yyin at a new input file. * scanning by just pointing yyin at a new input file.
*/ */
#define YY_BUFFER_EOF_PENDING 2 #define YY_BUFFER_EOF_PENDING 2
@ -774,7 +776,7 @@ extern int cmDependsFortran_yywrap (yyscan_t yyscanner );
#endif #endif
static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
#ifndef yytext_ptr #ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif #endif
@ -1722,7 +1724,7 @@ static void cmDependsFortran_yy_load_buffer_state (yyscan_t yyscanner)
YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) cmDependsFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); b = (YY_BUFFER_STATE) cmDependsFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b ) if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in cmDependsFortran_yy_create_buffer()" ); YY_FATAL_ERROR( "out of dynamic memory in cmDependsFortran_yy_create_buffer()" );
@ -1766,7 +1768,7 @@ static void cmDependsFortran_yy_load_buffer_state (yyscan_t yyscanner)
#ifndef __cplusplus #ifndef __cplusplus
extern int isatty (int ); extern int isatty (int );
#endif /* __cplusplus */ #endif /* __cplusplus */
/* Initializes or reinitializes a buffer. /* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer, * This function is sometimes called more than once on the same buffer,
* such as during a cmDependsFortran_yyrestart() or at EOF. * such as during a cmDependsFortran_yyrestart() or at EOF.
@ -1792,7 +1794,7 @@ extern int isatty (int );
} }
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno; errno = oerrno;
} }
@ -1896,9 +1898,9 @@ static void cmDependsFortran_yyensure_buffer_stack (yyscan_t yyscanner)
yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsFortran_yyalloc yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsFortran_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*) (num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_max = num_to_alloc;
yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_top = 0;
return; return;
@ -1925,12 +1927,12 @@ static void cmDependsFortran_yyensure_buffer_stack (yyscan_t yyscanner)
* @param base the character buffer * @param base the character buffer
* @param size the size in bytes of the character buffer * @param size the size in bytes of the character buffer
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
if ( size < 2 || if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR ) base[size-1] != YY_END_OF_BUFFER_CHAR )
@ -1966,7 +1968,7 @@ YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char * base, yy_size_t size ,
*/ */
YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner)
{ {
return cmDependsFortran_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); return cmDependsFortran_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner);
} }
@ -1983,7 +1985,7 @@ YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char * bytes, int len
char *buf; char *buf;
yy_size_t n; yy_size_t n;
int i; int i;
/* Get memory for full buffer, including space for trailing EOB's. */ /* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2; n = len + 2;
buf = (char *) cmDependsFortran_yyalloc(n ,yyscanner ); buf = (char *) cmDependsFortran_yyalloc(n ,yyscanner );
@ -2051,10 +2053,10 @@ YY_EXTRA_TYPE cmDependsFortran_yyget_extra (yyscan_t yyscanner)
int cmDependsFortran_yyget_lineno (yyscan_t yyscanner) int cmDependsFortran_yyget_lineno (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER) if (! YY_CURRENT_BUFFER)
return 0; return 0;
return yylineno; return yylineno;
} }
@ -2064,10 +2066,10 @@ int cmDependsFortran_yyget_lineno (yyscan_t yyscanner)
int cmDependsFortran_yyget_column (yyscan_t yyscanner) int cmDependsFortran_yyget_column (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER) if (! YY_CURRENT_BUFFER)
return 0; return 0;
return yycolumn; return yycolumn;
} }
@ -2128,8 +2130,8 @@ void cmDependsFortran_yyset_lineno (int line_number , yyscan_t yyscanner)
/* lineno is only valid if an input buffer exists. */ /* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER ) if (! YY_CURRENT_BUFFER )
yy_fatal_error( "cmDependsFortran_yyset_lineno called with no buffer" , yyscanner); yy_fatal_error( "cmDependsFortran_yyset_lineno called with no buffer" , yyscanner);
yylineno = line_number; yylineno = line_number;
} }
@ -2143,8 +2145,8 @@ void cmDependsFortran_yyset_column (int column_no , yyscan_t yyscanner)
/* column is only valid if an input buffer exists. */ /* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER ) if (! YY_CURRENT_BUFFER )
yy_fatal_error( "cmDependsFortran_yyset_column called with no buffer" , yyscanner); yy_fatal_error( "cmDependsFortran_yyset_column called with no buffer" , yyscanner);
yycolumn = column_no; yycolumn = column_no;
} }

View File

@ -43,7 +43,7 @@ typedef uint32_t flex_uint32_t;
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
typedef int flex_int32_t; typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */ #endif /* ! C99 */
@ -173,7 +173,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */ int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */ int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the /* Whether to try to fill the input buffer when we reach the
* end of it. * end of it.
*/ */
@ -185,16 +185,24 @@ struct yy_buffer_state
#endif /* !YY_STRUCT_YY_BUFFER_STATE */ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
void cmDependsFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner ); void cmDependsFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,
YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); yyscan_t yyscanner );
void cmDependsFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size ,
void cmDependsFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); yyscan_t yyscanner );
void cmDependsFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void cmDependsFortran_yy_delete_buffer (YY_BUFFER_STATE b ,
yyscan_t yyscanner );
void cmDependsFortran_yy_flush_buffer (YY_BUFFER_STATE b ,
yyscan_t yyscanner );
void cmDependsFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,
yyscan_t yyscanner );
void cmDependsFortran_yypop_buffer_state (yyscan_t yyscanner ); void cmDependsFortran_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char *base,yy_size_t size ,
YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char *yy_str ,
yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char *bytes,int len ,
yyscan_t yyscanner );
void *cmDependsFortran_yyalloc (yy_size_t ,yyscan_t yyscanner ); void *cmDependsFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *cmDependsFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); void *cmDependsFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
@ -231,7 +239,8 @@ void cmDependsFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE cmDependsFortran_yyget_extra (yyscan_t yyscanner ); YY_EXTRA_TYPE cmDependsFortran_yyget_extra (yyscan_t yyscanner );
void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,
yyscan_t yyscanner );
FILE *cmDependsFortran_yyget_in (yyscan_t yyscanner ); FILE *cmDependsFortran_yyget_in (yyscan_t yyscanner );
@ -294,7 +303,8 @@ extern int cmDependsFortran_yylex (yyscan_t yyscanner);
#define YY_DECL int cmDependsFortran_yylex (yyscan_t yyscanner) #define YY_DECL int cmDependsFortran_yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */ #endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */ /* yy_get_previous_state - get the state just before the EOB char was reached
*/
#undef YY_NEW_FILE #undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER #undef YY_FLUSH_BUFFER

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -48,7 +48,7 @@ void cmLocalVisualStudio7Generator::Generate()
// for CommandLine= need to repleace quotes with &quot // for CommandLine= need to repleace quotes with &quot
// write out configurations // write out configurations
void cmLocalVisualStudio7Generator::OutputVCProjFile() void cmLocalVisualStudio7Generator::OutputVCProjFile()
{ {
// If not an in source build, then create the output directory // If not an in source build, then create the output directory
if(strcmp(m_Makefile->GetStartOutputDirectory(), if(strcmp(m_Makefile->GetStartOutputDirectory(),
m_Makefile->GetHomeDirectory()) != 0) m_Makefile->GetHomeDirectory()) != 0)
@ -59,7 +59,7 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
m_Makefile->GetStartOutputDirectory()); m_Makefile->GetStartOutputDirectory());
} }
} }
m_LibraryOutputPath = ""; m_LibraryOutputPath = "";
if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
{ {
@ -86,7 +86,7 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
m_ExecutableOutputPath += "/"; m_ExecutableOutputPath += "/";
} }
} }
// Create the VCProj or set of VCProj's for libraries and executables // Create the VCProj or set of VCProj's for libraries and executables
// clear project names // clear project names
@ -97,8 +97,8 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
// generators. It is duplicated in every generator. // generators. It is duplicated in every generator.
// Call TraceVSDependencies on all targets // Call TraceVSDependencies on all targets
cmTargets &tgts = m_Makefile->GetTargets(); cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
// Add a rule to regenerate the build system when the target // Add a rule to regenerate the build system when the target
@ -121,11 +121,11 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
target.TraceVSDependencies(target.GetName(), m_Makefile); target.TraceVSDependencies(target.GetName(), m_Makefile);
} }
} }
// now for all custom commands that are not used directly in a // now for all custom commands that are not used directly in a
// target, add them to all targets in the current directory or // target, add them to all targets in the current directory or
// makefile // makefile
std::vector<cmSourceFile*> & classesmf = m_Makefile->GetSourceFiles(); std::vector<cmSourceFile*> & classesmf = m_Makefile->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classesmf.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classesmf.begin();
i != classesmf.end(); i++) i != classesmf.end(); i++)
{ {
if(cmCustomCommand* cc = (*i)->GetCustomCommand()) if(cmCustomCommand* cc = (*i)->GetCustomCommand())
@ -133,16 +133,16 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
// while we are at it, if it is a .rule file then for visual studio 7 we // while we are at it, if it is a .rule file then for visual studio 7 we
// must generate it so that depend information works correctly // must generate it so that depend information works correctly
if ((*i)->GetSourceExtension() == "rule") if ((*i)->GetSourceExtension() == "rule")
{ {
std::string source = (*i)->GetFullPath(); std::string source = (*i)->GetFullPath();
if(!cmSystemTools::FileExists(source.c_str())) if(!cmSystemTools::FileExists(source.c_str()))
{ {
cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ofstream fout(source.c_str(), std::ofstream fout(source.c_str(),
std::ios::binary | std::ios::out | std::ios::trunc); std::ios::binary | std::ios::out | std::ios::trunc);
#else #else
std::ofstream fout(source.c_str(), std::ofstream fout(source.c_str(),
std::ios::out | std::ios::trunc); std::ios::out | std::ios::trunc);
#endif #endif
if(fout) if(fout)
@ -155,7 +155,7 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
} }
if(!cc->IsUsed()) if(!cc->IsUsed())
{ {
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if ((l->second.GetType() != cmTarget::INSTALL_FILES)
@ -185,7 +185,7 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
} }
} }
#endif #endif
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
@ -241,12 +241,12 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
this->Convert(m_Makefile->GetHomeDirectory(), START_OUTPUT, SHELL, true); this->Convert(m_Makefile->GetHomeDirectory(), START_OUTPUT, SHELL, true);
commandLine.push_back(args); commandLine.push_back(args);
args = "-B"; args = "-B";
args += args +=
this->Convert(m_Makefile->GetHomeOutputDirectory(), this->Convert(m_Makefile->GetHomeOutputDirectory(),
START_OUTPUT, SHELL, true); START_OUTPUT, SHELL, true);
commandLine.push_back(args); commandLine.push_back(args);
std::string configFile = std::string configFile =
m_Makefile->GetRequiredDefinition("CMAKE_ROOT"); m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
configFile += "/Templates/CMakeWindowsSystemConfig.cmake"; configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
std::vector<std::string> listFiles = m_Makefile->GetListFiles(); std::vector<std::string> listFiles = m_Makefile->GetListFiles();
@ -281,11 +281,11 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
} }
void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
const char *libName, const char *libName,
cmTarget &target) cmTarget &target)
{ {
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations(); static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations();
fout << "\t<Configurations>\n"; fout << "\t<Configurations>\n";
for( std::vector<std::string>::iterator i = configs->begin(); for( std::vector<std::string>::iterator i = configs->begin();
@ -310,7 +310,7 @@ struct cmVS7FlagTable
// NOTE: Make sure the longer commandFlag comes FIRST! // NOTE: Make sure the longer commandFlag comes FIRST!
cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
{ {
// option flags (some flags map to the same option) // option flags (some flags map to the same option)
{"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"},
{"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks ", "3"}, {"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks ", "3"},
{"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"},
@ -351,7 +351,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
{"WarningLevel", "W3", "Warning level", "3"}, {"WarningLevel", "W3", "Warning level", "3"},
{"WarningLevel", "W4", "Warning level", "4"}, {"WarningLevel", "W4", "Warning level", "4"},
// boolean flags // boolean flags
{"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"}, {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"},
{"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"}, {"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"},
{"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"}, {"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"},
@ -373,24 +373,24 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
{ {
// option flags (some flags map to the same option) // option flags (some flags map to the same option)
{"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"},
{"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"},
{0,0,0,0 } {0,0,0,0 }
}; };
void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
const char* configName, const char* configName,
const char *libName, const char *libName,
cmTarget &target) cmTarget &target)
{ {
// create a map of xml tags to the values they should have in the output // create a map of xml tags to the values they should have in the output
// for example, "BufferSecurityCheck" = "TRUE" // for example, "BufferSecurityCheck" = "TRUE"
// first fill this table with the values for the configuration // first fill this table with the values for the configuration
@ -415,10 +415,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// 4 == static library // 4 == static library
// 2 == dll // 2 == dll
// 1 == executable // 1 == executable
// 10 == utility // 10 == utility
const char* configType = "10"; const char* configType = "10";
switch(target.GetType()) switch(target.GetType())
{ {
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
configType = "4"; configType = "4";
break; break;
@ -426,16 +426,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
configType = "2"; configType = "2";
break; break;
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
configType = "1"; configType = "1";
break; break;
case cmTarget::UTILITY: case cmTarget::UTILITY:
case cmTarget::GLOBAL_TARGET: case cmTarget::GLOBAL_TARGET:
configType = "10"; configType = "10";
default: default:
break; break;
} }
std::string flags; std::string flags;
if(strcmp(configType, "10") != 0) if(strcmp(configType, "10") != 0)
{ {
@ -447,7 +447,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
return; return;
} }
if(!(strcmp(linkLanguage, "RC") == 0 || strcmp(linkLanguage, "DEF") == 0)) if(!(strcmp(linkLanguage, "RC") == 0 || strcmp(linkLanguage, "DEF") == 0))
{ {
std::string baseFlagVar = "CMAKE_"; std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage; baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS"; baseFlagVar += "_FLAGS";
@ -458,7 +458,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
flags += m_Makefile->GetRequiredDefinition(flagVar.c_str()); flags += m_Makefile->GetRequiredDefinition(flagVar.c_str());
} }
} }
// Add the target-specific flags. // Add the target-specific flags.
if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
{ {
@ -479,7 +479,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
<< "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"; << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
// if -D_UNICODE or /D_UNICODE is found in the flags // if -D_UNICODE or /D_UNICODE is found in the flags
// change the character set to unicode, if not then // change the character set to unicode, if not then
// default to MBCS // default to MBCS
std::string defs = m_Makefile->GetDefineFlags(); std::string defs = m_Makefile->GetDefineFlags();
if(flags.find("D_UNICODE") != flags.npos || if(flags.find("D_UNICODE") != flags.npos ||
defs.find("D_UNICODE") != flags.npos) defs.find("D_UNICODE") != flags.npos)
@ -490,26 +490,26 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
{ {
fout << "\t\t\tCharacterSet=\"2\">\n"; fout << "\t\t\tCharacterSet=\"2\">\n";
} }
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"VCCLCompilerTool\"\n" << "\t\t\t\tName=\"VCCLCompilerTool\"\n"
<< "\t\t\t\tAdditionalOptions=\""; << "\t\t\t\tAdditionalOptions=\"";
// now fill the flagMap from the command line flags, and // now fill the flagMap from the command line flags, and
// if a flag is used, it will be removed from the flags string by // if a flag is used, it will be removed from the flags string by
// this function call // this function call
this->FillFlagMapFromCommandFlags(flagMap, this->FillFlagMapFromCommandFlags(flagMap,
&cmLocalVisualStudio7GeneratorFlagTable[0], &cmLocalVisualStudio7GeneratorFlagTable[0],
flags); flags);
std::string defineFlags = m_Makefile->GetDefineFlags(); std::string defineFlags = m_Makefile->GetDefineFlags();
// now check the define flags for flags other than -D and // now check the define flags for flags other than -D and
// put them in the map, the -D flags will be left in the defineFlags // put them in the map, the -D flags will be left in the defineFlags
// variable as -D is not in the flagMap // variable as -D is not in the flagMap
this->FillFlagMapFromCommandFlags(flagMap, this->FillFlagMapFromCommandFlags(flagMap,
&cmLocalVisualStudio7GeneratorFlagTable[0], &cmLocalVisualStudio7GeneratorFlagTable[0],
defineFlags); defineFlags);
// output remaining flags that were not mapped to anything // output remaining flags that were not mapped to anything
fout << this->EscapeForXML(flags.c_str()).c_str(); fout << this->EscapeForXML(flags.c_str()).c_str();
fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;" fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
<< "\"\n"; << "\"\n";
fout << "\t\t\t\tAdditionalIncludeDirectories=\""; fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
std::vector<std::string> includes; std::vector<std::string> includes;
@ -560,9 +560,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
std::map<cmStdString, cmStdString>::iterator mi = flagMap.find("DebugInformationFormat"); std::map<cmStdString, cmStdString>::iterator mi = flagMap.find("DebugInformationFormat");
if(mi != flagMap.end() && mi->second != "1") if(mi != flagMap.end() && mi->second != "1")
{ {
fout << "\t\t\t\tProgramDatabaseFileName=\"" fout << "\t\t\t\tProgramDatabaseFileName=\""
<< m_LibraryOutputPath << m_LibraryOutputPath
<< "$(OutDir)/" << libName << ".pdb\"\n"; << "$(OutDir)/" << libName << ".pdb\"\n";
} }
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
@ -574,7 +574,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
fout << ipath << ";"; fout << ipath << ";";
} }
// add the -D flags to the RC tool // add the -D flags to the RC tool
fout << "\"\n" fout << "\"\n"
<< "\t\t\t\tPreprocessorDefinitions=\""; << "\t\t\t\tPreprocessorDefinitions=\"";
this->OutputDefineFlags(defineFlags.c_str(), fout); this->OutputDefineFlags(defineFlags.c_str(), fout);
@ -615,7 +615,7 @@ void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags(
option += flagTable->commandFlag; option += flagTable->commandFlag;
while(flags.find(option) != flags.npos) while(flags.find(option) != flags.npos)
{ {
// replace the flag // replace the flag
cmSystemTools::ReplaceString(flags, option.c_str(), ""); cmSystemTools::ReplaceString(flags, option.c_str(), "");
// now put value into flag map // now put value into flag map
flagMap[flagTable->IDEName] = flagTable->value; flagMap[flagTable->IDEName] = flagTable->value;
@ -624,7 +624,7 @@ void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags(
option[0] = '/'; option[0] = '/';
while(flags.find(option) != flags.npos) while(flags.find(option) != flags.npos)
{ {
// replace the flag // replace the flag
cmSystemTools::ReplaceString(flags, option.c_str(), ""); cmSystemTools::ReplaceString(flags, option.c_str(), "");
// now put value into flag map // now put value into flag map
flagMap[flagTable->IDEName] = flagTable->value; flagMap[flagTable->IDEName] = flagTable->value;
@ -683,7 +683,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") + extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") +
std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName); std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
} }
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
if(targetLinkFlags) if(targetLinkFlags)
{ {
@ -693,7 +693,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
std::map<cmStdString, cmStdString> flagMap; std::map<cmStdString, cmStdString> flagMap;
this-> this->
FillFlagMapFromCommandFlags(flagMap, FillFlagMapFromCommandFlags(flagMap,
&cmLocalVisualStudio7GeneratorLinkFlagTable[0], &cmLocalVisualStudio7GeneratorLinkFlagTable[0],
extraLinkOptions); extraLinkOptions);
switch(target.GetType()) switch(target.GetType())
@ -708,7 +708,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{ {
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
} }
fout << "\t\t\t\tOutputFile=\"" fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(libpath.c_str()) << ".\"/>\n"; << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << ".\"/>\n";
break; break;
} }
@ -732,7 +732,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad. // libraries which may be set by the user to something bad.
fout << "\"\n" fout << "\"\n"
<< "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< m_Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES") << m_Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES")
<< " "; << " ";
this->OutputLibraries(fout, linkLibs); this->OutputLibraries(fout, linkLibs);
fout << "\"\n"; fout << "\"\n";
@ -740,7 +740,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
temp += configName; temp += configName;
temp += "/"; temp += "/";
temp += targetFullName; temp += targetFullName;
fout << "\t\t\t\tOutputFile=\"" fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin(); for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
i != flagMap.end(); ++i) i != flagMap.end(); ++i)
@ -755,7 +755,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
temp += "$(OutDir)/"; temp += "$(OutDir)/";
temp += libName; temp += libName;
temp += ".pdb"; temp += ".pdb";
fout << "\t\t\t\tProgramDatabaseFile=\"" << fout << "\t\t\t\tProgramDatabaseFile=\"" <<
this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
if(strcmp(configName, "Debug") == 0 if(strcmp(configName, "Debug") == 0
|| strcmp(configName, "RelWithDebInfo") == 0) || strcmp(configName, "RelWithDebInfo") == 0)
@ -794,7 +794,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"VCLinkerTool\"\n" << "\t\t\t\tName=\"VCLinkerTool\"\n"
<< "\t\t\t\tAdditionalOptions=\"/MACHINE:I386"; << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
if(extraLinkOptions.size()) if(extraLinkOptions.size())
{ {
fout << " " << cmLocalVisualStudio7Generator::EscapeForXML( fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
@ -804,7 +804,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad. // libraries which may be set by the user to something bad.
fout << "\"\n" fout << "\"\n"
<< "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< m_Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES") << m_Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES")
<< " "; << " ";
this->OutputLibraries(fout, linkLibs); this->OutputLibraries(fout, linkLibs);
fout << "\"\n"; fout << "\"\n";
@ -821,9 +821,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t\tAdditionalLibraryDirectories=\""; fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
this->OutputLibraryDirectories(fout, linkDirs); this->OutputLibraryDirectories(fout, linkDirs);
fout << "\"\n"; fout << "\"\n";
fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath
<< "$(OutDir)\\" << libName << ".pdb\"\n"; << "$(OutDir)\\" << libName << ".pdb\"\n";
if(strcmp(configName, "Debug") == 0 if(strcmp(configName, "Debug") == 0
|| strcmp(configName, "RelWithDebInfo") == 0) || strcmp(configName, "RelWithDebInfo") == 0)
{ {
fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"; fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
@ -833,10 +833,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t\tSubSystem=\"2\"\n"; fout << "\t\t\t\tSubSystem=\"2\"\n";
} }
else else
{ {
fout << "\t\t\t\tSubSystem=\"1\"\n"; fout << "\t\t\t\tSubSystem=\"1\"\n";
} }
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error("CMake can not determine linker language for target:",
@ -864,9 +864,9 @@ void cmLocalVisualStudio7Generator::OutputModuleDefinitionFile(std::ostream& fou
cmTarget &target) cmTarget &target)
{ {
std::vector<cmSourceFile*> const& classes = target.GetSourceFiles(); std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF") if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
{ {
fout << "\t\t\t\tModuleDefinitionFile=\"" fout << "\t\t\t\tModuleDefinitionFile=\""
@ -875,7 +875,7 @@ void cmLocalVisualStudio7Generator::OutputModuleDefinitionFile(std::ostream& fou
return; return;
} }
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -951,29 +951,29 @@ void cmLocalVisualStudio7Generator::OutputDefineFlags(const char* flags,
{ {
pos = defs.find("-D", nextpos); pos = defs.find("-D", nextpos);
} }
} }
} }
void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
const char *libName, const char *libName,
cmTarget &target) cmTarget &target)
{ {
// get the configurations // get the configurations
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(m_GlobalGenerator)->GetConfigurations(); (m_GlobalGenerator)->GetConfigurations();
// trace the visual studio dependencies // trace the visual studio dependencies
std::string name = libName; std::string name = libName;
name += ".vcproj.cmake"; name += ".vcproj.cmake";
// We may be modifying the source groups temporarily, so make a copy. // We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> & classes = target.GetSourceFiles(); std::vector<cmSourceFile*> & classes = target.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
// Add the file to the list of sources. // Add the file to the list of sources.
@ -982,11 +982,11 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
{ {
m_ModuleDefinitionFile = (*i)->GetFullPath(); m_ModuleDefinitionFile = (*i)->GetFullPath();
} }
cmSourceGroup& sourceGroup = cmSourceGroup& sourceGroup =
m_Makefile->FindSourceGroup(source.c_str(), sourceGroups); m_Makefile->FindSourceGroup(source.c_str(), sourceGroups);
sourceGroup.AssignSource(*i); sourceGroup.AssignSource(*i);
} }
// open the project // open the project
this->WriteProjectStart(fout, libName, target, sourceGroups); this->WriteProjectStart(fout, libName, target, sourceGroups);
// write the configuration information // write the configuration information
@ -1003,7 +1003,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
} }
//} //}
fout << "\t</Files>\n"; fout << "\t</Files>\n";
// Write the VCProj file's footer. // Write the VCProj file's footer.
@ -1012,21 +1012,21 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector<std::string> *configs) void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector<std::string> *configs)
{ {
const std::vector<const cmSourceFile *> &sourceFiles = const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles(); sg->GetSourceFiles();
// If the group is empty, don't write it at all. // If the group is empty, don't write it at all.
if(sourceFiles.empty() && sg->GetGroupChildren().empty()) if(sourceFiles.empty() && sg->GetGroupChildren().empty())
{ {
return; return;
} }
// If the group has a name, write the header. // If the group has a name, write the header.
std::string name = sg->GetName(); std::string name = sg->GetName();
if(name != "") if(name != "")
{ {
this->WriteVCProjBeginGroup(fout, name.c_str(), ""); this->WriteVCProjBeginGroup(fout, name.c_str(), "");
} }
// Loop through each source in the source group. // Loop through each source in the source group.
for(std::vector<const cmSourceFile *>::const_iterator sf = for(std::vector<const cmSourceFile *>::const_iterator sf =
sourceFiles.begin(); sf != sourceFiles.end(); ++sf) sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
@ -1042,8 +1042,8 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
{ {
compileFlags += " "; compileFlags += " ";
compileFlags += cflags; compileFlags += cflags;
} }
const char* lang = const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0) if(lang && strcmp(lang, "CXX") == 0)
{ {
@ -1104,7 +1104,7 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
{ {
aCompilerTool = "VCCustomBuildTool"; aCompilerTool = "VCCustomBuildTool";
} }
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
{ {
fout << "\t\t\t\t<FileConfiguration\n" fout << "\t\t\t\t<FileConfiguration\n"
@ -1128,20 +1128,20 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
fout << "\t\t\t</File>\n"; fout << "\t\t\t</File>\n";
} }
} }
std::vector<cmSourceGroup> children = sg->GetGroupChildren(); std::vector<cmSourceGroup> children = sg->GetGroupChildren();
for(unsigned int i=0;i<children.size();++i) for(unsigned int i=0;i<children.size();++i)
{ {
this->WriteGroup(&children[i], target, fout, libName, configs); this->WriteGroup(&children[i], target, fout, libName, configs);
} }
// If the group has a name, write the footer. // If the group has a name, write the footer.
if(name != "") if(name != "")
{ {
this->WriteVCProjEndGroup(fout); this->WriteVCProjEndGroup(fout);
} }
} }
void cmLocalVisualStudio7Generator:: void cmLocalVisualStudio7Generator::
WriteCustomRule(std::ostream& fout, WriteCustomRule(std::ostream& fout,
@ -1153,7 +1153,7 @@ WriteCustomRule(std::ostream& fout,
const char* compileFlags) const char* compileFlags)
{ {
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations(); static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations();
for(i = configs->begin(); i != configs->end(); ++i) for(i = configs->begin(); i != configs->end(); ++i)
{ {
@ -1190,7 +1190,7 @@ WriteCustomRule(std::ostream& fout,
{ {
fout << source << "_force"; fout << source << "_force";
} }
// Write a rule for the output generated by this command. // Write a rule for the output generated by this command.
fout << this->ConvertToXMLOutputPathSingle(output); fout << this->ConvertToXMLOutputPathSingle(output);
fout << "\"/>\n"; fout << "\"/>\n";
@ -1199,7 +1199,7 @@ WriteCustomRule(std::ostream& fout,
} }
void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
const char* group, const char* group,
const char* ) const char* )
{ {
@ -1217,19 +1217,19 @@ void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
// look for custom rules on a target and collect them together // look for custom rules on a target and collect them together
void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout, void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
cmTarget &target, cmTarget &target,
const char * /*libName*/) const char * /*libName*/)
{ {
if (target.GetType() > cmTarget::GLOBAL_TARGET) if (target.GetType() > cmTarget::GLOBAL_TARGET)
{ {
return; return;
} }
// add the pre build rules // add the pre build rules
fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\""; fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"";
bool init = false; bool init = false;
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
target.GetPreBuildCommands().begin(); target.GetPreBuildCommands().begin();
cr != target.GetPreBuildCommands().end(); ++cr) cr != target.GetPreBuildCommands().end(); ++cr)
{ {
if(!init) if(!init)
@ -1249,8 +1249,8 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
// add the pre Link rules // add the pre Link rules
fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\""; fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"";
init = false; init = false;
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
target.GetPreLinkCommands().begin(); target.GetPreLinkCommands().begin();
cr != target.GetPreLinkCommands().end(); ++cr) cr != target.GetPreLinkCommands().end(); ++cr)
{ {
if(!init) if(!init)
@ -1267,12 +1267,12 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
fout << "\""; fout << "\"";
} }
fout << "/>\n"; fout << "/>\n";
// add the PostBuild rules // add the PostBuild rules
fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\""; fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
init = false; init = false;
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
target.GetPostBuildCommands().begin(); target.GetPostBuildCommands().begin();
cr != target.GetPostBuildCommands().end(); ++cr) cr != target.GetPostBuildCommands().end(); ++cr)
{ {
if(!init) if(!init)
@ -1290,10 +1290,10 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
fout << "/>\n"; fout << "/>\n";
} }
void void
cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
const char *libName, const char *libName,
cmTarget & target, cmTarget & target,
std::vector<cmSourceGroup> &) std::vector<cmSourceGroup> &)
{ {
fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
@ -1303,7 +1303,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
{ {
fout << "\tVersion=\"7.10\"\n"; fout << "\tVersion=\"7.10\"\n";
} }
else else
{ {
if (m_Version == 8) if (m_Version == 8)
{ {
@ -1384,7 +1384,7 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
cmLocalGenerator::ConfigureFinalPass(); cmLocalGenerator::ConfigureFinalPass();
cmTargets &tgts = m_Makefile->GetTargets(); cmTargets &tgts = m_Makefile->GetTargets();
cmGlobalVisualStudio7Generator* gg = cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator); static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator);
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{ {
@ -1397,10 +1397,10 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
} }
else else
{ {
gg->CreateGUID(l->first.c_str()); gg->CreateGUID(l->first.c_str());
} }
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -23,14 +23,14 @@ class cmMacroHelperCommand : public cmCommand
{ {
public: public:
cmMacroHelperCommand() {} cmMacroHelperCommand() {}
///! clean up any memory allocated by the macro ///! clean up any memory allocated by the macro
~cmMacroHelperCommand() {}; ~cmMacroHelperCommand() {};
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmMacroHelperCommand *newC = new cmMacroHelperCommand; cmMacroHelperCommand *newC = new cmMacroHelperCommand;
// we must copy when we clone // we must copy when we clone
@ -38,7 +38,7 @@ public:
newC->m_Functions = this->m_Functions; newC->m_Functions = this->m_Functions;
return newC; return newC;
} }
/** /**
* This determines if the command is invoked when in script mode. * This determines if the command is invoked when in script mode.
*/ */
@ -51,22 +51,22 @@ public:
virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args); virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args);
virtual bool InitialPass(std::vector<std::string> const&) { return false; }; virtual bool InitialPass(std::vector<std::string> const&) { return false; };
/** /**
* The name of the command as specified in CMakeList.txt. * The name of the command as specified in CMakeList.txt.
*/ */
virtual const char* GetName() { return this->m_Args[0].c_str(); } virtual const char* GetName() { return this->m_Args[0].c_str(); }
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
std::string docs = "Macro named: "; std::string docs = "Macro named: ";
docs += this->GetName(); docs += this->GetName();
return docs.c_str(); return docs.c_str();
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -74,7 +74,7 @@ public:
{ {
return this->GetTerseDocumentation(); return this->GetTerseDocumentation();
} }
cmTypeMacro(cmMacroHelperCommand, cmCommand); cmTypeMacro(cmMacroHelperCommand, cmCommand);
std::vector<std::string> m_Args; std::vector<std::string> m_Args;
@ -88,7 +88,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
// Expand the argument list to the macro. // Expand the argument list to the macro.
std::vector<std::string> expandedArgs; std::vector<std::string> expandedArgs;
m_Makefile->ExpandArguments(args, expandedArgs); m_Makefile->ExpandArguments(args, expandedArgs);
std::string tmps; std::string tmps;
cmListFileArgument arg; cmListFileArgument arg;
std::string variable; std::string variable;
@ -97,24 +97,24 @@ bool cmMacroHelperCommand::InvokeInitialPass
// required by the signature // required by the signature
if (expandedArgs.size() < m_Args.size() - 1) if (expandedArgs.size() < m_Args.size() - 1)
{ {
std::string errorMsg = std::string errorMsg =
"Macro invoked with incorrect arguments for macro named: "; "Macro invoked with incorrect arguments for macro named: ";
errorMsg += m_Args[0]; errorMsg += m_Args[0];
this->SetError(errorMsg.c_str()); this->SetError(errorMsg.c_str());
return false; return false;
} }
// set the value of argc // set the value of argc
cmOStringStream argcDefStream; cmOStringStream argcDefStream;
argcDefStream << expandedArgs.size(); argcDefStream << expandedArgs.size();
std::string argcDef = argcDefStream.str(); std::string argcDef = argcDefStream.str();
// declare varuiables for ARGV ARGN but do not compute until needed // declare varuiables for ARGV ARGN but do not compute until needed
std::string argvDef; std::string argvDef;
std::string argnDef; std::string argnDef;
bool argnDefInitialized = false; bool argnDefInitialized = false;
bool argvDefInitialized = false; bool argvDefInitialized = false;
// Invoke all the functions that were collected in the block. // Invoke all the functions that were collected in the block.
cmListFileFunction newLFF; cmListFileFunction newLFF;
// for each function // for each function
@ -127,15 +127,15 @@ bool cmMacroHelperCommand::InvokeInitialPass
newLFF.m_FilePath = m_Functions[c].m_FilePath; newLFF.m_FilePath = m_Functions[c].m_FilePath;
newLFF.m_Line = m_Functions[c].m_Line; newLFF.m_Line = m_Functions[c].m_Line;
const char* def = const char* def =
m_Makefile->GetDefinition("CMAKE_MACRO_REPORT_DEFINITION_LOCATION"); m_Makefile->GetDefinition("CMAKE_MACRO_REPORT_DEFINITION_LOCATION");
bool macroReportLocation = false; bool macroReportLocation = false;
if(def && !cmSystemTools::IsOff(def)) if(def && !cmSystemTools::IsOff(def))
{ {
macroReportLocation = true; macroReportLocation = true;
} }
// for each argument of the current function // for each argument of the current function
for (std::vector<cmListFileArgument>::const_iterator k = for (std::vector<cmListFileArgument>::const_iterator k =
m_Functions[c].m_Arguments.begin(); m_Functions[c].m_Arguments.begin();
k != m_Functions[c].m_Arguments.end(); ++k) k != m_Functions[c].m_Arguments.end(); ++k)
{ {
@ -145,13 +145,13 @@ bool cmMacroHelperCommand::InvokeInitialPass
{ {
variable = "${"; variable = "${";
variable += m_Args[j]; variable += m_Args[j];
variable += "}"; variable += "}";
cmSystemTools::ReplaceString(tmps, variable.c_str(), cmSystemTools::ReplaceString(tmps, variable.c_str(),
expandedArgs[j-1].c_str()); expandedArgs[j-1].c_str());
} }
// replace argc // replace argc
cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
// repleace ARGN // repleace ARGN
if (tmps.find("${ARGN}") != std::string::npos) if (tmps.find("${ARGN}") != std::string::npos)
{ {
@ -175,13 +175,13 @@ bool cmMacroHelperCommand::InvokeInitialPass
} }
cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
} }
// if the current argument of the current function has ${ARGV in it // if the current argument of the current function has ${ARGV in it
// then try replacing ARGV values // then try replacing ARGV values
if (tmps.find("${ARGV") != std::string::npos) if (tmps.find("${ARGV") != std::string::npos)
{ {
char argvName[60]; char argvName[60];
// repleace ARGV, compute it only once // repleace ARGV, compute it only once
if (!argvDefInitialized) if (!argvDefInitialized)
{ {
@ -197,7 +197,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
argvDefInitialized = true; argvDefInitialized = true;
} }
cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
// also replace the ARGV1 ARGV2 ... etc // also replace the ARGV1 ARGV2 ... etc
for (unsigned int t = 0; t < expandedArgs.size(); ++t) for (unsigned int t = 0; t < expandedArgs.size(); ++t)
{ {
@ -206,7 +206,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
expandedArgs[t].c_str()); expandedArgs[t].c_str());
} }
} }
arg.Value = tmps; arg.Value = tmps;
arg.Quoted = k->Quoted; arg.Quoted = k->Quoted;
if(macroReportLocation) if(macroReportLocation)
@ -248,7 +248,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
} }
bool cmMacroFunctionBlocker:: bool cmMacroFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
{ {
// record commands until we hit the ENDMACRO // record commands until we hit the ENDMACRO
// at the ENDMACRO call we shift gears and start looking for invocations // at the ENDMACRO call we shift gears and start looking for invocations
@ -267,30 +267,31 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
} }
name += " )"; name += " )";
mf.AddMacro(m_Args[0].c_str(), name.c_str()); mf.AddMacro(m_Args[0].c_str(), name.c_str());
// create a new command and add it to cmake // create a new command and add it to cmake
cmMacroHelperCommand *f = new cmMacroHelperCommand(); cmMacroHelperCommand *f = new cmMacroHelperCommand();
f->m_Args = this->m_Args; f->m_Args = this->m_Args;
f->m_Functions = this->m_Functions; f->m_Functions = this->m_Functions;
std::string newName = "_" + this->m_Args[0]; std::string newName = "_" + this->m_Args[0];
mf.GetCMakeInstance()->RenameCommand(this->m_Args[0].c_str(), newName.c_str()); mf.GetCMakeInstance()->RenameCommand(
this->m_Args[0].c_str(), newName.c_str());
mf.AddCommand(f); mf.AddCommand(f);
// remove the function blocker now that the macro is defined // remove the function blocker now that the macro is defined
mf.RemoveFunctionBlocker(lff); mf.RemoveFunctionBlocker(lff);
return true; return true;
} }
} }
// if it wasn't an endmacro and we are not executing then we must be // if it wasn't an endmacro and we are not executing then we must be
// recording // recording
m_Functions.push_back(lff); m_Functions.push_back(lff);
return true; return true;
} }
bool cmMacroFunctionBlocker:: bool cmMacroFunctionBlocker::
ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf) ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
{ {
if(cmSystemTools::LowerCase(lff.m_Name) == "endmacro") if(cmSystemTools::LowerCase(lff.m_Name) == "endmacro")
{ {
@ -305,12 +306,14 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
} }
void cmMacroFunctionBlocker:: void cmMacroFunctionBlocker::
ScopeEnded(cmMakefile &mf) ScopeEnded(cmMakefile &mf)
{ {
// macros should end with an EndMacro // macros should end with an EndMacro
cmSystemTools::Error("The end of a CMakeLists file was reached with a MACRO statement that was not closed properly. Within the directory: ", cmSystemTools::Error(
mf.GetCurrentDirectory(), " with macro ", "The end of a CMakeLists file was reached with a MACRO statement that "
m_Args[0].c_str()); "was not closed properly. Within the directory: ",
mf.GetCurrentDirectory(), " with macro ",
m_Args[0].c_str());
} }
bool cmMacroCommand::InitialPass(std::vector<std::string> const& args) bool cmMacroCommand::InitialPass(std::vector<std::string> const& args)
@ -320,16 +323,16 @@ bool cmMacroCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments"); this->SetError("called with incorrect number of arguments");
return false; return false;
} }
// create a function blocker // create a function blocker
cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker(); cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker();
for(std::vector<std::string>::const_iterator j = args.begin(); for(std::vector<std::string>::const_iterator j = args.begin();
j != args.end(); ++j) j != args.end(); ++j)
{ {
f->m_Args.push_back(*j); f->m_Args.push_back(*j);
} }
m_Makefile->AddFunctionBlocker(f); m_Makefile->AddFunctionBlocker(f);
return true; return true;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -23,7 +23,7 @@
/** \class cmMacroFunctionBlocker /** \class cmMacroFunctionBlocker
* \brief subclass of function blocker * \brief subclass of function blocker
* *
* *
*/ */
class cmMacroFunctionBlocker : public cmFunctionBlocker class cmMacroFunctionBlocker : public cmFunctionBlocker
{ {
@ -33,7 +33,7 @@ public:
virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile &mf); virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile &mf);
virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf); virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
virtual void ScopeEnded(cmMakefile &mf); virtual void ScopeEnded(cmMakefile &mf);
std::vector<std::string> m_Args; std::vector<std::string> m_Args;
std::vector<cmListFileFunction> m_Functions; std::vector<cmListFileFunction> m_Functions;
}; };
@ -49,7 +49,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
return new cmMacroCommand; return new cmMacroCommand;
} }
@ -73,11 +73,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Start recording a macro for later invocation as a command."; return "Start recording a macro for later invocation as a command.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -93,8 +93,8 @@ public:
"arg1 arg2 arg3 (...). Commands listed after MACRO, " "arg1 arg2 arg3 (...). Commands listed after MACRO, "
"but before the matching ENDMACRO, are not invoked until the macro " "but before the matching ENDMACRO, are not invoked until the macro "
"is invoked. When it is invoked, the commands recorded in the " "is invoked. When it is invoked, the commands recorded in the "
"macro are first modified by replacing formal parameters (${arg1}) with " "macro are first modified by replacing formal parameters (${arg1}) "
"the arguments passed, and then invoked as normal commands. In " "with the arguments passed, and then invoked as normal commands. In "
"addition to referencing the formal parameters you can reference " "addition to referencing the formal parameters you can reference "
"the variable ARGC which will be set to the number of arguments " "the variable ARGC which will be set to the number of arguments "
"passed into the function as well as ARGV0 ARGV1 ARGV2 ... which " "passed into the function as well as ARGV0 ARGV1 ARGV2 ... which "
@ -103,7 +103,7 @@ public:
"ARGV holds the list of all arguments given to the macro and ARGN " "ARGV holds the list of all arguments given to the macro and ARGN "
"holds the list of argument pass the last expected argument."; "holds the list of argument pass the last expected argument.";
} }
cmTypeMacro(cmMacroCommand, cmCommand); cmTypeMacro(cmMacroCommand, cmCommand);
}; };

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -36,7 +36,7 @@ cmMakeDepend::cmMakeDepend()
cmMakeDepend::~cmMakeDepend() cmMakeDepend::~cmMakeDepend()
{ {
for(DependInformationMap::iterator i = m_DependInformationMap.begin(); for(DependInformationMap::iterator i = m_DependInformationMap.begin();
i != m_DependInformationMap.end(); ++i) i != m_DependInformationMap.end(); ++i)
{ {
@ -58,7 +58,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
m_Makefile->m_IncludeFileRegularExpression.c_str()); m_Makefile->m_IncludeFileRegularExpression.c_str());
m_ComplainFileRegularExpression.compile( m_ComplainFileRegularExpression.compile(
m_Makefile->m_ComplainFileRegularExpression.c_str()); m_Makefile->m_ComplainFileRegularExpression.c_str());
// Now extract any include paths from the makefile flags // Now extract any include paths from the makefile flags
const std::vector<std::string>& includes = const std::vector<std::string>& includes =
m_Makefile->GetIncludeDirectories(); m_Makefile->GetIncludeDirectories();
@ -94,7 +94,8 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
const char* path = info->m_FullPath.c_str(); const char* path = info->m_FullPath.c_str();
if(!path) if(!path)
{ {
cmSystemTools::Error("Attempt to find dependencies for file without path!"); cmSystemTools::Error(
"Attempt to find dependencies for file without path!");
return; return;
} }
@ -108,7 +109,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
found = true; found = true;
} }
// See if the cmSourceFile for it has any files specified as // See if the cmSourceFile for it has any files specified as
// dependency hints. // dependency hints.
if(info->m_cmSourceFile != 0) if(info->m_cmSourceFile != 0)
@ -123,12 +124,12 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
// Dependency hints have been given. Use them to begin the // Dependency hints have been given. Use them to begin the
// recursion. // recursion.
for(std::vector<std::string>::const_iterator file = for(std::vector<std::string>::const_iterator file =
cFile.GetDepends().begin(); file != cFile.GetDepends().end(); cFile.GetDepends().begin(); file != cFile.GetDepends().end();
++file) ++file)
{ {
this->AddDependency(info, file->c_str()); this->AddDependency(info, file->c_str());
} }
// Found dependency information. We are done. // Found dependency information. We are done.
found = true; found = true;
} }
@ -137,8 +138,9 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
if(!found) if(!found)
{ {
// Try to find the file amongst the sources // Try to find the file amongst the sources
cmSourceFile *srcFile = cmSourceFile *srcFile =
m_Makefile->GetSource(cmSystemTools::GetFilenameWithoutExtension(path).c_str()); m_Makefile->GetSource(
cmSystemTools::GetFilenameWithoutExtension(path).c_str());
if (srcFile) if (srcFile)
{ {
if (srcFile->GetFullPath() == path) if (srcFile->GetFullPath() == path)
@ -148,7 +150,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
else else
{ {
//try to guess which include path to use //try to guess which include path to use
for(std::vector<std::string>::iterator t = for(std::vector<std::string>::iterator t =
m_IncludeDirectories.begin(); m_IncludeDirectories.begin();
t != m_IncludeDirectories.end(); ++t) t != m_IncludeDirectories.end(); ++t)
{ {
@ -161,14 +163,14 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
if (srcFile->GetFullPath() == incpath) if (srcFile->GetFullPath() == incpath)
{ {
// set the path to the guessed path // set the path to the guessed path
info->m_FullPath = incpath; info->m_FullPath = incpath;
found=true; found=true;
} }
} }
} }
} }
} }
if(!found) if(!found)
{ {
// Couldn't find any dependency information. // Couldn't find any dependency information.
@ -189,7 +191,8 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
// #include directives // #include directives
void cmMakeDepend::DependWalk(cmDependInformation* info) void cmMakeDepend::DependWalk(cmDependInformation* info)
{ {
cmsys::RegularExpression includeLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); cmsys::RegularExpression includeLine(
"^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
std::ifstream fin(info->m_FullPath.c_str()); std::ifstream fin(info->m_FullPath.c_str());
if(!fin) if(!fin)
{ {
@ -218,7 +221,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info)
} }
continue; continue;
} }
// Add this file and all its dependencies. // Add this file and all its dependencies.
this->AddDependency(info, includeFile.c_str()); this->AddDependency(info, includeFile.c_str());
} }
@ -228,7 +231,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info)
void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file) void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file)
{ {
cmDependInformation* dependInfo = cmDependInformation* dependInfo =
this->GetDependInformation(file, info->m_PathOnly.c_str()); this->GetDependInformation(file, info->m_PathOnly.c_str());
this->GenerateDependInformation(dependInfo); this->GenerateDependInformation(dependInfo);
info->AddDependencies(dependInfo); info->AddDependencies(dependInfo);
@ -239,7 +242,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file,
{ {
// Get the full path for the file so that lookup is unambiguous. // Get the full path for the file so that lookup is unambiguous.
std::string fullPath = this->FullPath(file, extraPath); std::string fullPath = this->FullPath(file, extraPath);
// Try to find the file's instance of cmDependInformation. // Try to find the file's instance of cmDependInformation.
DependInformationMap::const_iterator result = DependInformationMap::const_iterator result =
m_DependInformationMap.find(fullPath); m_DependInformationMap.find(fullPath);
@ -265,11 +268,11 @@ void cmMakeDepend::GenerateMakefileDependencies()
{ {
// Now create cmDependInformation objects for files in the directory // Now create cmDependInformation objects for files in the directory
cmTargets &tgts = m_Makefile->GetTargets(); cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
const std::vector<cmSourceFile*> &classes = l->second.GetSourceFiles(); const std::vector<cmSourceFile*> &classes = l->second.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY"))
@ -297,7 +300,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
{ {
m = m_DirectoryToFileToPathMap.find(""); m = m_DirectoryToFileToPathMap.find("");
} }
if(m != m_DirectoryToFileToPathMap.end()) if(m != m_DirectoryToFileToPathMap.end())
{ {
FileToPathMap& map = m->second; FileToPathMap& map = m->second;
@ -314,7 +317,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
return fp; return fp;
} }
for(std::vector<std::string>::iterator i = m_IncludeDirectories.begin(); for(std::vector<std::string>::iterator i = m_IncludeDirectories.begin();
i != m_IncludeDirectories.end(); ++i) i != m_IncludeDirectories.end(); ++i)
{ {
@ -349,7 +352,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
return fp; return fp;
} }
} }
// Couldn't find the file. // Couldn't find the file.
return std::string(fname); return std::string(fname);
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -78,7 +78,7 @@
#include <memory> // auto_ptr #include <memory> // auto_ptr
void cmNeedBackwardsCompatibility(const std::string& variable, void cmNeedBackwardsCompatibility(const std::string& variable,
int access_type, void* ) int access_type, void* )
{ {
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
@ -86,12 +86,14 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
{ {
std::string message = "An attempt was made to access a variable: "; std::string message = "An attempt was made to access a variable: ";
message += variable; message += variable;
message += " that has not been defined. Some variables were always defined " message +=
"by CMake in versions prior to 1.6. To fix this you might need to set the " " that has not been defined. Some variables were always defined "
"cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If you are " "by CMake in versions prior to 1.6. To fix this you might need to set "
"writing a CMakeList file, (or have already set " "the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If "
"CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need to " "you are writing a CMakeList file, (or have already set "
"include a CMake module to test for the feature this variable defines."; "CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need "
"to include a CMake module to test for the feature this variable "
"defines.";
cmSystemTools::Error(message.c_str()); cmSystemTools::Error(message.c_str());
} }
#else #else
@ -105,7 +107,7 @@ cmake::cmake()
m_DebugTryCompile = false; m_DebugTryCompile = false;
m_ClearBuildSystem = false; m_ClearBuildSystem = false;
m_FileComparison = new cmFileTimeComparison; m_FileComparison = new cmFileTimeComparison;
#ifdef __APPLE__ #ifdef __APPLE__
struct rlimit rlp; struct rlimit rlp;
if(!getrlimit(RLIMIT_STACK, &rlp)) if(!getrlimit(RLIMIT_STACK, &rlp))
@ -126,8 +128,8 @@ cmake::cmake()
if(getenv("MAKEFLAGS")) if(getenv("MAKEFLAGS"))
{ {
cmSystemTools::PutEnv("MAKEFLAGS="); cmSystemTools::PutEnv("MAKEFLAGS=");
} }
m_Verbose = false; m_Verbose = false;
m_InTryCompile = false; m_InTryCompile = false;
m_CacheManager = new cmCacheManager; m_CacheManager = new cmCacheManager;
@ -202,7 +204,7 @@ bool cmake::CommandExists(const char* name) const
return (m_Commands.find(sName) != m_Commands.end()); return (m_Commands.find(sName) != m_Commands.end());
} }
cmCommand *cmake::GetCommand(const char *name) cmCommand *cmake::GetCommand(const char *name)
{ {
cmCommand* rm = 0; cmCommand* rm = 0;
std::string sName = cmSystemTools::LowerCase(name); std::string sName = cmSystemTools::LowerCase(name);
@ -252,7 +254,7 @@ void cmake::AddCommand(cmCommand* wg)
// Parse the args // Parse the args
bool cmake::SetCacheArgs(const std::vector<std::string>& args) bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{ {
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
{ {
std::string arg = args[i]; std::string arg = args[i];
@ -278,7 +280,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
<< "Should be: VAR:type=value\n"; << "Should be: VAR:type=value\n";
cmSystemTools::Error("No cmake scrpt provided."); cmSystemTools::Error("No cmake scrpt provided.");
return false; return false;
} }
} }
else if(arg.find("-C",0) == 0) else if(arg.find("-C",0) == 0)
{ {
@ -311,7 +313,7 @@ void cmake::ReadListFile(const char *path)
// if a generator was not yet created, temporarily create one // if a generator was not yet created, temporarily create one
cmGlobalGenerator *gg = this->GetGlobalGenerator(); cmGlobalGenerator *gg = this->GetGlobalGenerator();
bool created = false; bool created = false;
// if a generator was not specified use a generic one // if a generator was not specified use a generic one
if (!gg) if (!gg)
{ {
@ -338,7 +340,7 @@ void cmake::ReadListFile(const char *path)
std::cerr << "Error processing file:" << path << "\n"; std::cerr << "Error processing file:" << path << "\n";
} }
} }
// free generic one if generated // free generic one if generated
if (created) if (created)
{ {
@ -422,7 +424,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
{ {
value = args[++i]; value = args[++i];
} }
cmGlobalGenerator* gen = cmGlobalGenerator* gen =
this->CreateGlobalGenerator(value.c_str()); this->CreateGlobalGenerator(value.c_str());
if(!gen) if(!gen)
{ {
@ -520,28 +522,29 @@ void cmake::SetDirectoriesFromFile(const char* arg)
{ {
cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager* cachem = this->GetCacheManager();
cmCacheManager::CacheIterator it = cachem->NewIterator(); cmCacheManager::CacheIterator it = cachem->NewIterator();
if(cachem->LoadCache(cachePath.c_str()) && it.Find("CMAKE_HOME_DIRECTORY")) if(cachem->LoadCache(cachePath.c_str()) &&
it.Find("CMAKE_HOME_DIRECTORY"))
{ {
this->SetHomeOutputDirectory(cachePath.c_str()); this->SetHomeOutputDirectory(cachePath.c_str());
this->SetStartOutputDirectory(cachePath.c_str()); this->SetStartOutputDirectory(cachePath.c_str());
this->SetHomeDirectory(it.GetValue()); this->SetHomeDirectory(it.GetValue());
this->SetStartDirectory(it.GetValue()); this->SetStartDirectory(it.GetValue());
return; return;
} }
} }
// If there is a CMakeLists.txt file, use it as the source tree. // If there is a CMakeLists.txt file, use it as the source tree.
if(listPath.length() > 0) if(listPath.length() > 0)
{ {
this->SetHomeDirectory(listPath.c_str()); this->SetHomeDirectory(listPath.c_str());
this->SetStartDirectory(listPath.c_str()); this->SetStartDirectory(listPath.c_str());
if(argIsFile) if(argIsFile)
{ {
// Source CMakeLists.txt file given. It was probably dropped // Source CMakeLists.txt file given. It was probably dropped
// onto the executable in a GUI. Default to an in-source build. // onto the executable in a GUI. Default to an in-source build.
this->SetHomeOutputDirectory(listPath.c_str()); this->SetHomeOutputDirectory(listPath.c_str());
this->SetStartOutputDirectory(listPath.c_str()); this->SetStartOutputDirectory(listPath.c_str());
} }
else else
{ {
@ -549,11 +552,11 @@ void cmake::SetDirectoriesFromFile(const char* arg)
// directory as build tree. // directory as build tree.
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
this->SetHomeOutputDirectory(cwd.c_str()); this->SetHomeOutputDirectory(cwd.c_str());
this->SetStartOutputDirectory(cwd.c_str()); this->SetStartOutputDirectory(cwd.c_str());
} }
return; return;
} }
// We didn't find a CMakeLists.txt or CMakeCache.txt file from the // We didn't find a CMakeLists.txt or CMakeCache.txt file from the
// argument. Assume it is the path to the source tree, and use the // argument. Assume it is the path to the source tree, and use the
// current working directory as the build tree. // current working directory as the build tree.
@ -562,10 +565,11 @@ void cmake::SetDirectoriesFromFile(const char* arg)
this->SetHomeDirectory(full.c_str()); this->SetHomeDirectory(full.c_str());
this->SetStartDirectory(full.c_str()); this->SetStartDirectory(full.c_str());
this->SetHomeOutputDirectory(cwd.c_str()); this->SetHomeOutputDirectory(cwd.c_str());
this->SetStartOutputDirectory(cwd.c_str()); this->SetStartOutputDirectory(cwd.c_str());
} }
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
// cache
int cmake::AddCMakePaths(const char *arg0) int cmake::AddCMakePaths(const char *arg0)
{ {
// Find our own executable. // Find our own executable.
@ -638,7 +642,7 @@ int cmake::AddCMakePaths(const char *arg0)
("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
"Path to cache edit program executable.", cmCacheManager::INTERNAL); "Path to cache edit program executable.", cmCacheManager::INTERNAL);
} }
// do CMAKE_ROOT, look for the environment variable first // do CMAKE_ROOT, look for the environment variable first
std::string cMakeRoot; std::string cMakeRoot;
std::string modules; std::string modules;
@ -652,14 +656,14 @@ int cmake::AddCMakePaths(const char *arg0)
// next try exe/.. // next try exe/..
cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
std::string::size_type slashPos = cMakeRoot.rfind("/"); std::string::size_type slashPos = cMakeRoot.rfind("/");
if(slashPos != std::string::npos) if(slashPos != std::string::npos)
{ {
cMakeRoot = cMakeRoot.substr(0, slashPos); cMakeRoot = cMakeRoot.substr(0, slashPos);
} }
// is there no Modules direcory there? // is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
} }
if (!cmSystemTools::FileExists(modules.c_str())) if (!cmSystemTools::FileExists(modules.c_str()))
{ {
// try exe/../share/cmake // try exe/../share/cmake
@ -684,7 +688,7 @@ int cmake::AddCMakePaths(const char *arg0)
#endif #endif
if (!cmSystemTools::FileExists(modules.c_str())) if (!cmSystemTools::FileExists(modules.c_str()))
{ {
// try // try
cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
cMakeRoot += CMAKE_DATA_DIR; cMakeRoot += CMAKE_DATA_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
@ -694,15 +698,15 @@ int cmake::AddCMakePaths(const char *arg0)
// next try exe // next try exe
cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
// is there no Modules direcory there? // is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake"; modules = cMakeRoot + "/Modules/CMake.cmake";
} }
if (!cmSystemTools::FileExists(modules.c_str())) if (!cmSystemTools::FileExists(modules.c_str()))
{ {
// couldn't find modules // couldn't find modules
cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n"
"CMake has most likely not been installed correctly.\n" "CMake has most likely not been installed correctly.\n"
"Modules directory not found in\n", "Modules directory not found in\n",
cMakeRoot.c_str()); cMakeRoot.c_str());
return 0; return 0;
} }
this->m_CacheManager->AddCacheEntry this->m_CacheManager->AddCacheEntry
@ -723,20 +727,23 @@ void CMakeCommandUsage(const char* program)
cmOStringStream errorStream; cmOStringStream errorStream;
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
errorStream errorStream
<< "cmake version " << cmVersion::GetCMakeVersion() << "\n"; << "cmake version " << cmVersion::GetCMakeVersion() << "\n";
#else #else
errorStream errorStream
<< "cmake bootstrap\n"; << "cmake bootstrap\n";
#endif #endif
errorStream errorStream
<< "Usage: " << program << " -E [command] [arguments ...]\n" << "Usage: " << program << " -E [command] [arguments ...]\n"
<< "Available commands: \n" << "Available commands: \n"
<< " chdir dir cmd [args]... - run command in a given directory\n" << " chdir dir cmd [args]... - run command in a given directory\n"
<< " copy file destination - copy file to destination (either file or directory)\n" << " copy file destination - copy file to destination (either file or "
<< " copy_if_different in-file out-file - copy file if input has changed\n" "directory)\n"
<< " copy_directory source destination - copy directory 'source' content to directory 'destination'\n" << " copy_if_different in-file out-file - copy file if input has "
"changed\n"
<< " copy_directory source destination - copy directory 'source' "
"content to directory 'destination'\n"
<< " compare_files file1 file2 - check if file1 is same as file2\n" << " compare_files file1 file2 - check if file1 is same as file2\n"
<< " echo [string]... - displays arguments as text\n" << " echo [string]... - displays arguments as text\n"
<< " remove file1 file2 ... - remove the file(s)\n" << " remove file1 file2 ... - remove the file(s)\n"
@ -774,7 +781,8 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
// Copy file if different. // Copy file if different.
if (args[1] == "copy_if_different" && args.size() == 4) if (args[1] == "copy_if_different" && args.size() == 4)
{ {
if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str())) if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(),
args[3].c_str()))
{ {
std::cerr << "Error copying file (if different) from \"" std::cerr << "Error copying file (if different) from \""
<< args[2].c_str() << "\" to \"" << args[3].c_str() << args[2].c_str() << "\" to \"" << args[3].c_str()
@ -856,17 +864,17 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
time(&time_start); time(&time_start);
clock_start = clock(); clock_start = clock();
cmSystemTools::RunSingleCommand(command.c_str()); cmSystemTools::RunSingleCommand(command.c_str());
clock_finish = clock(); clock_finish = clock();
time(&time_finish); time(&time_finish);
double clocks_per_sec = (double)CLOCKS_PER_SEC; double clocks_per_sec = (double)CLOCKS_PER_SEC;
std::cout << "Elapsed time: " std::cout << "Elapsed time: "
<< (long)(time_finish - time_start) << " s. (time)" << (long)(time_finish - time_start) << " s. (time)"
<< ", " << ", "
<< (double)(clock_finish - clock_start) / clocks_per_sec << (double)(clock_finish - clock_start) / clocks_per_sec
<< " s. (clock)" << " s. (clock)"
<< "\n"; << "\n";
return 0; return 0;
@ -894,11 +902,11 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
} }
int retval = 0; int retval = 0;
int timeout = 0; int timeout = 0;
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,
directory.c_str(), true, timeout) ) directory.c_str(), true, timeout) )
{ {
return retval; return retval;
} }
return 1; return 1;
} }
@ -1011,7 +1019,8 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
} }
else if ( flags.find_first_of('c') != flags.npos ) else if ( flags.find_first_of('c') != flags.npos )
{ {
if ( !cmSystemTools::CreateTar(outFile.c_str(), files, gzip, verbose) ) if ( !cmSystemTools::CreateTar(
outFile.c_str(), files, gzip, verbose) )
{ {
cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1; return 1;
@ -1019,7 +1028,8 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
} }
else if ( flags.find_first_of('x') != flags.npos ) else if ( flags.find_first_of('x') != flags.npos )
{ {
if ( !cmSystemTools::ExtractTar(outFile.c_str(), files, gzip, verbose) ) if ( !cmSystemTools::ExtractTar(
outFile.c_str(), files, gzip, verbose) )
{ {
cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); cmSystemTools::Error("Problem extracting tar: ", outFile.c_str());
return 1; return 1;
@ -1040,7 +1050,7 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
// Write registry value // Write registry value
else if (args[1] == "write_regv" && args.size() > 3) else if (args[1] == "write_regv" && args.size() > 3)
{ {
return cmSystemTools::WriteRegistryValue(args[2].c_str(), return cmSystemTools::WriteRegistryValue(args[2].c_str(),
args[3].c_str()) ? 0 : 1; args[3].c_str()) ? 0 : 1;
} }
@ -1091,7 +1101,7 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
} }
} }
void cmake::SetHomeDirectory(const char* dir) void cmake::SetHomeDirectory(const char* dir)
{ {
m_cmHomeDirectory = dir; m_cmHomeDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory); cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
@ -1127,7 +1137,7 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
// set the new // set the new
m_GlobalGenerator = gg; m_GlobalGenerator = gg;
// set the global flag for unix style paths on cmSystemTools as // set the global flag for unix style paths on cmSystemTools as
// soon as the generator is set. This allows gmake to be used // soon as the generator is set. This allows gmake to be used
// on windows. // on windows.
cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths()); cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths());
@ -1177,15 +1187,16 @@ int cmake::DoPreConfigureChecks()
err << "The source directory \"" << this->GetHomeDirectory() err << "The source directory \"" << this->GetHomeDirectory()
<< "\" does not exist.\n"; << "\" does not exist.\n";
} }
err << "Specify --help for usage, or press the help button on the CMake GUI."; err << "Specify --help for usage, or press the help button on the CMake "
"GUI.";
cmSystemTools::Error(err.str().c_str()); cmSystemTools::Error(err.str().c_str());
return -2; return -2;
} }
// do a sanity check on some values // do a sanity check on some values
if(m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) if(m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"))
{ {
std::string cacheStart = std::string cacheStart =
m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY");
cacheStart += "/CMakeLists.txt"; cacheStart += "/CMakeLists.txt";
std::string currentStart = this->GetHomeDirectory(); std::string currentStart = this->GetHomeDirectory();
@ -1226,12 +1237,13 @@ int cmake::Configure()
} }
if ( !res ) if ( !res )
{ {
m_CacheManager->AddCacheEntry("CMAKE_HOME_DIRECTORY", m_CacheManager->AddCacheEntry("CMAKE_HOME_DIRECTORY",
this->GetHomeDirectory(), this->GetHomeDirectory(),
"Start directory with the top level CMakeLists.txt file for this project", "Start directory with the top level CMakeLists.txt file for this "
cmCacheManager::INTERNAL); "project",
cmCacheManager::INTERNAL);
} }
// set the default BACKWARDS compatibility to the current version // set the default BACKWARDS compatibility to the current version
if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
{ {
@ -1239,11 +1251,12 @@ int cmake::Configure()
sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(),
cmMakefile::GetMinorVersion()); cmMakefile::GetMinorVersion());
this->m_CacheManager->AddCacheEntry this->m_CacheManager->AddCacheEntry
("CMAKE_BACKWARDS_COMPATIBILITY",ver, ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
"For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.", "For backwards compatibility, what version of CMake commands and "
"syntax should this version of CMake allow.",
cmCacheManager::STRING); cmCacheManager::STRING);
} }
// no generator specified on the command line // no generator specified on the command line
if(!m_GlobalGenerator) if(!m_GlobalGenerator)
{ {
@ -1254,10 +1267,11 @@ int cmake::Configure()
} }
if(m_GlobalGenerator) if(m_GlobalGenerator)
{ {
// set the global flag for unix style paths on cmSystemTools as // set the global flag for unix style paths on cmSystemTools as
// soon as the generator is set. This allows gmake to be used // soon as the generator is set. This allows gmake to be used
// on windows. // on windows.
cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths()); cmSystemTools::SetForceUnixPaths(
m_GlobalGenerator->GetForceUnixPaths());
} }
else else
{ {
@ -1265,7 +1279,8 @@ int cmake::Configure()
this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator); this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator);
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
std::string installedCompiler; std::string installedCompiler;
std::string mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path]"; std::string mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
"\\VisualStudio\\8.0\\Setup;Dbghelp_path]";
cmSystemTools::ExpandRegistryValues(mp); cmSystemTools::ExpandRegistryValues(mp);
if (!(mp == "/registry")) if (!(mp == "/registry"))
{ {
@ -1273,7 +1288,8 @@ int cmake::Configure()
} }
else else
{ {
mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]"; mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
"\\VisualStudio\\7.1;InstallDir]";
cmSystemTools::ExpandRegistryValues(mp); cmSystemTools::ExpandRegistryValues(mp);
if (!(mp == "/registry")) if (!(mp == "/registry"))
{ {
@ -1281,7 +1297,8 @@ int cmake::Configure()
} }
else else
{ {
mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]"; mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
"\\VisualStudio\\7.0;InstallDir]";
cmSystemTools::ExpandRegistryValues(mp); cmSystemTools::ExpandRegistryValues(mp);
if (!(mp == "/registry")) if (!(mp == "/registry"))
{ {
@ -1293,7 +1310,8 @@ int cmake::Configure()
} }
} }
} }
cmGlobalGenerator* gen = this->CreateGlobalGenerator(installedCompiler.c_str()); cmGlobalGenerator* gen
= this->CreateGlobalGenerator(installedCompiler.c_str());
if(!gen) if(!gen)
{ {
gen = new cmGlobalNMakeMakefileGenerator; gen = new cmGlobalNMakeMakefileGenerator;
@ -1328,7 +1346,8 @@ int cmake::Configure()
} }
if(!m_CacheManager->GetCacheValue("CMAKE_GENERATOR")) if(!m_CacheManager->GetCacheValue("CMAKE_GENERATOR"))
{ {
m_CacheManager->AddCacheEntry("CMAKE_GENERATOR", m_GlobalGenerator->GetName(), m_CacheManager->AddCacheEntry("CMAKE_GENERATOR",
m_GlobalGenerator->GetName(),
"Name of generator.", "Name of generator.",
cmCacheManager::INTERNAL); cmCacheManager::INTERNAL);
} }
@ -1340,7 +1359,7 @@ int cmake::Configure()
{ {
m_GlobalGenerator->ClearEnabledLanguages(); m_GlobalGenerator->ClearEnabledLanguages();
} }
this->CleanupWrittenFiles(); this->CleanupWrittenFiles();
// Truncate log files // Truncate log files
@ -1352,7 +1371,7 @@ int cmake::Configure()
// actually do the configure // actually do the configure
m_GlobalGenerator->Configure(); m_GlobalGenerator->Configure();
// Before saving the cache // Before saving the cache
// if the project did not define one of the entries below, add them now // if the project did not define one of the entries below, add them now
// so users can edit the values in the cache: // so users can edit the values in the cache:
@ -1361,30 +1380,31 @@ int cmake::Configure()
if(!m_CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) if(!m_CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH"))
{ {
m_CacheManager->AddCacheEntry("LIBRARY_OUTPUT_PATH", "", m_CacheManager->AddCacheEntry("LIBRARY_OUTPUT_PATH", "",
"Single output directory for building all libraries.", "Single output directory for building all libraries.",
cmCacheManager::PATH); cmCacheManager::PATH);
} }
if(!m_CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) if(!m_CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH"))
{ {
m_CacheManager->AddCacheEntry("EXECUTABLE_OUTPUT_PATH", "", m_CacheManager->AddCacheEntry("EXECUTABLE_OUTPUT_PATH", "",
"Single output directory for building all executables.", "Single output directory for building all executables.",
cmCacheManager::PATH); cmCacheManager::PATH);
} }
if(!m_CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) if(!m_CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS"))
{ {
m_CacheManager->AddCacheEntry("CMAKE_USE_RELATIVE_PATHS", false, m_CacheManager->AddCacheEntry("CMAKE_USE_RELATIVE_PATHS", false,
"If true, cmake will use relative paths in makefiles and projects."); "If true, cmake will use relative paths in makefiles and projects.");
cmCacheManager::CacheIterator it = cmCacheManager::CacheIterator it =
m_CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS"); m_CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS");
if ( !it.PropertyExists("ADVANCED") ) if ( !it.PropertyExists("ADVANCED") )
{ {
it.SetProperty("ADVANCED", "1"); it.SetProperty("ADVANCED", "1");
} }
} }
if(cmSystemTools::GetFatalErrorOccured() && if(cmSystemTools::GetFatalErrorOccured() &&
(!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || (!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") ||
cmSystemTools::IsOff(this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM")))) cmSystemTools::IsOff(
this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM"))))
{ {
// We must have a bad generator selection. Wipe the cache entry so the // We must have a bad generator selection. Wipe the cache entry so the
// user can select another. // user can select another.
@ -1409,13 +1429,16 @@ int cmake::Configure()
bool cmake::CacheVersionMatches() bool cmake::CacheVersionMatches()
{ {
const char* majv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"); const char* majv
const char* minv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"); = m_CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION");
const char* relv = m_CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION"); const char* minv
= m_CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION");
const char* relv
= m_CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION");
bool cacheSameCMake = false; bool cacheSameCMake = false;
if(majv && if(majv &&
atoi(majv) == static_cast<int>(cmMakefile::GetMajorVersion()) atoi(majv) == static_cast<int>(cmMakefile::GetMajorVersion())
&& minv && && minv &&
atoi(minv) == static_cast<int>(cmMakefile::GetMinorVersion()) atoi(minv) == static_cast<int>(cmMakefile::GetMinorVersion())
&& relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0)) && relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0))
{ {
@ -1456,16 +1479,16 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
CMakeCommandUsage(args[0].c_str()); CMakeCommandUsage(args[0].c_str());
return -1; return -1;
} }
// set the cmake command // set the cmake command
m_CMakeCommand = args[0]; m_CMakeCommand = args[0];
if ( !m_ScriptMode ) if ( !m_ScriptMode )
{ {
// load the cache // load the cache
if(this->LoadCache() < 0) if(this->LoadCache() < 0)
{ {
cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n"); cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
return -1; return -1;
} }
} }
@ -1510,7 +1533,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
{ {
return 0; return 0;
} }
// If we are doing global generate, we better set start and start // If we are doing global generate, we better set start and start
// output directory to the root of the project. // output directory to the root of the project.
std::string oldstartdir = this->GetStartDirectory(); std::string oldstartdir = this->GetStartDirectory();
@ -1550,26 +1573,26 @@ int cmake::Generate()
return 0; return 0;
} }
unsigned int cmake::GetMajorVersion() unsigned int cmake::GetMajorVersion()
{ {
return cmMakefile::GetMajorVersion(); return cmMakefile::GetMajorVersion();
} }
unsigned int cmake::GetMinorVersion() unsigned int cmake::GetMinorVersion()
{ {
return cmMakefile::GetMinorVersion(); return cmMakefile::GetMinorVersion();
} }
const char *cmake::GetReleaseVersion() const char *cmake::GetReleaseVersion()
{ {
return cmMakefile::GetReleaseVersion(); return cmMakefile::GetReleaseVersion();
} }
void cmake::AddCacheEntry(const char* key, const char* value, void cmake::AddCacheEntry(const char* key, const char* value,
const char* helpString, const char* helpString,
int type) int type)
{ {
m_CacheManager->AddCacheEntry(key, value, m_CacheManager->AddCacheEntry(key, value,
helpString, helpString,
cmCacheManager::CacheEntryType(type)); cmCacheManager::CacheEntryType(type));
} }
@ -1666,22 +1689,27 @@ int cmake::LoadCache()
cacheFile += "/CMakeCache.txt"; cacheFile += "/CMakeCache.txt";
if(cmSystemTools::FileExists(cacheFile.c_str())) if(cmSystemTools::FileExists(cacheFile.c_str()))
{ {
cmSystemTools::Error("There is a CMakeCache.txt file for the current binary tree but cmake does not have permission to read it. Please check the permissions of the directory you are trying to run CMake on."); cmSystemTools::Error(
"There is a CMakeCache.txt file for the current binary tree but "
"cmake does not have permission to read it. Please check the "
"permissions of the directory you are trying to run CMake on.");
return -1; return -1;
} }
} }
if (m_CMakeCommand.size() < 2) if (m_CMakeCommand.size() < 2)
{ {
cmSystemTools::Error("cmake command was not specified prior to loading the cache in cmake.cxx"); cmSystemTools::Error(
"cmake command was not specified prior to loading the cache in "
"cmake.cxx");
return -1; return -1;
} }
// setup CMAKE_ROOT and CMAKE_COMMAND // setup CMAKE_ROOT and CMAKE_COMMAND
if(!this->AddCMakePaths(m_CMakeCommand.c_str())) if(!this->AddCMakePaths(m_CMakeCommand.c_str()))
{ {
return -3; return -3;
} }
// set the default BACKWARDS compatibility to the current version // set the default BACKWARDS compatibility to the current version
if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
@ -1690,11 +1718,12 @@ int cmake::LoadCache()
sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(),
cmMakefile::GetMinorVersion()); cmMakefile::GetMinorVersion());
this->m_CacheManager->AddCacheEntry this->m_CacheManager->AddCacheEntry
("CMAKE_BACKWARDS_COMPATIBILITY",ver, ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
"For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.", "For backwards compatibility, what version of CMake commands and "
"syntax should this version of CMake allow.",
cmCacheManager::STRING); cmCacheManager::STRING);
} }
return 0; return 0;
} }
@ -1713,7 +1742,8 @@ void cmake::UpdateProgress(const char *msg, float prog)
} }
} }
void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const void cmake::GetCommandDocumentation(
std::vector<cmDocumentationEntry>& v) const
{ {
for(RegisteredCommandsMap::const_iterator j = m_Commands.begin(); for(RegisteredCommandsMap::const_iterator j = m_Commands.begin();
j != m_Commands.end(); ++j) j != m_Commands.end(); ++j)
@ -1763,7 +1793,7 @@ void cmake::CleanupWrittenFiles()
void cmake::UpdateConversionPathTable() void cmake::UpdateConversionPathTable()
{ {
// Update the path conversion table with any specified file: // Update the path conversion table with any specified file:
const char* tablepath = const char* tablepath =
m_CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); m_CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE");
if(tablepath) if(tablepath)
@ -1771,7 +1801,8 @@ void cmake::UpdateConversionPathTable()
std::ifstream table( tablepath ); std::ifstream table( tablepath );
if(!table) if(!table)
{ {
cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, ". CMake can not open file."); cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath,
". CMake can not open file.");
cmSystemTools::ReportLastSystemError("CMake can not open file."); cmSystemTools::ReportLastSystemError("CMake can not open file.");
} }
else else
@ -1844,7 +1875,7 @@ int cmake::CheckBuildSystem()
out != outputs.end(); ++out) out != outputs.end(); ++out)
{ {
int result = 0; int result = 0;
if(!m_FileComparison->FileTimeCompare(out->c_str(), if(!m_FileComparison->FileTimeCompare(out->c_str(),
dep->c_str(), &result) || dep->c_str(), &result) ||
result < 0) result < 0)
{ {
@ -1917,7 +1948,8 @@ const char* cmake::GetCTestCommand()
return m_CTestCommand.c_str(); return m_CTestCommand.c_str();
} }
cmMakefile* mf = this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile(); cmMakefile* mf
= this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile();
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
m_CTestCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); m_CTestCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
m_CTestCommand = removeQuotes(m_CTestCommand); m_CTestCommand = removeQuotes(m_CTestCommand);
@ -1962,7 +1994,8 @@ const char* cmake::GetCPackCommand()
return m_CPackCommand.c_str(); return m_CPackCommand.c_str();
} }
cmMakefile* mf = this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile(); cmMakefile* mf
= this->GetGlobalGenerator()->GetLocalGenerator(0)->GetMakefile();
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
m_CPackCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); m_CPackCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
@ -2031,10 +2064,12 @@ void cmake::GenerateGraphViz(const char* fileName)
{ {
if ( !mf->ReadListFile(0, infile.c_str()) ) if ( !mf->ReadListFile(0, infile.c_str()) )
{ {
cmSystemTools::Error("Problem opening GraphViz options file: ", infile.c_str()); cmSystemTools::Error("Problem opening GraphViz options file: ",
infile.c_str());
return; return;
} }
std::cout << "Read GraphViz options file: " << infile.c_str() << std::endl; std::cout << "Read GraphViz options file: " << infile.c_str()
<< std::endl;
} }
#define __set_if_not_set(var, value, cmakeDefinition) \ #define __set_if_not_set(var, value, cmakeDefinition) \
@ -2045,7 +2080,8 @@ void cmake::GenerateGraphViz(const char* fileName)
} }
__set_if_not_set(graphType, "digraph", "GRAPHVIZ_GRAPH_TYPE"); __set_if_not_set(graphType, "digraph", "GRAPHVIZ_GRAPH_TYPE");
__set_if_not_set(graphName, "GG", "GRAPHVIZ_GRAPH_NAME"); __set_if_not_set(graphName, "GG", "GRAPHVIZ_GRAPH_NAME");
__set_if_not_set(graphHeader, "node [\n fontsize = \"12\"\n];", "GRAPHVIZ_GRAPH_HEADER"); __set_if_not_set(graphHeader, "node [\n fontsize = \"12\"\n];",
"GRAPHVIZ_GRAPH_HEADER");
__set_if_not_set(graphNodePrefix, "node", "GRAPHVIZ_NODE_PREFIX"); __set_if_not_set(graphNodePrefix, "node", "GRAPHVIZ_NODE_PREFIX");
const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS");
std::set<cmStdString> ignoreTargetsSet; std::set<cmStdString> ignoreTargetsSet;
@ -2054,12 +2090,14 @@ void cmake::GenerateGraphViz(const char* fileName)
std::vector<std::string> ignoreTargetsVector; std::vector<std::string> ignoreTargetsVector;
cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector);
std::vector<std::string>::iterator itvIt; std::vector<std::string>::iterator itvIt;
for ( itvIt = ignoreTargetsVector.begin(); itvIt != ignoreTargetsVector.end(); ++ itvIt ) for ( itvIt = ignoreTargetsVector.begin();
itvIt != ignoreTargetsVector.end();
++ itvIt )
{ {
ignoreTargetsSet.insert(itvIt->c_str()); ignoreTargetsSet.insert(itvIt->c_str());
} }
} }
str << graphType << " " << graphName << " {" << std::endl; str << graphType << " " << graphName << " {" << std::endl;
str << graphHeader << std::endl; str << graphHeader << std::endl;
@ -2093,7 +2131,8 @@ void cmake::GenerateGraphViz(const char* fileName)
sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); sprintf(tgtName, "%s%d", graphNodePrefix, cnt++);
targetNamesNodes[realTargetName] = tgtName; targetNamesNodes[realTargetName] = tgtName;
targetPtrs[realTargetName] = &tit->second; targetPtrs[realTargetName] = &tit->second;
//str << " \"" << tgtName << "\" [ label=\"" << tit->first.c_str() << "\" shape=\"box\"];" << std::endl; //str << " \"" << tgtName << "\" [ label=\"" << tit->first.c_str()
//<< "\" shape=\"box\"];" << std::endl;
} }
} }
// Ok, now find all the stuff we link to that is not in cmake // Ok, now find all the stuff we link to that is not in cmake
@ -2103,7 +2142,8 @@ void cmake::GenerateGraphViz(const char* fileName)
cmTargets::iterator tit; cmTargets::iterator tit;
for ( tit = targets->begin(); tit != targets->end(); ++ tit ) for ( tit = targets->begin(); tit != targets->end(); ++ tit )
{ {
const cmTarget::LinkLibraries* ll = &(tit->second.GetOriginalLinkLibraries()); const cmTarget::LinkLibraries* ll
= &(tit->second.GetOriginalLinkLibraries());
cmTarget::LinkLibraries::const_iterator llit; cmTarget::LinkLibraries::const_iterator llit;
const char* realTargetName = tit->first.c_str(); const char* realTargetName = tit->first.c_str();
if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() ) if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() )
@ -2118,7 +2158,8 @@ void cmake::GenerateGraphViz(const char* fileName)
for ( llit = ll->begin(); llit != ll->end(); ++ llit ) for ( llit = ll->begin(); llit != ll->end(); ++ llit )
{ {
const char* libName = llit->first.c_str(); const char* libName = llit->first.c_str();
std::map<cmStdString, cmStdString>::iterator tarIt = targetNamesNodes.find(libName); std::map<cmStdString, cmStdString>::iterator tarIt
= targetNamesNodes.find(libName);
if ( ignoreTargetsSet.find(libName) != ignoreTargetsSet.end() ) if ( ignoreTargetsSet.find(libName) != ignoreTargetsSet.end() )
{ {
// Skip ignored targets // Skip ignored targets
@ -2129,11 +2170,13 @@ void cmake::GenerateGraphViz(const char* fileName)
sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); sprintf(tgtName, "%s%d", graphNodePrefix, cnt++);
targetDeps[libName] = 2; targetDeps[libName] = 2;
targetNamesNodes[libName] = tgtName; targetNamesNodes[libName] = tgtName;
//str << " \"" << tgtName << "\" [ label=\"" << libName << "\" shape=\"ellipse\"];" << std::endl; //str << " \"" << tgtName << "\" [ label=\"" << libName
//<< "\" shape=\"ellipse\"];" << std::endl;
} }
else else
{ {
std::map<cmStdString, int>::iterator depIt = targetDeps.find(libName); std::map<cmStdString, int>::iterator depIt
= targetDeps.find(libName);
if ( depIt == targetDeps.end() ) if ( depIt == targetDeps.end() )
{ {
targetDeps[libName] = 1; targetDeps[libName] = 1;
@ -2148,22 +2191,27 @@ void cmake::GenerateGraphViz(const char* fileName)
for ( depIt = targetDeps.begin(); depIt != targetDeps.end(); ++ depIt ) for ( depIt = targetDeps.begin(); depIt != targetDeps.end(); ++ depIt )
{ {
const char* newTargetName = depIt->first.c_str(); const char* newTargetName = depIt->first.c_str();
std::map<cmStdString, cmStdString>::iterator tarIt = targetNamesNodes.find(newTargetName); std::map<cmStdString, cmStdString>::iterator tarIt
= targetNamesNodes.find(newTargetName);
if ( tarIt == targetNamesNodes.end() ) if ( tarIt == targetNamesNodes.end() )
{ {
// We should not be here. // We should not be here.
std::cout << __LINE__ << " Cannot find library: " << newTargetName << " even though it was added in the previous pass" << std::endl; std::cout << __LINE__ << " Cannot find library: " << newTargetName
<< " even though it was added in the previous pass" << std::endl;
abort(); abort();
} }
str << " \"" << tarIt->second.c_str() << "\" [ label=\"" << newTargetName << "\" shape=\""; str << " \"" << tarIt->second.c_str() << "\" [ label=\""
<< newTargetName << "\" shape=\"";
if ( depIt->second == 1 ) if ( depIt->second == 1 )
{ {
std::map<cmStdString, cmTarget*>::iterator tarTypeIt= targetPtrs.find(newTargetName); std::map<cmStdString, cmTarget*>::iterator tarTypeIt= targetPtrs.find(
newTargetName);
if ( tarTypeIt == targetPtrs.end() ) if ( tarTypeIt == targetPtrs.end() )
{ {
// We should not be here. // We should not be here.
std::cout << __LINE__ << " Cannot find library: " << newTargetName << " even though it was added in the previous pass" << std::endl; std::cout << __LINE__ << " Cannot find library: " << newTargetName
<< " even though it was added in the previous pass" << std::endl;
abort(); abort();
} }
cmTarget* tg = tarTypeIt->second; cmTarget* tg = tarTypeIt->second;
@ -2199,31 +2247,38 @@ void cmake::GenerateGraphViz(const char* fileName)
cmTargets::iterator tit; cmTargets::iterator tit;
for ( tit = targets->begin(); tit != targets->end(); ++ tit ) for ( tit = targets->begin(); tit != targets->end(); ++ tit )
{ {
std::map<cmStdString, int>::iterator dependIt = targetDeps.find(tit->first.c_str()); std::map<cmStdString, int>::iterator dependIt
= targetDeps.find(tit->first.c_str());
if ( dependIt == targetDeps.end() ) if ( dependIt == targetDeps.end() )
{ {
continue; continue;
} }
std::map<cmStdString, cmStdString>::iterator cmakeTarIt = targetNamesNodes.find(tit->first.c_str()); std::map<cmStdString, cmStdString>::iterator cmakeTarIt
const cmTarget::LinkLibraries* ll = &(tit->second.GetOriginalLinkLibraries()); = targetNamesNodes.find(tit->first.c_str());
const cmTarget::LinkLibraries* ll
= &(tit->second.GetOriginalLinkLibraries());
cmTarget::LinkLibraries::const_iterator llit; cmTarget::LinkLibraries::const_iterator llit;
for ( llit = ll->begin(); llit != ll->end(); ++ llit ) for ( llit = ll->begin(); llit != ll->end(); ++ llit )
{ {
const char* libName = llit->first.c_str(); const char* libName = llit->first.c_str();
std::map<cmStdString, cmStdString>::iterator tarIt = targetNamesNodes.find(libName); std::map<cmStdString, cmStdString>::iterator tarIt
= targetNamesNodes.find(libName);
if ( tarIt == targetNamesNodes.end() ) if ( tarIt == targetNamesNodes.end() )
{ {
// We should not be here. // We should not be here.
std::cout << __LINE__ << " Cannot find library: " << libName << " even though it was added in the previous pass" << std::endl; std::cout << __LINE__ << " Cannot find library: " << libName
<< " even though it was added in the previous pass" << std::endl;
abort(); abort();
} }
str << " \"" << cmakeTarIt->second.c_str() << "\" -> \"" << tarIt->second.c_str() << "\"" << std::endl; str << " \"" << cmakeTarIt->second.c_str() << "\" -> \""
<< tarIt->second.c_str() << "\"" << std::endl;
} }
} }
} }
// TODO: Use dotted or something for external libraries // TODO: Use dotted or something for external libraries
//str << " \"node0\":f4 -> \"node12\"[color=\"#0000ff\" style=dotted]" << std::endl; //str << " \"node0\":f4 -> \"node12\"[color=\"#0000ff\" style=dotted]"
//<< std::endl;
// //
str << "}" << std::endl; str << "}" << std::endl;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -23,8 +23,9 @@ cmakewizard::cmakewizard()
m_ShowAdvanced = false; m_ShowAdvanced = false;
} }
void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter) void cmakewizard::AskUser(const char* key,
cmCacheManager::CacheIterator& iter)
{ {
printf("Variable Name: %s\n", key); printf("Variable Name: %s\n", key);
const char* helpstring = iter.GetProperty("HELPSTRING"); const char* helpstring = iter.GetProperty("HELPSTRING");
@ -34,7 +35,7 @@ void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter)
char buffer[4096]; char buffer[4096];
buffer[0] = 0; buffer[0] = 0;
fgets(buffer, sizeof(buffer)-1, stdin); fgets(buffer, sizeof(buffer)-1, stdin);
if(strlen(buffer) > 0) if(strlen(buffer) > 0)
{ {
std::string sbuffer = buffer; std::string sbuffer = buffer;
@ -44,7 +45,7 @@ void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter)
{ {
value = sbuffer.substr(0, pos+1); value = sbuffer.substr(0, pos+1);
} }
if ( value.size() > 0 ) if ( value.size() > 0 )
{ {
if(iter.GetType() == cmCacheManager::PATH || if(iter.GetType() == cmCacheManager::PATH ||
@ -67,7 +68,7 @@ void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter)
bool cmakewizard::AskAdvanced() bool cmakewizard::AskAdvanced()
{ {
printf("Would you like to see advanced options? [No]:"); printf("Would you like to see advanced options? [No]:");
char buffer[4096]; char buffer[4096];
buffer[0] = 0; buffer[0] = 0;
fgets(buffer, sizeof(buffer)-1, stdin); fgets(buffer, sizeof(buffer)-1, stdin);
@ -105,7 +106,8 @@ int cmakewizard::RunWizard(std::vector<std::string> const& args)
{ {
asked = false; asked = false;
// run cmake // run cmake
this->ShowMessage("Please wait while cmake processes CMakeLists.txt files....\n"); this->ShowMessage(
"Please wait while cmake processes CMakeLists.txt files....\n");
make.Configure(); make.Configure();
this->ShowMessage("\n"); this->ShowMessage("\n");
@ -115,9 +117,9 @@ int cmakewizard::RunWizard(std::vector<std::string> const& args)
cmCacheManager::CacheIterator i = cachem->NewIterator(); cmCacheManager::CacheIterator i = cachem->NewIterator();
// iterate over all entries in the cache // iterate over all entries in the cache
for(;!i.IsAtEnd(); i.Next()) for(;!i.IsAtEnd(); i.Next())
{ {
std::string key = i.GetName(); std::string key = i.GetName();
if( i.GetType() == cmCacheManager::INTERNAL || if( i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED ) i.GetType() == cmCacheManager::UNINITIALIZED )
{ {
@ -136,7 +138,7 @@ int cmakewizard::RunWizard(std::vector<std::string> const& args)
} }
} }
else else
{ {
if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED"))
{ {
this->AskUser(key.c_str(), i); this->AskUser(key.c_str(), i);