From cca67d7f8eec353a4dd46ee021090af1f6cf546f Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 11 Jan 2007 21:02:47 -0500 Subject: [PATCH] BUG: fix for bug 4239, NODEFAULTLIB flag support in ide --- Source/cmLocalVisualStudio7Generator.cxx | 52 +++++++++++++++++++----- Source/cmLocalVisualStudio7Generator.h | 6 +++ 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index bf85145db..66e4a74dc 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -366,6 +366,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE"}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"}, + {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "USER_VALUE", ""}, {0,0,0,0 } }; @@ -625,6 +626,36 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, this->OutputBuildTool(fout, configName, libName, target); fout << "\t\t\n"; } +void cmLocalVisualStudio7Generator::ReplaceFlagSetMap(std::string& flags, + cmVS7FlagTable* flagTable, + std::map& flagMap, + std::string& option, + std::string::size_type pos) +{ + std::string value = flagTable->value; + if(strcmp(flagTable->comment, "USER_VALUE") == 0) + { + std::string::size_type len = flags.find(" ", pos); + if(len != flags.npos) + { + len -= option.size(); + } + value = flags.substr(pos+option.size(), len); + std::string fullflag = option; + fullflag += value; + // remove everything + cmSystemTools::ReplaceString(flags, fullflag.c_str(), ""); + } + else + { + cmSystemTools::ReplaceString(flags, option.c_str(), ""); + } + // now put value into flag map + + flagMap[flagTable->IDEName] = value; +} + void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags( std::map& flagMap, @@ -639,21 +670,21 @@ void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags( // first do the - version option = "-"; option += flagTable->commandFlag; - while(flags.find(option) != flags.npos) + std::string::size_type pos = flags.find(option); + while(pos != flags.npos) { - // replace the flag - cmSystemTools::ReplaceString(flags, option.c_str(), ""); - // now put value into flag map - flagMap[flagTable->IDEName] = flagTable->value; + this->ReplaceFlagSetMap(flags, flagTable, flagMap, + option, pos); + pos = flags.find(option); } // now do the / version option[0] = '/'; - while(flags.find(option) != flags.npos) + pos = flags.find(option); + while(pos != flags.npos) { - // replace the flag - cmSystemTools::ReplaceString(flags, option.c_str(), ""); - // now put value into flag map - flagMap[flagTable->IDEName] = flagTable->value; + this->ReplaceFlagSetMap(flags, flagTable, flagMap, + option, pos); + pos = flags.find(option); } // move to next flag flagTable++; @@ -737,7 +768,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->FillFlagMapFromCommandFlags (flagMap, &cmLocalVisualStudio7GeneratorLinkFlagTable[0], extraLinkOptions); - switch(target.GetType()) { case cmTarget::STATIC_LIBRARY: diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 48dce0c27..a3c6f624d 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -65,6 +65,12 @@ public: void SetPlatformName(const char* n) { this->PlatformName = n;} virtual void ConfigureFinalPass(); private: + void ReplaceFlagSetMap(std::string& flags, + cmVS7FlagTable* flagTable, + std::map& flagMap, + std::string& option, + std::string::size_type pos); void FillFlagMapFromCommandFlags(std::map& flagMap, cmVS7FlagTable* flagTable,