| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778 | 
							- /*============================================================================
 
-   CMake - Cross Platform Makefile Generator
 
-   Copyright 2004-2009 Kitware, Inc.
 
-   Copyright 2004 Alexander Neundorf ([email protected])
 
-   Distributed under the OSI-approved BSD License (the "License");
 
-   see accompanying file Copyright.txt for details.
 
-   This software is distributed WITHOUT ANY WARRANTY; without even the
 
-   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-   See the License for more information.
 
- ============================================================================*/
 
- #include "cmExtraCodeBlocksGenerator.h"
 
- #include "cmGlobalUnixMakefileGenerator3.h"
 
- #include "cmLocalUnixMakefileGenerator3.h"
 
- #include "cmMakefile.h"
 
- #include "cmake.h"
 
- #include "cmSourceFile.h"
 
- #include "cmGeneratedFileStream.h"
 
- #include "cmTarget.h"
 
- #include "cmSystemTools.h"
 
- #include "cmXMLSafe.h"
 
- #include <cmsys/SystemTools.hxx>
 
- /* Some useful URLs:
 
- Homepage:
 
- http://www.codeblocks.org
 
- File format docs:
 
- http://wiki.codeblocks.org/index.php?title=File_formats_description
 
- http://wiki.codeblocks.org/index.php?title=Workspace_file
 
- http://wiki.codeblocks.org/index.php?title=Project_file
 
- Discussion:
 
- http://forums.codeblocks.org/index.php/topic,6789.0.html
 
- */
 
- //----------------------------------------------------------------------------
 
- void cmExtraCodeBlocksGenerator
 
- ::GetDocumentation(cmDocumentationEntry& entry, const char*) const
 
- {
 
-   entry.Name = this->GetName();
 
-   entry.Brief = "Generates CodeBlocks project files.";
 
-   entry.Full =
 
-     "Project files for CodeBlocks will be created in the top directory "
 
-     "and in every subdirectory which features a CMakeLists.txt file "
 
-     "containing a PROJECT() call. "
 
-     "Additionally a hierarchy of makefiles is generated into the "
 
-     "build tree.  The appropriate make program can build the project through "
 
-     "the default make target.  A \"make install\" target is also provided.";
 
- }
 
- cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
 
- :cmExternalMakefileProjectGenerator()
 
- {
 
- #if defined(_WIN32)
 
-   this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
 
-   this->SupportedGlobalGenerators.push_back("NMake Makefiles");
 
- // disable until somebody actually tests it:
 
- //  this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
 
- #endif
 
-   this->SupportedGlobalGenerators.push_back("Unix Makefiles");
 
- }
 
- void cmExtraCodeBlocksGenerator::Generate()
 
- {
 
-   // for each sub project in the project create a codeblocks project
 
-   for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
 
-        it = this->GlobalGenerator->GetProjectMap().begin();
 
-       it!= this->GlobalGenerator->GetProjectMap().end();
 
-       ++it)
 
-     {
 
-     // create a project file
 
-     this->CreateProjectFile(it->second);
 
-     }
 
- }
 
- /* create the project file */
 
- void cmExtraCodeBlocksGenerator::CreateProjectFile(
 
-                                      const std::vector<cmLocalGenerator*>& lgs)
 
- {
 
-   const cmMakefile* mf=lgs[0]->GetMakefile();
 
-   std::string outputDir=mf->GetStartOutputDirectory();
 
-   std::string projectName=mf->GetProjectName();
 
-   std::string filename=outputDir+"/";
 
-   filename+=projectName+".cbp";
 
-   std::string sessionFilename=outputDir+"/";
 
-   sessionFilename+=projectName+".layout";
 
-   this->CreateNewProjectFile(lgs, filename);
 
- }
 
