[Cmake-commits] [cmake-commits] king committed cmLocalVisualStudio7Generator.cxx 1.254 1.255 cmLocalVisualStudio7Generator.h 1.60 1.61 cmMakefileExecutableTargetGenerator.cxx 1.63 1.64 cmMakefileLibraryTargetGenerator.cxx 1.79 1.80 cmMakefileTargetGenerator.cxx 1.123 1.124 cmMakefileTargetGenerator.h 1.32 1.33 cmVisualStudio10TargetGenerator.cxx 1.18 1.19

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Sep 29 16:39:09 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv25207/Source

Modified Files:
	cmLocalVisualStudio7Generator.cxx 
	cmLocalVisualStudio7Generator.h 
	cmMakefileExecutableTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmMakefileTargetGenerator.h 
	cmVisualStudio10TargetGenerator.cxx 
Log Message:
Fix use of module .def files for MS tools

We recognize .def source files and map them to the /DEF:<file> option in
the MSVC tools.  Previously this worked only for shared libraries.  This
commit cleans up the implementation and makes it work for executables
too.  See issue #9613.


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.254
retrieving revision 1.255
diff -C 2 -d -r1.254 -r1.255
*** cmLocalVisualStudio7Generator.cxx	28 Sep 2009 15:42:47 -0000	1.254
--- cmLocalVisualStudio7Generator.cxx	29 Sep 2009 20:39:07 -0000	1.255
***************
*** 888,891 ****
--- 888,897 ----
                        cmLocalVisualStudio7GeneratorLinkFlagTable);
    linkOptions.Parse(extraLinkOptions.c_str());
+   if(!this->ModuleDefinitionFile.empty())
+     {
+     std::string defFile =
+       this->ConvertToXMLOutputPath(this->ModuleDefinitionFile.c_str());
+     linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
+     }
    switch(target.GetType())
      {
***************
*** 961,965 ****
      this->OutputLibraryDirectories(fout, cli.GetDirectories());
      fout << "\"\n";
-     this->OutputModuleDefinitionFile(fout, target);
      temp = target.GetDirectory(configName);
      temp += "/";
--- 967,970 ----
***************
*** 1081,1104 ****
  }
  
- void cmLocalVisualStudio7Generator
- ::OutputModuleDefinitionFile(std::ostream& fout,
-                              cmTarget &target)
- {
-   std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
-   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-       i != classes.end(); i++)
-     {
-     cmSourceFile* sf = *i;
-     if(cmSystemTools::UpperCase(sf->GetExtension()) == "DEF")
-       {
-       fout << "\t\t\t\tModuleDefinitionFile=\""
-            << this->ConvertToXMLOutputPath(sf->GetFullPath().c_str())
-            << "\"\n";
-       return;
-       }
-     }
- 
- }
- 
  //----------------------------------------------------------------------------
  void
--- 1086,1089 ----
***************
*** 1175,1178 ****
--- 1160,1164 ----
  
    // get the classes from the source lists then add them to the groups
+   this->ModuleDefinitionFile = "";
    std::vector<cmSourceFile*>const & classes = target.GetSourceFiles();
    for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -C 2 -d -r1.60 -r1.61
*** cmLocalVisualStudio7Generator.h	28 Sep 2009 15:42:47 -0000	1.60
--- cmLocalVisualStudio7Generator.h	29 Sep 2009 20:39:07 -0000	1.61
***************
*** 103,107 ****
    void OutputLibraryDirectories(std::ostream& fout,
                                  std::vector<std::string> const& dirs);
-   void OutputModuleDefinitionFile(std::ostream& fout, cmTarget &target);
    void WriteProjectStart(std::ostream& fout, const char *libName,
                           cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
--- 103,106 ----

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.79
retrieving revision 1.80
diff -C 2 -d -r1.79 -r1.80
*** cmMakefileLibraryTargetGenerator.cxx	28 Sep 2009 15:42:48 -0000	1.79
--- cmMakefileLibraryTargetGenerator.cxx	29 Sep 2009 20:39:07 -0000	1.80
***************
*** 147,171 ****
    this->LocalGenerator->AddConfigVariableFlags
      (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
!   if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") 
!                                         || this->Makefile->IsOn("MINGW")))
!     {
!     const std::vector<cmSourceFile*>& sources = 
!       this->Target->GetSourceFiles();
!     for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
!         i != sources.end(); ++i)
!       {
!       cmSourceFile* sf = *i;
!       if(sf->GetExtension() == "def")
!         {
!         extraFlags += " ";
!         extraFlags += 
!           this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
!         extraFlags += 
!           this->Convert(sf->GetFullPath().c_str(),
!                         cmLocalGenerator::START_OUTPUT,
!                         cmLocalGenerator::SHELL);
!         }
!       }
!     }
    this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
  }
