[CMake] PDBs patch for VS2010 generator

Robert Goulet Robert.Goulet at autodesk.com
Wed Aug 18 14:59:48 EDT 2010


Hello the world,

I would like to submit the following changes to the cmake repository until someone finds a better solution.

This fix an issue with the Visual Studio 2010 generator:

When none of the options /Z7, /Zi and /ZI are specified in the cmake project settings, the project will open in the editor with "Program Database" as the default debug information format, ending up always generating PDBs regardless of project configuration.

This change will modify the output project file so that if the debug information format is not specified in the cmake project settings, it will default to no PDB generated, just like all the previous other Visual Studio versions. This problem comes from the fact that Microsoft changed the default setting of the debug information format to be "Program Database" instead of "Disabled", and not an error from cmake itself.

The changes are as follow:

cmVisualStudio10TargetGenerator.cxx : around line 1037, function cmVisualStudio10TargetGenerator::WriteClOptions

   ...
   clOptions.OutputAdditionalOptions(*this->BuildFileStream, "      ", "");
   this->OutputIncludes(includes);
   clOptions.OutputFlagMap(*this->BuildFileStream, "      ");
+
+  //If not in debug mode, write the DebugInformationFormat
+  //field without value so PDBs don't get generated uselessly.
+  if( !clOptions.IsDebug() )
+  {
+    this->WriteString("<DebugInformationFormat></DebugInformationFormat>\n", 3);
+  }
+
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
                                             "\n");
   this->WriteString("<AssemblerListingLocation>", 3);
   ...



Robert Goulet
Software Development Manager
Autodesk Media & Entertainment

Autodesk, Inc.
10 Duke
Montreal, QC H3C 2L7

Direct 514 954-3911

[cid:image001.gif at 01CB3EE3.93E2BE40]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100818/5617fffb/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 651 bytes
Desc: image001.gif
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100818/5617fffb/attachment-0001.gif>


More information about the CMake mailing list