- /* Tree is used to create a "Virtual Folder" in CodeBlocks, in which all
 
-  CMake files this project depends on will be put. This means additionally
 
-  to the "Sources" and "Headers" virtual folders of CodeBlocks, there will
 
-  now also be a "CMake Files" virtual folder.
 
-  Patch by Daniel Teske <daniel.teske AT nokia.com> (which use C::B project
 
-  files in QtCreator).*/
 
- struct Tree
 
- {
 
-   std::string path; //only one component of the path
 
-   std::vector<Tree> folders;
 
-   std::vector<std::string> files;
 
-   void InsertPath(const std::vector<std::string>& splitted,
 
-                   std::vector<std::string>::size_type start,
 
-                   const std::string& fileName);
 
-   void BuildVirtualFolder(std::string& virtualFolders) const;
 
-   void BuildVirtualFolderImpl(std::string& virtualFolders,
 
-                               const std::string& prefix) const;
 
-   void BuildUnit(std::string& unitString, const std::string& fsPath) const;
 
-   void BuildUnitImpl(std::string& unitString,
 
-                      const std::string& virtualFolderPath,
 
-                      const std::string& fsPath) const;
 
- };
 
- void Tree::InsertPath(const std::vector<std::string>& splitted,
 
-                       std::vector<std::string>::size_type start,
 
-                       const std::string& fileName)
 
- {
 
-   if (start == splitted.size())
 
-     {
 
-     files.push_back(fileName);
 
-     return;
 
-     }
 
-   for (std::vector<Tree>::iterator
 
-        it = folders.begin();
 
-        it != folders.end();
 
-        ++it)
 
-     {
 
-     if ((*it).path == splitted[start])
 
-       {
 
-       if (start + 1 <  splitted.size())
 
-         {
 
-         it->InsertPath(splitted, start + 1, fileName);
 
-         return;
 
-         }
 
-       else
 
-         {
 
-         // last part of splitted
 
-         it->files.push_back(fileName);
 
-         return;
 
-         }
 
-       }
 
-     }
 
-   // Not found in folders, thus insert
 
-   Tree newFolder;
 
-   newFolder.path = splitted[start];
 
-   if (start + 1 <  splitted.size())
 
-     {
 
-     newFolder.InsertPath(splitted, start + 1, fileName);
 
-     folders.push_back(newFolder);
 
-     return;
 
-     }
 
-   else
 
-     {
 
-     // last part of splitted
 
-     newFolder.files.push_back(fileName);
 
-     folders.push_back(newFolder);
 
-     return;
 
-     }
 
- }
 
- void Tree::BuildVirtualFolder(std::string& virtualFolders) const
 
- {
 
-   virtualFolders += "<Option virtualFolders=\"CMake Files\\;";
 
-   for (std::vector<Tree>::const_iterator it = folders.begin();
 
-      it != folders.end();
 
-      ++it)
 
-     {
 
-     it->BuildVirtualFolderImpl(virtualFolders, "");
 
-     }
 
-   virtualFolders += "\" />";
 
- }
 
- void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
 
-                                   const std::string& prefix) const
 
- {
 
-   virtualFolders += "CMake Files\\" + prefix +  path + "\\;";
 
-   for (std::vector<Tree>::const_iterator it = folders.begin();
 
-        it != folders.end();
 
-      ++it)
 
-     {
 
-     it->BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
 
-     }
 
- }
 
- void Tree::BuildUnit(std::string& unitString, const std::string& fsPath) const
 
- {
 
-   for (std::vector<std::string>::const_iterator it = files.begin();
 
-        it != files.end();
 
-        ++it)
 
-     {
 
-     unitString += "      <Unit filename=\"" + fsPath + *it + "\">\n";
 
-     unitString += "          <Option virtualFolder=\"CMake Files\\\" />\n";
 
-     unitString += "      </Unit>\n";
 
-     }
 
-   for (std::vector<Tree>::const_iterator it = folders.begin();
 
-      it != folders.end();
 
-      ++it)
 
-     {
 
-     it->BuildUnitImpl(unitString, "", fsPath);
 
-     }
 
- }
 
