[Cmake-commits] [cmake-commits] hoffman committed cmLocalGenerator.h 1.113 1.114 cmMakefile.cxx 1.511 1.512 cmSourceGroup.cxx 1.20 1.21 cmSourceGroup.h 1.20 1.21 cmVisualStudio10TargetGenerator.cxx 1.9 1.10 cmVisualStudio10TargetGenerator.h 1.4 1.5

cmake-commits at cmake.org cmake-commits at cmake.org
Sat Jul 11 00:05:22 EDT 2009


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

Modified Files:
	cmLocalGenerator.h cmMakefile.cxx cmSourceGroup.cxx 
	cmSourceGroup.h cmVisualStudio10TargetGenerator.cxx 
	cmVisualStudio10TargetGenerator.h 
Log Message:
ENH: add group support and fix borland error


Index: cmSourceGroup.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceGroup.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmSourceGroup.cxx	16 May 2008 20:56:41 -0000	1.20
--- cmSourceGroup.cxx	11 Jul 2009 04:05:20 -0000	1.21
***************
*** 24,31 ****
  
  //----------------------------------------------------------------------------
! cmSourceGroup::cmSourceGroup(const char* name, const char* regex): Name(name)
  {
    this->Internal = new cmSourceGroupInternals;
    this->SetGroupRegex(regex);
  }
  
--- 24,38 ----
  
  //----------------------------------------------------------------------------
! cmSourceGroup::cmSourceGroup(const char* name, const char* regex,
!                              const char* parentName): Name(name)
  {
    this->Internal = new cmSourceGroupInternals;
    this->SetGroupRegex(regex);
+   if(parentName)
+     {
+     this->FullName = parentName;
+     this->FullName += "\\";
+     }
+   this->FullName += this->Name;
  }
  
***************
*** 40,43 ****
--- 47,51 ----
  {
    this->Name = r.Name;
+   this->FullName = r.FullName;
    this->GroupRegex = r.GroupRegex;
    this->GroupFiles = r.GroupFiles;
***************
*** 81,84 ****
--- 89,98 ----
    return this->Name.c_str();
  }
+ 
+ //----------------------------------------------------------------------------
+ const char* cmSourceGroup::GetFullName() const
+ {
+   return this->FullName.c_str();
+ }
    
  //----------------------------------------------------------------------------

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.113
retrieving revision 1.114
diff -C 2 -d -r1.113 -r1.114
*** cmLocalGenerator.h	25 Jun 2009 20:41:55 -0000	1.113
--- cmLocalGenerator.h	11 Jul 2009 04:05:20 -0000	1.114
***************
*** 303,306 ****
--- 303,310 ----
    std::string ConstructComment(const cmCustomCommand& cc,
                                 const char* default_comment = "");
+   // Compute object file names.
+   std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,
+                                              std::string const& dir_max,
+                                              bool* hasSourceExtension = 0);
  
  protected:
***************
*** 347,354 ****
      std::vector<std::string> const& configurationTypes);
  
-   // Compute object file names.
-   std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,
-                                              std::string const& dir_max,
-                                              bool* hasSourceExtension = 0);
    std::string& CreateSafeUniqueObjectFileName(const char* sin,
                                                std::string const& dir_max);
--- 351,354 ----

Index: cmVisualStudio10TargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudio10TargetGenerator.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C 2 -d -r1.4 -r1.5
*** cmVisualStudio10TargetGenerator.h	10 Jul 2009 13:12:39 -0000	1.4
--- cmVisualStudio10TargetGenerator.h	11 Jul 2009 04:05:20 -0000	1.5
***************
*** 27,30 ****
--- 27,31 ----
  class cmLocalVisualStudio7Generator;
  class cmComputeLinkInformation;
+ #include "cmSourceGroup.h"
  
  class cmVisualStudio10TargetGenerator
***************
*** 75,78 ****
--- 76,82 ----
                    std::string const& configName);
    void ComputeObjectNames();
+   void WriteGroupSources(const char* name,
+                          std::vector<cmSourceFile*> const& sources,
+                          std::vector<cmSourceGroup>& );
  private:
    std::string ModuleDefinitionFile;

