[CMake] Visual C++ 2005: Precompiled headers patch + STATIC_LIBRARY_FLAGS support for .lib type projects

speedy speedy at 3d-io.com
Mon Apr 2 12:38:17 EDT 2007


Hello CMake crew,

      someone might find this useful. :)


Index: P:/Elasticity_tools_and_libs/cmake-2.4.6/Source/cmLocalVisualStudio7Generator.cxx
===================================================================
--- P:/Elasticity_tools_and_libs/cmake-2.4.6/Source/cmLocalVisualStudio7Generator.cxx   (revision 16)
+++ P:/Elasticity_tools_and_libs/cmake-2.4.6/Source/cmLocalVisualStudio7Generator.cxx   (working copy)
@@ -294,6 +294,8 @@
 cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
 {
   // option flags (some flags map to the same option)
+  {"UsePrecompiledHeader", "Yc", "Create Precompiled Header",             "1"},
+  {"UsePrecompiledHeader", "Yu", "Use Precompiled Header",                "2"},
   {"BasicRuntimeChecks", "GZ", "Stack frame checks",                      "1"},
   {"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks", "3"},
   {"BasicRuntimeChecks", "RTCs", "Stack frame checks",                    "1"},
@@ -746,10 +748,14 @@
       "$(OutDir)/" + targetFullName;
     fout << "\t\t\t<Tool\n"
          << "\t\t\t\tName=\"VCLibrarianTool\"\n";
-    if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
-      {
-      fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
-      }
+       const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS");
+       std::string additionalOptions = extraLinkOptions;
+       if( libflags != NULL )
+               additionalOptions += libflags;
+       if( additionalOptions != "" )
+       {
+               fout << "\t\t\t\tAdditionalOptions=\"" << additionalOptions << "\"\n";
+       }
     fout << "\t\t\t\tOutputFile=\""
          << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
     break;
@@ -1129,6 +1135,10 @@
              std::ostream &fout, const char *libName, 
              std::vector<std::string> *configs)
 {
+  // create a map of xml tags to the values they should have in the output
+  // for example, "BufferSecurityCheck" = "TRUE"
+  std::map<cmStdString, cmStdString> flagMap;
+
   const std::vector<const cmSourceFile *> &sourceFiles =
     sg->GetSourceFiles();
   // If the group is empty, don't write it at all.
@@ -1194,6 +1204,12 @@
         compileFlags += " /TC ";
         }
       }
+         // 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], compileFlags);
+
     // Check for extra object-file dependencies.
     const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS");
     if(deps)
@@ -1264,6 +1280,14 @@
           fout << ">\n";
           fout << "\t\t\t\t\t<Tool\n"
                << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
+
+                 // Now copy the flag map into the xml for the file
+                 for(std::map<cmStdString, cmStdString>::iterator m = flagMap.begin();
+                         m != flagMap.end(); ++m)
+                 {
+                         fout << "\t\t\t\t\t" << m->first << "=\"" << m->second << "\"\n";
+                 }
+
           if(compileFlags.size())
             {
             std::string compileFlagsCopy = compileFlags;
  

-- 
Best regards,
 speedy                          mailto:speedy at 3d-io.com



More information about the CMake mailing list