- void Tree::BuildUnitImpl(std::string& unitString,
 
-                          const std::string& virtualFolderPath,
 
-                          const std::string& fsPath) const
 
- {
 
-   for (std::vector<std::string>::const_iterator it = files.begin();
 
-        it != files.end();
 
-        ++it)
 
-     {
 
-     unitString += "      <Unit filename=\"" +fsPath+path+ "/" + *it + "\">\n";
 
-     unitString += "          <Option virtualFolder=\"CMake Files\\"
 
-                + virtualFolderPath + path + "\\\" />\n";
 
-     unitString += "      </Unit>\n";
 
-     }
 
-   for (std::vector<Tree>::const_iterator it = folders.begin();
 
-      it != folders.end();
 
-      ++it)
 
-     {
 
-     it->BuildUnitImpl(unitString,
 
-                       virtualFolderPath + path + "\\", fsPath + path + "/");
 
-     }
 
- }
 
- void cmExtraCodeBlocksGenerator
 
-   ::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
 
-                          const std::string& filename)
 
- {
 
-   const cmMakefile* mf=lgs[0]->GetMakefile();
 
-   cmGeneratedFileStream fout(filename.c_str());
 
-   if(!fout)
 
-     {
 
-     return;
 
-     }
 
-   Tree tree;
 
-   // build tree of virtual folders
 
-   for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
 
-           it = this->GlobalGenerator->GetProjectMap().begin();
 
-          it != this->GlobalGenerator->GetProjectMap().end();
 
-          ++it)
 
-     {
 
-     // Collect all files
 
-     std::vector<std::string> listFiles;
 
-     for (std::vector<cmLocalGenerator *>::const_iterator
 
-          jt = it->second.begin();
 
-          jt != it->second.end();
 
-          ++jt)
 
-       {
 
-       const std::vector<std::string> & files =
 
-                                           (*jt)->GetMakefile()->GetListFiles();
 
-       listFiles.insert(listFiles.end(), files.begin(), files.end());
 
-       }
 
-     // Convert
 
-     const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
 
-     for (std::vector<std::string>::const_iterator jt = listFiles.begin();
 
-          jt != listFiles.end();
 
-          ++jt)
 
-       {
 
-       // don't put cmake's own files into the project (#12110):
 
-       if (jt->find(cmakeRoot) == 0)
 
-         {
 
-         continue;
 
-         }
 
-       const std::string &relative = cmSystemTools::RelativePath(
 
-                          it->second[0]->GetMakefile()->GetHomeDirectory(),
 
-                          jt->c_str());
 
-       std::vector<std::string> splitted;
 
-       cmSystemTools::SplitPath(relative.c_str(), splitted, false);
 
-       // Split filename from path
 
-       std::string fileName = *(splitted.end()-1);
 
-       splitted.erase(splitted.end() - 1, splitted.end());
 
-       // We don't want paths with CMakeFiles in them
 
-       // or do we?
 
-       // In speedcrunch those where purely internal
 
-       if (splitted.size() >= 1
 
-           && relative.find("CMakeFiles") == std::string::npos)
 
-         {
 
-         tree.InsertPath(splitted, 1, fileName);
 
-         }
 
-       }
 
-     }
 
-   // Now build a virtual tree string
 
-   std::string virtualFolders;
 
-   tree.BuildVirtualFolder(virtualFolders);
 
-   // And one for <Unit>
 
-   std::string unitFiles;
 
-   tree.BuildUnit(unitFiles, std::string(mf->GetHomeDirectory()) + "/");
 
-   // figure out the compiler
 
-   std::string compiler = this->GetCBCompilerId(mf);
 
-   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
 
-   fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"
 
-         "<CodeBlocks_project_file>\n"
 
-         "   <FileVersion major=\"1\" minor=\"6\" />\n"
 
-         "   <Project>\n"
 