--- 147,152 ----
    this->LocalGenerator->AddConfigVariableFlags
      (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
!   this->AddModuleDefinitionFlag(extraFlags);
! 
    this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
  }
***************
*** 192,197 ****
    this->LocalGenerator->AddConfigVariableFlags
      (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
  
-   // TODO: .def files should be supported here also.
    this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
  }
--- 173,178 ----
    this->LocalGenerator->AddConfigVariableFlags
      (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
+   this->AddModuleDefinitionFlag(extraFlags);
  
    this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
  }
***************
*** 219,223 ****
      (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
  
-   // TODO: .def files should be supported here also.
    this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
  }
--- 200,203 ----

Index: cmVisualStudio10TargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudio10TargetGenerator.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** cmVisualStudio10TargetGenerator.cxx	29 Sep 2009 20:38:43 -0000	1.18
--- cmVisualStudio10TargetGenerator.cxx	29 Sep 2009 20:39:07 -0000	1.19
***************
*** 1126,1129 ****
--- 1126,1134 ----
    linkOptions.AddFlag("ProgramDataBaseFileName", pdb.c_str());
    linkOptions.Parse(flags.c_str());
+   if(!this->ModuleDefinitionFile.empty())
+     {
+     linkOptions.AddFlag("ModuleDefinitionFile",
+                         this->ModuleDefinitionFile.c_str());
+     }
    linkOptions.OutputAdditionalOptions(*this->BuildFileStream, "      ", "");
    linkOptions.OutputFlagMap(*this->BuildFileStream, "      ");

Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.63
retrieving revision 1.64
diff -C 2 -d -r1.63 -r1.64
*** cmMakefileExecutableTargetGenerator.cxx	28 Sep 2009 15:42:47 -0000	1.63
--- cmMakefileExecutableTargetGenerator.cxx	29 Sep 2009 20:39:07 -0000	1.64
***************
*** 244,247 ****
--- 244,249 ----
      (linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
  
+   this->AddModuleDefinitionFlag(linkFlags);
+ 
    // Construct a list of files associated with this executable that
    // may need to be cleaned.

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.123
retrieving revision 1.124
diff -C 2 -d -r1.123 -r1.124
*** cmMakefileTargetGenerator.cxx	28 Sep 2009 15:42:48 -0000	1.123
--- cmMakefileTargetGenerator.cxx	29 Sep 2009 20:39:07 -0000	1.124
***************
*** 171,174 ****
--- 171,178 ----
          this->ExternalObjects.push_back((*source)->GetFullPath());
          }
+       else if(cmSystemTools::UpperCase((*source)->GetExtension()) == "DEF")
+         {
+         this->ModuleDefinitionFile = (*source)->GetFullPath();
+         }
        else
          {
***************
*** 1735,1736 ****
--- 1739,1764 ----
      }
  }
+ 
+ //----------------------------------------------------------------------------
+ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
+ {
+   if(this->ModuleDefinitionFile.empty())
+     {
+     return;
+     }
+ 
+   // TODO: Create a per-language flag variable.
+   const char* defFileFlag =
+     this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
+   if(!defFileFlag)
+     {
+     return;
+     }
+ 
+   // Append the flag and value.
+   std::string flag = defFileFlag;
+   flag += this->Convert(this->ModuleDefinitionFile.c_str(),
+                         cmLocalGenerator::START_OUTPUT,
+                         cmLocalGenerator::SHELL);
+   this->LocalGenerator->AppendFlags(flags, flag.c_str());
+ }

Index: cmMakefileTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C 2 -d -r1.32 -r1.33
*** cmMakefileTargetGenerator.h	28 Sep 2009 15:42:48 -0000	1.32
--- cmMakefileTargetGenerator.h	29 Sep 2009 20:39:07 -0000	1.33
***************
*** 187,190 ****
--- 187,193 ----
    std::vector<std::string> ExternalObjects;
  
+   // The windows module definition source file (.def), if any.
+   std::string ModuleDefinitionFile;
+ 
    // Set of object file names that will be built in this directory.
    std::set<cmStdString> ObjectFiles;
***************
*** 215,218 ****
--- 218,224 ----
    void AddFortranFlags(std::string& flags);
  
+   // Helper to add flag for windows .def file.
+   void AddModuleDefinitionFlag(std::string& flags);
+ 
    //==================================================================
    // Convenience routines that do nothing more than forward to



More information about the Cmake-commits mailing list