[Cmake-commits] [cmake-commits] alex committed cmExtraCodeBlocksGenerator.cxx 1.20 1.21

cmake-commits at cmake.org cmake-commits at cmake.org
Sun Mar 8 15:34:00 EDT 2009


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

Modified Files:
	cmExtraCodeBlocksGenerator.cxx 
Log Message:

ENH: automatically add headers of implementation file to the codeblocks project file

Alex



Index: cmExtraCodeBlocksGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExtraCodeBlocksGenerator.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmExtraCodeBlocksGenerator.cxx	9 Jan 2009 23:04:20 -0000	1.20
--- cmExtraCodeBlocksGenerator.cxx	8 Mar 2009 19:33:58 -0000	1.21
***************
*** 260,263 ****
--- 260,295 ----
      }
  
+   // The following loop tries to add header files matching to implementation
+   // files to the project. It does that by iterating over all source files,
+   // replacing the file name extension with ".h" and checks whether such a 
+   // file exists. If it does, it is inserted into the map of files.
+   // A very similar version of that code exists also in the kdevelop
+   // project generator.
+   for (std::map<std::string, std::string>::const_iterator 
+        sit=sourceFiles.begin();
+        sit!=sourceFiles.end();
+        ++sit)
+     {
+     std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
+     headerBasename+="/";
+     headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first);
+ 
+     // check if there's a matching header around
+     for(std::vector<std::string>::const_iterator
+         ext = mf->GetHeaderExtensions().begin();
+         ext !=  mf->GetHeaderExtensions().end(); 
+         ++ext)
+       {
+       std::string hname=headerBasename;
+       hname += ".";
+       hname += *ext;
+       if(cmSystemTools::FileExists(hname.c_str()))
+         {
+         sourceFiles[hname] = hname;
+         break;
+         }
+       }
+     }
+ 
    // insert all used source files in the CodeBlocks project
    for (std::map<std::string, std::string>::const_iterator 
***************
*** 265,272 ****
         sit!=sourceFiles.end();
         ++sit)
!   {
!   fout<<"      <Unit filename=\""<<sit->first <<"\">\n"
!         "      </Unit>\n";
!   }
  
    fout<<"   </Project>\n"
--- 297,304 ----
         sit!=sourceFiles.end();
         ++sit)
!     {
!     fout<<"      <Unit filename=\""<<sit->first <<"\">\n"
!           "      </Unit>\n";
!     }
  
    fout<<"   </Project>\n"



More information about the Cmake-commits mailing list