-         "      <Option title=\"" << mf->GetProjectName()<<"\" />\n"
 
-         "      <Option makefile_is_custom=\"1\" />\n"
 
-         "      <Option compiler=\"" << compiler << "\" />\n"
 
-         "      "<<virtualFolders<<"\n"
 
-         "      <Build>\n";
 
-   this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str());
 
-   // add all executable and library targets and some of the GLOBAL
 
-   // and UTILITY targets
 
-   for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
 
-        lg!=lgs.end(); lg++)
 
-     {
 
-     cmMakefile* makefile=(*lg)->GetMakefile();
 
-     cmTargets& targets=makefile->GetTargets();
 
-     for (cmTargets::iterator ti = targets.begin();
 
-          ti != targets.end(); ti++)
 
-       {
 
-       switch(ti->second.GetType())
 
-         {
 
-         case cmTarget::GLOBAL_TARGET:
 
-           {
 
-           bool insertTarget = false;
 
-           // Only add the global targets from CMAKE_BINARY_DIR,
 
-           // not from the subdirs
 
-           if (strcmp(makefile->GetStartOutputDirectory(),
 
-                      makefile->GetHomeOutputDirectory())==0)
 
-             {
 
-             insertTarget = true;
 
-             // only add the "edit_cache" target if it's not ccmake, because
 
-             // this will not work within the IDE
 
-             if (ti->first == "edit_cache")
 
-               {
 
-               const char* editCommand = makefile->GetDefinition
 
-                                                         ("CMAKE_EDIT_COMMAND");
 
-               if (editCommand == 0)
 
-                 {
 
-                 insertTarget = false;
 
-                 }
 
-               else if (strstr(editCommand, "ccmake")!=NULL)
 
-                 {
 
-                 insertTarget = false;
 
-                 }
 
-               }
 
-             }
 
-           if (insertTarget)
 
-             {
 
-             this->AppendTarget(fout, ti->first.c_str(), 0,
 
-                                make.c_str(), makefile, compiler.c_str());
 
-             }
 
-           }
 
-           break;
 
-         case cmTarget::UTILITY:
 
-           // Add all utility targets, except the Nightly/Continuous/
 
-           // Experimental-"sub"targets as e.g. NightlyStart
 
-           if (((ti->first.find("Nightly")==0)   &&(ti->first!="Nightly"))
 
-              || ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous"))
 
-              || ((ti->first.find("Experimental")==0)
 
-                                                && (ti->first!="Experimental")))
 
-             {
 
-             break;
 
-             }
 
-           this->AppendTarget(fout, ti->first.c_str(), 0,
 
-                                  make.c_str(), makefile, compiler.c_str());
 
-           break;
 
-         case cmTarget::EXECUTABLE:
 
-         case cmTarget::STATIC_LIBRARY:
 
-         case cmTarget::SHARED_LIBRARY:
 
-         case cmTarget::MODULE_LIBRARY:
 
-           {
 
-           this->AppendTarget(fout, ti->first.c_str(), &ti->second,
 
-                              make.c_str(), makefile, compiler.c_str());
 
-           std::string fastTarget = ti->first;
 
-           fastTarget += "/fast";
 
-           this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
 
-                              make.c_str(), makefile, compiler.c_str());
 
-           }
 
-           break;
 
-         default:
 
-           break;
 
-         }
 
-       }
 
-     }
 
-   fout<<"      </Build>\n";
 
-   // Collect all used source files in the project
 
-   // Sort them into two containers, one for C/C++ implementation files
 
-   // which may have an acompanying header, one for all other files
 
-   std::map<std::string, cmSourceFile*> cFiles;
 
-   std::set<std::string> otherFiles;
 
-   for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
 
-        lg!=lgs.end(); lg++)
 
