From d8ed9ef12151ad36c7cc9bb1908e7866a1e61bd0 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 9 Feb 2005 23:25:09 -0500 Subject: [PATCH] ENH: fix bug 1324 --- Source/cmLocalVisualStudio7Generator.cxx | 32 ++++++++++++++++++------ Source/cmLocalVisualStudio7Generator.h | 3 ++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 50e65f985..0578fe8e2 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -284,11 +284,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { // create a map of xml tags to the values they should have in the output // for example, "BufferSecurityCheck" = "TRUE" - // first fill this table with the values for the configuration Debug, Release, etc, - // Then parse the command line flags specified in CMAKE_CXX_FLAGS and CMAKE_C_FLAGS + // first fill this table with the values for the configuration + // Debug, Release, etc, + // Then parse the command line flags specified in CMAKE_CXX_FLAGS + // and CMAKE_C_FLAGS // and overwrite or add new values to this map std::map flagMap; - + // since the default is on for this, but if /EHsc is found + // in the flags it will be turned on and we have /EHSC on by + // default in the CXX flags, then this is the only way to turn this off + flagMap["ExceptionHandling"] = "FALSE"; const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG"); if(!mfcFlag) { @@ -431,7 +436,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // now fill the flagMap from the command line flags, and // if a flag is used, it will be removed from the flags string by // this function call - this->FillFlagMapFromCommandFlags(flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], flags); + this->FillFlagMapFromCommandFlags(flagMap, + &cmLocalVisualStudio7GeneratorFlagTable[0], + flags); + std::string defineFlags = m_Makefile->GetDefineFlags(); + // 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 + // variable as -D is not in the flagMap + this->FillFlagMapFromCommandFlags(flagMap, + &cmLocalVisualStudio7GeneratorFlagTable[0], + defineFlags); // output remaining flags that were not mapped to anything fout << this->EscapeForXML(flags.c_str()).c_str(); fout << " -DCMAKE_INTDIR=\\"" << configName << "\\"" @@ -478,7 +492,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } fout << "," << exportSymbol; } - this->OutputDefineFlags(fout); + this->OutputDefineFlags(defineFlags.c_str(), fout); fout << "\"\n"; fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n"; fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n"; @@ -500,9 +514,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); fout << ipath << ";"; } + // add the -D flags to the RC tool fout << "\"\n" << "\t\t\t\tPreprocessorDefinitions=\"" << pre; - this->OutputDefineFlags(fout); + this->OutputDefineFlags(defineFlags.c_str(), fout); fout << "\" />\n"; fout << "\t\t\t\n"; this->OutputTargetRules(fout, target, libName); @@ -842,9 +857,10 @@ void cmLocalVisualStudio7Generator::OutputLibraries(std::ostream& fout, } } -void cmLocalVisualStudio7Generator::OutputDefineFlags(std::ostream& fout) +void cmLocalVisualStudio7Generator::OutputDefineFlags(const char* flags, + std::ostream& fout) { - std::string defs = m_Makefile->GetDefineFlags(); + std::string defs = flags; cmSystemTools::ReplaceString(defs, "/D","-D"); std::string::size_type pos = defs.find("-D"); bool done = pos == std::string::npos; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 52d1624ac..a6608bc6d 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -89,7 +89,8 @@ private: std::string EscapeForXML(const char* s); std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path); - void OutputDefineFlags(std::ostream& fout); + void OutputDefineFlags(const char* flags, + std::ostream& fout); void OutputTargetRules(std::ostream& fout, const cmTarget &target, const char *libName);