Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.252.2.2
diff -u -r1.252.2.2 cmLocalVisualStudio7Generator.cxx
--- cmLocalVisualStudio7Generator.cxx	28 Oct 2009 16:15:19 -0000	1.252.2.2
+++ cmLocalVisualStudio7Generator.cxx	29 Jan 2010 10:28:24 -0000
@@ -654,11 +654,6 @@
   targetOptions.SetVerboseMakefile(
     this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
 
-  // Add a definition for the configuration name.
-  std::string configDefine = "CMAKE_INTDIR=\"";
-  configDefine += configName;
-  configDefine += "\"";
-  targetOptions.AddDefine(configDefine);
 
   // Add the export symbol definition for shared library objects.
   if(const char* exportMacro = target.GetExportMacro())
@@ -666,6 +661,15 @@
     targetOptions.AddDefine(exportMacro);
     }
 
+  // only needed for midl 
+  Options targetOptionsExclIntDir = targetOptions;
+
+  // Add a definition for the configuration name.
+  std::string configDefine = "CMAKE_INTDIR=\"";
+  configDefine += configName;
+  configDefine += "\"";
+  targetOptions.AddDefine(configDefine);
+
   // The intermediate directory name consists of a directory for the
   // target and a subdirectory for the configuration name.
   std::string intermediateDir = this->GetTargetDirectory(target);
@@ -776,7 +780,13 @@
     tool = "VFMIDLTool";
     }
   fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
-  targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n");
+
+  // workaround for bug in midl which chokes on the quoted defines handed from the ide
+  targetOptionsExclIntDir.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n");
+  std::string configDefineEsc = this->EscapeForShell(configDefine.c_str(), true);
+  configDefineEsc = this->EscapeForXML(configDefineEsc.c_str());
+  fout << "\t\t\t\tAdditionalOptions=\"/D" + configDefineEsc + "\"\n";
+
   fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
   if( this->PlatformName == "x64" )
     {