-     {
 
-     cmMakefile* makefile=(*lg)->GetMakefile();
 
-     cmTargets& targets=makefile->GetTargets();
 
-     for (cmTargets::iterator ti = targets.begin();
 
-          ti != targets.end(); ti++)
 
-       {
 
-       switch(ti->second.GetType())
 
-         {
 
-         case cmTarget::EXECUTABLE:
 
-         case cmTarget::STATIC_LIBRARY:
 
-         case cmTarget::SHARED_LIBRARY:
 
-         case cmTarget::MODULE_LIBRARY:
 
-         case cmTarget::UTILITY: // can have sources since 2.6.3
 
-           {
 
-           const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles();
 
-           for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
 
-                si!=sources.end(); si++)
 
-             {
 
-             // don't add source files which have the GENERATED property set:
 
-             if ((*si)->GetPropertyAsBool("GENERATED"))
 
-               {
 
-               continue;
 
-               }
 
-             // check whether it is a C/C++ implementation file
 
-             bool isCFile = false;
 
-             if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
 
-               {
 
-               for(std::vector<std::string>::const_iterator
 
-                   ext = mf->GetSourceExtensions().begin();
 
-                   ext !=  mf->GetSourceExtensions().end();
 
-                   ++ext)
 
-                 {
 
-                 if ((*si)->GetExtension() == *ext)
 
-                   {
 
-                   isCFile = true;
 
-                   break;
 
-                   }
 
-                 }
 
-               }
 
-             // then put it accordingly into one of the two containers
 
-             if (isCFile)
 
-               {
 
-               cFiles[(*si)->GetFullPath()] = *si ;
 
-               }
 
-             else
 
-               {
 
-               otherFiles.insert((*si)->GetFullPath());
 
-               }
 
-             }
 
-           }
 
-         default:  // intended fallthrough
 
-           break;
 
-         }
 
-       }
 
-     }
 
-   // 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, cmSourceFile*>::const_iterator
 
-        sit=cFiles.begin();
 
-        sit!=cFiles.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 it's already in the set, don't check if it exists on disk
 
-       std::set<std::string>::const_iterator headerIt=otherFiles.find(hname);
 
-       if (headerIt != otherFiles.end())
 
-         {
 
-         break;
 
-         }
 
-       if(cmSystemTools::FileExists(hname.c_str()))
 
-         {
 
-         otherFiles.insert(hname);
 
-         break;
 
-         }
 
-       }
 
-     }
 
-   // insert all source files in the CodeBlocks project
 
-   // first the C/C++ implementation files, then all others
 
-   for (std::map<std::string, cmSourceFile*>::const_iterator
 
-        sit=cFiles.begin();
 
-        sit!=cFiles.end();
 
-        ++sit)
 
-     {
 
-     fout<<"      <Unit filename=\""<< sit->first <<"\">\n"
 
-           "      </Unit>\n";
 
-     }
 
-   for (std::set<std::string>::const_iterator
 
-        sit=otherFiles.begin();
 
-        sit!=otherFiles.end();
 
-        ++sit)
 
-     {
 
-     fout<<"      <Unit filename=\""<< sit->c_str() <<"\">\n"
 
-           "      </Unit>\n";
 
-     }
 
-   // Add CMakeLists.txt
 
-   fout<<unitFiles;
 
-   fout<<"   </Project>\n"
 
-         "</CodeBlocks_project_file>\n";
 
- }
 
- // Generate the xml code for one target.
 
- void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
 
-                                               const char* targetName,
 
-                                               cmTarget* target,
 
-                                               const char* make,
 
-                                               const cmMakefile* makefile,
 
-                                               const char* compiler)
 