Index: cmSourceGroup.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceGroup.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmSourceGroup.h	16 May 2008 20:56:41 -0000	1.20
--- cmSourceGroup.h	11 Jul 2009 04:05:20 -0000	1.21
***************
*** 38,42 ****
  {
  public:
!   cmSourceGroup(const char* name, const char* regex);
    cmSourceGroup(cmSourceGroup const& r);
    ~cmSourceGroup();
--- 38,43 ----
  {
  public:
!   cmSourceGroup(const char* name, const char* regex,
!                 const char* parentName=0);
    cmSourceGroup(cmSourceGroup const& r);
    ~cmSourceGroup();
***************
*** 67,70 ****
--- 68,76 ----
     */
    const char* GetName() const;
+ 
+   /**
+    * Get the full path name for group.
+    */
+   const char* GetFullName() const;
    
    /**
***************
*** 108,111 ****
--- 114,119 ----
     */
    std::string Name;
+   // Full path to group
+   std::string FullName;
    
    /**

Index: cmVisualStudio10TargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudio10TargetGenerator.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -C 2 -d -r1.9 -r1.10
*** cmVisualStudio10TargetGenerator.cxx	10 Jul 2009 16:26:39 -0000	1.9
--- cmVisualStudio10TargetGenerator.cxx	11 Jul 2009 04:05:20 -0000	1.10
***************
*** 332,364 ****
  }
  void cmVisualStudio10TargetGenerator::WriteGroups()
! {
!   // This should create a target.vcxproj.filters file
!   // something like this:
    
! /*
!   <?xml version="1.0" encoding="utf-8"?>
! <Project ToolsVersion="4.0" 
! xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
!   <ItemGroup>
!     <CustomBuild Include="..\CMakeLists.txt" />
!   </ItemGroup>
!   <ItemGroup>
!     <Filter Include="Source Files">
!       <UniqueIdentifier>{05072589-c7be-439a-8fd7-5db6ee5008a9}
!       </UniqueIdentifier>
!     </Filter>
!   </ItemGroup>
!   <ItemGroup>
!     <ClCompile Include="..\foo.c">
!       <Filter>Source Files</Filter>
!     </ClCompile>
!     <ClCompile Include="..\testCCompiler.c">
!       <Filter>Source Files</Filter>
!     </ClCompile>
!   </ItemGroup>
! </Project>
! */
  }
  
  
  void cmVisualStudio10TargetGenerator::WriteObjSources()
--- 332,466 ----
  }
  void cmVisualStudio10TargetGenerator::WriteGroups()
! { 
!   // collect up group information
!   std::vector<cmSourceGroup> sourceGroups = 
!     this->Makefile->GetSourceGroups();
!   std::vector<cmSourceFile*>  classes = this->Target->GetSourceFiles();
    
!   std::set<cmSourceGroup*> groupsUsed;
!   std::vector<cmSourceFile*> clCompile;
!   std::vector<cmSourceFile*> customBuild;
!   std::vector<cmSourceFile*> none;
!   
!   for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); 
!       s != classes.end(); s++)
!     {
!     cmSourceFile* sf = *s; 
!     std::string const& source = sf->GetFullPath();
!     cmSourceGroup& sourceGroup = 
!       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
!     groupsUsed.insert(&sourceGroup);
!     const char* lang = sf->GetLanguage();
!     if(!lang)
!       {
!       lang = "None";
!       }
!     if(lang[0] == 'C')
!       {
!       clCompile.push_back(sf);
!       }
!     else if(sf->GetCustomCommand())
!       {
!       customBuild.push_back(sf);
!       }
!     else
!       {
!       none.push_back(sf);
!       }
!     }
!   // Write out group file
!   std::string path =  this->Makefile->GetStartOutputDirectory();
!   path += "/";
!   path += this->Target->GetName();
!   path += ".vcxproj.filters";
!   cmGeneratedFileStream fout(path.c_str());
!   char magic[] = {0xEF,0xBB, 0xBF};
!   fout.write(magic, 3);
!   cmGeneratedFileStream* save = this->BuildFileStream;
!   this->BuildFileStream = & fout;
!   this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
!                     "<Project "
!                     "ToolsVersion=\"4.0\" "
!                     "xmlns=\"http://schemas.microsoft.com/"
!                     "developer/msbuild/2003\">\n",
!                     0);
!   this->WriteGroupSources("ClCompile", clCompile, sourceGroups);
!   this->WriteGroupSources("CustomBuild", customBuild, sourceGroups);
! 
!   this->WriteString("<ItemGroup>\n", 1);
!   for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
!       g != groupsUsed.end(); ++g)
!     {
!     cmSourceGroup* sg = *g;
!     const char* name = sg->GetFullName();
!     if(strlen(name) != 0)
!       {
!       this->WriteString("<Filter Include=\"", 2);
!       (*this->BuildFileStream) << name << "\">\n";
!       std::string guidName = "SG_Filter_";
!       guidName += name;
!       this->GlobalGenerator->CreateGUID(guidName.c_str());
!       this->WriteString("<UniqueIdentifier>", 3);
!       std::string guid 
!         = this->GlobalGenerator->GetGUID(guidName.c_str());
!       (*this->BuildFileStream) 
!         << "{"
!         << guid << "}"
!         << "</UniqueIdentifier>\n";
!       this->WriteString("</Filter>\n", 2);
!       }
!     }
!   this->WriteString("</ItemGroup>\n", 1);
!   this->WriteGroupSources("None", none, sourceGroups);
!   this->WriteString("</Project>\n", 0);
!   // restore stream pointer
!   this->BuildFileStream = save;
  }
  
