ENH: use GetRequiredDefinition instead of GetDefinition and crash

This commit is contained in:
Bill Hoffman 2004-08-11 16:58:09 -04:00
parent bb32a51825
commit b41d447935
9 changed files with 44 additions and 43 deletions

View File

@ -23,7 +23,7 @@
bool cmAbstractFilesCommand::InitialPass(std::vector<std::string> const& args)
{
const char* versionValue
= m_Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
= m_Makefile->GetRequiredDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
if (atof(versionValue) > 1.4)
{
this->SetError("The ABSTRACT_FILES command was deprecated in CMake version 1.4 and will be removed in later versions of CMake. You should modify your CMakeLists.txt files to use the SET command instead, or set the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.2 or less.\n");

View File

@ -65,7 +65,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("could not find Mac OSX bundle template file.");
return false;
}
std::string macdir = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
std::string macdir = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
if ( macdir.size() == 0 )
{
macdir = m_Makefile->GetCurrentOutputDirectory();

View File

@ -82,7 +82,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args)
++i;
std::string configFile =
m_Makefile->GetDefinition("CMAKE_ROOT");
m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
configFile += "/Templates/TestDriver.cxx.in";
// Create the test driver file

View File

@ -33,7 +33,7 @@ void cmGlobalCodeWarriorGenerator::EnableLanguage(const char*,
if(!this->GetLanguageEnabled("CXX"))
{
std::string fpath =
mf->GetDefinition("CMAKE_ROOT");
mf->GetRequiredDefinition("CMAKE_ROOT");
fpath += "/Templates/CMakeCodeWarriorConfig.cmake";
mf->ReadListFile(0,fpath.c_str());
this->SetLanguageEnabled("CXX");

View File

@ -53,7 +53,7 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
"Generator implementation error, "
"all generators must specify m_FindMakeProgramFile");
}
std::string root = mf->GetDefinition("CMAKE_ROOT");
std::string root = mf->GetRequiredDefinition("CMAKE_ROOT");
if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
|| cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
{
@ -73,7 +73,7 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
cmSystemTools::SetFatalErrorOccured();
return;
}
std::string makeProgram = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
// if there are spaces in the make program use short path
// but do not short path the actual program name, as
// this can cause trouble with VSExpress

View File

@ -43,7 +43,7 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage");
return;
}
const char* cc = mf->GetDefinition("CMAKE_C_COMPILER");
const char* cc = mf->GetRequiredDefinition("CMAKE_C_COMPILER");
std::string path = cmSystemTools::FindProgram(cc);
if(path.size() == 0)
{
@ -64,7 +64,7 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
}
if(strcmp(lang, "CXX") == 0)
{
const char* cxx = mf->GetDefinition("CMAKE_CXX_COMPILER");
const char* cxx = mf->GetRequiredDefinition("CMAKE_CXX_COMPILER");
path = cmSystemTools::FindProgram(cxx);
if(path.size() == 0)
{

View File

@ -184,7 +184,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule()
argv.push_back(args);
std::string configFile =
m_Makefile->GetDefinition("CMAKE_ROOT");
m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
std::vector<std::string> listFiles = m_Makefile->GetListFiles();
bool found = false;
@ -527,7 +527,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
const char* libName,
const cmTarget& target)
{
std::string root= m_Makefile->GetDefinition("CMAKE_ROOT");
std::string root= m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
std::string exportSymbol;
@ -924,15 +924,15 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
std::string extraLinkOptions;
if(target.GetType() == cmTarget::EXECUTABLE)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
}
if(target.GetType() == cmTarget::SHARED_LIBRARY)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_SHARED_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
}
if(target.GetType() == cmTarget::MODULE_LIBRARY)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_MODULE_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
}
if(extraLinkOptions.size())
@ -1059,30 +1059,30 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
// if CXX is on and the target contains cxx code then add the cxx flags
if ( gen->GetLanguageEnabled("CXX") && target.HasCxx() )
{
flagsRelease = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsRelease = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
flagsMinSize = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsMinSize = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flagsDebug = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebug = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flagsDebugRel = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flagsDebugRel = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
flags = " ";
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
flags = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS");
}
// if C and the target is not CXX
else if(gen->GetLanguageEnabled("C") && !target.HasCxx())
{
flagsRelease += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELEASE");
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\"";
flagsMinSize += m_Makefile->GetDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\"";
flagsDebug += m_Makefile->GetDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\"";
flagsDebugRel += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\"";
flags = " ";
flags = m_Makefile->GetDefinition("CMAKE_C_FLAGS");
flags = m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS");
}
// if unicode is not found, then add -D_MBCS
if(flags.find("D_UNICODE") == flags.npos)

View File

@ -157,7 +157,7 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule()
argv.push_back(args);
std::string configFile =
m_Makefile->GetDefinition("CMAKE_ROOT");
m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
std::vector<std::string> listFiles = m_Makefile->GetListFiles();
bool found = false;
@ -324,19 +324,19 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string flagsDebugRel = " ";
if(target.HasCxx())
{
flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
flagsRelease += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flags = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS");
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
}
else
{
flags = m_Makefile->GetDefinition("CMAKE_C_FLAGS");
flagsRelease += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
flags = m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS");
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
}
@ -538,15 +538,15 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
std::string extraLinkOptions;
if(target.GetType() == cmTarget::EXECUTABLE)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
}
if(target.GetType() == cmTarget::SHARED_LIBRARY)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_SHARED_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
}
if(target.GetType() == cmTarget::MODULE_LIBRARY)
{
extraLinkOptions = m_Makefile->GetDefinition("CMAKE_MODULE_LINKER_FLAGS");
extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
}
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
@ -620,10 +620,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
}
if(const char* stacksize = m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE"))
if(target.HasCxx())
{
fout << "\t\t\t\tStackReserveSize=\""
<< stacksize << "\"\n";
<< m_Makefile->GetRequiredDefinition("CMAKE_CXX_STACK_SIZE") << "\"\n";
}
temp = m_LibraryOutputPath;
temp += configName;
@ -645,7 +645,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
fout << "\"\n"
<< "\t\t\t\tAdditionalDependencies=\""
<< m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")
<< m_Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES")
<< " ";
this->OutputLibraries(fout, configName, libName, target);
fout << "\"\n";
@ -683,11 +683,12 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tSubSystem=\"1\"\n";
}
if(const char* stacksize = m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE"))
if(target.HasCxx())
{
fout << "\t\t\t\tStackReserveSize=\""
<< stacksize << "\"/>\n";
<< m_Makefile->GetRequiredDefinition("CMAKE_CXX_STACK_SIZE") << "\"";
}
fout << "/>\n";
break;
case cmTarget::UTILITY:
break;

View File

@ -63,7 +63,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args)
}
// The source exists.
std::string cmakeCFGout = m_Makefile->GetDefinition("CMAKE_CFG_INTDIR");
std::string cmakeCFGout = m_Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
std::string utilityDirectory = m_Makefile->GetCurrentOutputDirectory();
std::string exePath;
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))