- {
 
-   std::string makefileName = makefile->GetStartOutputDirectory();
 
-   makefileName += "/Makefile";
 
-   fout<<"      <Target title=\"" << targetName << "\">\n";
 
-   if (target!=0)
 
-     {
 
-     int cbTargetType = this->GetCBTargetType(target);
 
-     std::string workingDir = makefile->GetStartOutputDirectory();
 
-     if ( target->GetType()==cmTarget::EXECUTABLE)
 
-       {
 
-       // Determine the directory where the executable target is created, and
 
-       // set the working directory to this dir.
 
-       const char* runtimeOutputDir = makefile->GetDefinition(
 
-                                              "CMAKE_RUNTIME_OUTPUT_DIRECTORY");
 
-       if (runtimeOutputDir != 0)
 
-         {
 
-         workingDir = runtimeOutputDir;
 
-         }
 
-       else
 
-         {
 
-         const char* executableOutputDir = makefile->GetDefinition(
 
-                                                      "EXECUTABLE_OUTPUT_PATH");
 
-         if (executableOutputDir != 0)
 
-           {
 
-           workingDir = executableOutputDir;
 
-           }
 
-         }
 
-       }
 
-     const char* buildType = makefile->GetDefinition("CMAKE_BUILD_TYPE");
 
-     fout<<"         <Option output=\"" << target->GetLocation(buildType)
 
-                             << "\" prefix_auto=\"0\" extension_auto=\"0\" />\n"
 
-           "         <Option working_dir=\"" << workingDir << "\" />\n"
 
-           "         <Option object_output=\"./\" />\n"
 
-           "         <Option type=\"" << cbTargetType << "\" />\n"
 
-           "         <Option compiler=\"" << compiler << "\" />\n"
 
-           "         <Compiler>\n";
 
-     // the compilerdefines for this target
 
-     const char* cdefs = target->GetMakefile()->GetProperty(
 
-                                                         "COMPILE_DEFINITIONS");
 
-     if(cdefs)
 
-       {
 
-       // Expand the list.
 
-       std::vector<std::string> defs;
 
-       cmSystemTools::ExpandListArgument(cdefs, defs);
 
-       for(std::vector<std::string>::const_iterator di = defs.begin();
 
-           di != defs.end(); ++di)
 
-         {
 
-         cmXMLSafe safedef(di->c_str());
 
-         fout <<"            <Add option=\"-D" << safedef.str() << "\" />\n";
 
-         }
 
-       }
 
-       // the include directories for this target
 
-       std::set<std::string> uniqIncludeDirs;
 
-       const std::vector<std::string>& incDirs =
 
-           target->GetMakefile()->GetIncludeDirectories();
 
-       for(std::vector<std::string>::const_iterator dirIt=incDirs.begin();
 
-           dirIt != incDirs.end();
 
-           ++dirIt)
 
-         {
 
-         uniqIncludeDirs.insert(*dirIt);
 
-         }
 
-       std::string systemIncludeDirs = makefile->GetSafeDefinition(
 
-                                 "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
 
-       if (!systemIncludeDirs.empty())
 
-         {
 
-         std::vector<std::string> dirs;
 
-         cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
 
-         for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
 
-             dirIt != dirs.end();
 
-             ++dirIt)
 
-           {
 
-           uniqIncludeDirs.insert(*dirIt);
 
-           }
 
-         }
 
-       systemIncludeDirs = makefile->GetSafeDefinition(
 
-                               "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
 
-       if (!systemIncludeDirs.empty())
 
-         {
 
-         std::vector<std::string> dirs;
 
-         cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
 
-         for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
 
-             dirIt != dirs.end();
 
-             ++dirIt)
 
-           {
 
-           uniqIncludeDirs.insert(*dirIt);
 
-           }
 
-         }
 
-       for(std::set<std::string>::const_iterator dirIt=uniqIncludeDirs.begin();
 
-           dirIt != uniqIncludeDirs.end();
 
-           ++dirIt)
 
-         {
 
-         fout <<"            <Add directory=\"" << dirIt->c_str() << "\" />\n";
 
-         }
 
-       fout<<"         </Compiler>\n";
 
-       }
 
-     else // e.g. all and the GLOBAL and UTILITY targets
 
-     {
 
-     fout<<"         <Option working_dir=\""
 
-                             << makefile->GetStartOutputDirectory() << "\" />\n"
 
-         <<"         <Option type=\"" << 4 << "\" />\n";
 
-     }
 
-   fout<<"         <MakeCommands>\n"
 
-         "            <Build command=\""
 
-       << this->BuildMakeCommand(make, makefileName.c_str(), targetName)
 
-       << "\" />\n"
 
-         "            <CompileFile command=\""
 
-       << this->BuildMakeCommand(make, makefileName.c_str(),""$file"")
 
-       << "\" />\n"
 
-         "            <Clean command=\""
 
-       << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
 
-       << "\" />\n"
 
-         "            <DistClean command=\""
 
-       << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
 
-       << "\" />\n"
 
-         "         </MakeCommands>\n"
 
-         "      </Target>\n";
 
- }
 