+ void 
+ cmVisualStudio10TargetGenerator::
+ WriteGroupSources(const char* name,
+                   std::vector<cmSourceFile*> const& sources,
+                   std::vector<cmSourceGroup>& sourceGroups)
+ {
+   this->WriteString("<ItemGroup>\n", 1);
+   for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
+       s != sources.end(); ++s)
+     {
+     cmSourceFile* sf = *s; 
+     std::string const& source = sf->GetFullPath();
+     cmSourceGroup& sourceGroup = 
+       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+     const char* filter = sourceGroup.GetFullName();
+     this->WriteString("<", 2); 
+     std::string path = source;
+     // custom command source are done with relative paths 
+     // so that the custom command display in the GUI
+     // the source groups have to EXACTLY match the string
+     // used in the .vcxproj file
+     if(sf->GetCustomCommand())
+       {
+       path = cmSystemTools::RelativePath(
+         this->Makefile->GetCurrentOutputDirectory(),
+         source.c_str());
+       }
+     this->ConvertToWindowsSlash(path);
+     (*this->BuildFileStream) << name << " Include=\""
+                              << path;
+     if(strlen(filter))
+       {
+       (*this->BuildFileStream) << "\">\n";
+       this->WriteString("<Filter>", 3);
+       (*this->BuildFileStream) << filter << "</Filter>\n";
+       this->WriteString("</", 2);
+       (*this->BuildFileStream) << name << ">\n";
+       }
+     else
+       {
+       (*this->BuildFileStream) << "\" />\n";
+       }
+     }
+   this->WriteString("</ItemGroup>\n", 1);
+ }
  
  void cmVisualStudio10TargetGenerator::WriteObjSources()
***************
*** 413,416 ****
--- 515,519 ----
          {
          std::string sourceFile = (*source)->GetFullPath();
+         this->ConvertToWindowsSlash(sourceFile);
          // output the source file
          this->WriteString("<ClCompile Include=\"", 2);
***************
*** 1026,1044 ****
    this->WriteString("<Midl>\n", 2);
    this->OutputIncludes(includes);
-   // Need this stuff, but there is an midl.xml file...
-   // should we look for .idl language?, and flags?
-   /*
-        <MkTypLibCompatible>false</MkTypLibCompatible>
-       <TargetEnvironment>Win32</TargetEnvironment>
-       <GenerateStublessProxies>true</GenerateStublessProxies>
-       <TypeLibraryName>%(FileName).tlb</TypeLibraryName>
-       <OutputDirectory>$(IntDir)\</OutputDirectory>
-       <HeaderFileName>%(FileName).h</HeaderFileName>
-       <DllDataFileName>
-       </DllDataFileName>
-       <InterfaceIdentifierFileName>%(FileName)_i.c
-       </InterfaceIdentifierFileName>
-       <ProxyFileName>%(FileName)_p.c</ProxyFileName>
-   */
    this->WriteString("</Midl>\n", 2);
  }
--- 1129,1132 ----

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.511
retrieving revision 1.512
diff -C 2 -d -r1.511 -r1.512
*** cmMakefile.cxx	25 Jun 2009 20:41:55 -0000	1.511
--- cmMakefile.cxx	11 Jul 2009 04:05:20 -0000	1.512
***************
*** 1959,1963 ****
    for(++i; i<=lastElement; ++i)
      {
!     sg->AddChild(cmSourceGroup(name[i].c_str(), 0));
      sg = sg->lookupChild(name[i].c_str());
      }
--- 1959,1963 ----
    for(++i; i<=lastElement; ++i)
      {
!     sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
      sg = sg->lookupChild(name[i].c_str());
      }



More information about the Cmake-commits mailing list