- // Translate the cmake compiler id into the CodeBlocks compiler id
 
- std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
 
- {
 
-   // figure out which language to use
 
-   // for now care only for C and C++
 
-   std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
 
-   if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false)
 
-     {
 
-     compilerIdVar = "CMAKE_C_COMPILER_ID";
 
-     }
 
-   std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
 
-   std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
 
-   std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str());
 
-   std::string compiler = "gcc";  // default to gcc
 
-   if (compilerId == "MSVC")
 
-     {
 
-     compiler = "msvc8";
 
-     }
 
-   else if (compilerId == "Borland")
 
-     {
 
-     compiler = "bcc";
 
-     }
 
-   else if (compilerId == "SDCC")
 
-     {
 
-     compiler = "sdcc";
 
-     }
 
-   else if (compilerId == "Intel")
 
-     {
 
-     compiler = "icc";
 
-     }
 
-   else if (compilerId == "Watcom")
 
-     {
 
-     compiler = "ow";
 
-     }
 
-   else if (compilerId == "GNU")
 
-     {
 
-     compiler = "gcc";
 
-     }
 
-   return compiler;
 
- }
 
- // Translate the cmake target type into the CodeBlocks target type id
 
- int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target)
 
- {
 
-   if ( target->GetType()==cmTarget::EXECUTABLE)
 
-     {
 
-     if ((target->GetPropertyAsBool("WIN32_EXECUTABLE"))
 
-         || (target->GetPropertyAsBool("MACOSX_BUNDLE")))
 
-       {
 
-       return 0;
 
-       }
 
-     else
 
-       {
 
-       return 1;
 
-       }
 
-     }
 
-   else if ( target->GetType()==cmTarget::STATIC_LIBRARY)
 
-     {
 
-     return 2;
 
-     }
 
-   else if ((target->GetType()==cmTarget::SHARED_LIBRARY)
 
-            || (target->GetType()==cmTarget::MODULE_LIBRARY))
 
-     {
 
-     return 3;
 
-     }
 
-   return 4;
 
- }
 
- // Create the command line for building the given target using the selected
 
- // make
 
- std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
 
-              const std::string& make, const char* makefile, const char* target)
 
- {
 
-   std::string command = make;
 
-   if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
 
-     {
 
-     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
 
-     command += " /NOLOGO /f "";
 
-     command += makefileName;
 
-     command += "" ";
 
-     command += " VERBOSE=1 ";
 
-     command += target;
 
-     }
 
-   else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
 
-     {
 
-     // no escaping of spaces in this case, see
 
-     // http://public.kitware.com/Bug/view.php?id=10014
 
-     std::string makefileName = makefile;
 
-     command += " -f "";
 
-     command += makefileName;
 
-     command += "" ";
 
-     command += " VERBOSE=1 ";
 
-     command += target;
 
-     }
 
-   else
 
-     {
 
-     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
 
-     command += " -f "";
 
-     command += makefileName;
 
-     command += "" ";
 
-     command += " VERBOSE=1 ";
 
-     command += target;
 
-     }
 
-   return command;
 
- }
 
 
  |