cmGlobalKdevelopGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. Copyright (c) 2004 Alexander Neundorf [email protected], All rights reserved.
  9. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  10. This software is distributed WITHOUT ANY WARRANTY; without even
  11. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE. See the above copyright notices for more information.
  13. =========================================================================*/
  14. #include "cmGlobalKdevelopGenerator.h"
  15. #include "cmGlobalUnixMakefileGenerator3.h"
  16. #include "cmLocalUnixMakefileGenerator3.h"
  17. #include "cmMakefile.h"
  18. #include "cmake.h"
  19. #include "cmSourceFile.h"
  20. #include "cmGeneratedFileStream.h"
  21. #include "cmSystemTools.h"
  22. #include <cmsys/SystemTools.hxx>
  23. #include <cmsys/Directory.hxx>
  24. //----------------------------------------------------------------------------
  25. void cmGlobalKdevelopGenerator
  26. ::GetDocumentation(cmDocumentationEntry& entry, const char*) const
  27. {
  28. entry.name = this->GetName();
  29. entry.brief = "Generates KDevelop 3 project files.";
  30. entry.full =
  31. "Project files for KDevelop 3 will be created in the top directory "
  32. "and in every subdirectory which features a CMakeLists.txt file "
  33. "containing a PROJECT() call. "
  34. "If you change the settings using KDevelop cmake will try its best "
  35. "to keep your changes when regenerating the project files. "
  36. "Additionally a hierarchy of UNIX makefiles is generated into the "
  37. "build tree. Any "
  38. "standard UNIX-style make program can build the project through the "
  39. "default make target. A \"make install\" target is also provided.";
  40. }
  41. cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
  42. :cmExternalMakefileProjectGenerator()
  43. {
  44. this->SupportedGlobalGenerators.push_back("Unix Makefiles");
  45. }
  46. void cmGlobalKdevelopGenerator::SetGlobalGenerator(
  47. cmGlobalGenerator* generator)
  48. {
  49. cmExternalMakefileProjectGenerator::SetGlobalGenerator(generator);
  50. cmGlobalUnixMakefileGenerator3* mf = (cmGlobalUnixMakefileGenerator3*)
  51. generator;
  52. mf->SetToolSupportsColor(false);
  53. mf->SetForceVerboseMakefiles(true);
  54. }
  55. void cmGlobalKdevelopGenerator::Generate()
  56. {
  57. // for each sub project in the project create
  58. // a kdevelop project
  59. for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
  60. it = this->GlobalGenerator->GetProjectMap().begin();
  61. it!= this->GlobalGenerator->GetProjectMap().end();
  62. ++it)
  63. {
  64. cmMakefile* mf = it->second[0]->GetMakefile();
  65. std::string outputDir=mf->GetStartOutputDirectory();
  66. std::string projectDir=mf->GetHomeDirectory();
  67. std::string projectName=mf->GetProjectName();
  68. std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
  69. std::string fileToOpen;
  70. const std::vector<cmLocalGenerator*>& lgs= it->second;
  71. // create the project.kdevelop.filelist file
  72. if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
  73. projectName, cmakeFilePattern, fileToOpen))
  74. {
  75. cmSystemTools::Error("Can not create filelist file");
  76. return;
  77. }
  78. //try to find the name of an executable so we have something to
  79. //run from kdevelop for now just pick the first executable found
  80. std::string executable;
  81. for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
  82. lg!=lgs.end(); lg++)
  83. {
  84. cmMakefile* makefile=(*lg)->GetMakefile();
  85. cmTargets& targets=makefile->GetTargets();
  86. for (cmTargets::iterator ti = targets.begin();
  87. ti != targets.end(); ti++)
  88. {
  89. if (ti->second.GetType()==cmTarget::EXECUTABLE)
  90. {
  91. executable = ti->second.GetProperty("LOCATION");
  92. break;
  93. }
  94. }
  95. if (!executable.empty())
  96. {
  97. break;
  98. }
  99. }
  100. // now create a project file
  101. this->CreateProjectFile(outputDir, projectDir, projectName,
  102. executable, cmakeFilePattern, fileToOpen);
  103. }
  104. }
  105. bool cmGlobalKdevelopGenerator
  106. ::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
  107. const std::string& outputDir,
  108. const std::string& projectDirIn,
  109. const std::string& projectname,
  110. std::string& cmakeFilePattern,
  111. std::string& fileToOpen)
  112. {
  113. std::string projectDir = projectDirIn + "/";
  114. std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
  115. std::set<cmStdString> files;
  116. std::string tmp;
  117. for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
  118. it!=lgs.end(); it++)
  119. {
  120. cmMakefile* makefile=(*it)->GetMakefile();
  121. const std::vector<std::string>& listFiles=makefile->GetListFiles();
  122. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  123. lt!=listFiles.end(); lt++)
  124. {
  125. tmp=*lt;
  126. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  127. // make sure the file is part of this source tree
  128. if ((tmp[0]!='/') &&
  129. (strstr(tmp.c_str(),
  130. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  131. {
  132. files.insert(tmp);
  133. tmp=cmSystemTools::GetFilenameName(tmp);
  134. //add all files which dont match the default
  135. // */CMakeLists.txt;*cmake; to the file pattern
  136. if ((tmp!="CMakeLists.txt")
  137. && (strstr(tmp.c_str(), ".cmake")==0))
  138. {
  139. cmakeFilePattern+=tmp+";";
  140. }
  141. }
  142. }
  143. //get all sources
  144. cmTargets& targets=makefile->GetTargets();
  145. for (cmTargets::iterator ti = targets.begin();
  146. ti != targets.end(); ti++)
  147. {
  148. const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles();
  149. for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
  150. si!=sources.end(); si++)
  151. {
  152. tmp=(*si)->GetFullPath();
  153. std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
  154. headerBasename+="/";
  155. headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
  156. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  157. if ((tmp[0]!='/') &&
  158. (strstr(tmp.c_str(),
  159. cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
  160. (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
  161. {
  162. files.insert(tmp);
  163. // check if there's a matching header around
  164. for(std::vector<std::string>::const_iterator
  165. ext = makefile->GetHeaderExtensions().begin();
  166. ext != makefile->GetHeaderExtensions().end(); ++ext)
  167. {
  168. std::string hname=headerBasename;
  169. hname += ".";
  170. hname += *ext;
  171. if(cmSystemTools::FileExists(hname.c_str()))
  172. {
  173. cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
  174. files.insert(hname);
  175. break;
  176. }
  177. }
  178. }
  179. }
  180. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  181. lt!=listFiles.end(); lt++)
  182. {
  183. tmp=*lt;
  184. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  185. if ((tmp[0]!='/') &&
  186. (strstr(tmp.c_str(),
  187. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  188. {
  189. files.insert(tmp.c_str());
  190. }
  191. }
  192. }
  193. }
  194. //check if the output file already exists and read it
  195. //insert all files which exist into the set of files
  196. std::ifstream oldFilelist(filename.c_str());
  197. if (oldFilelist)
  198. {
  199. while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
  200. {
  201. if (tmp[0]=='/')
  202. {
  203. continue;
  204. }
  205. std::string completePath=projectDir+tmp;
  206. if (cmSystemTools::FileExists(completePath.c_str()))
  207. {
  208. files.insert(tmp);
  209. }
  210. }
  211. oldFilelist.close();
  212. }
  213. //now write the new filename
  214. cmGeneratedFileStream fout(filename.c_str());
  215. if(!fout)
  216. {
  217. return false;
  218. }
  219. fileToOpen="";
  220. for (std::set<cmStdString>::const_iterator it=files.begin();
  221. it!=files.end(); it++)
  222. {
  223. // get the full path to the file
  224. tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str());
  225. // just select the first source file
  226. if (fileToOpen.empty())
  227. {
  228. std::string ext = cmSystemTools::GetFilenameExtension(tmp);
  229. if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".cxx")
  230. || (ext==".C") || (ext==".h") || (ext==".hpp"))
  231. {
  232. fileToOpen=tmp;
  233. }
  234. }
  235. // make it relative to the project dir
  236. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  237. // only put relative paths
  238. if (tmp.size() && tmp[0] != '/')
  239. {
  240. fout << tmp.c_str() <<"\n";
  241. }
  242. }
  243. return true;
  244. }
  245. /* create the project file, if it already exists, merge it with the
  246. existing one, otherwise create a new one */
  247. void cmGlobalKdevelopGenerator
  248. ::CreateProjectFile(const std::string& outputDir,
  249. const std::string& projectDir,
  250. const std::string& projectname,
  251. const std::string& executable,
  252. const std::string& cmakeFilePattern,
  253. const std::string& fileToOpen)
  254. {
  255. this->Blacklist.clear();
  256. std::string filename=outputDir+"/";
  257. filename+=projectname+".kdevelop";
  258. std::string sessionFilename=outputDir+"/";
  259. sessionFilename+=projectname+".kdevses";
  260. if (cmSystemTools::FileExists(filename.c_str()))
  261. {
  262. this->MergeProjectFiles(outputDir, projectDir, filename,
  263. executable, cmakeFilePattern,
  264. fileToOpen, sessionFilename);
  265. }
  266. else
  267. {
  268. // add all subdirectories to the kdevelop blacklist
  269. // so they are not monitored for added or removed files
  270. // since this is basically handled by adding files to the cmake files
  271. cmsys::Directory d;
  272. if (d.Load(projectDir.c_str()))
  273. {
  274. size_t numf = d.GetNumberOfFiles();
  275. for (unsigned int i = 0; i < numf; i++)
  276. {
  277. std::string nextFile = d.GetFile(i);
  278. if ((nextFile!=".") && (nextFile!=".."))
  279. {
  280. std::string tmp = projectDir;
  281. tmp += "/";
  282. tmp += nextFile;
  283. if (cmSystemTools::FileIsDirectory(tmp.c_str()))
  284. {
  285. this->Blacklist.push_back(nextFile);
  286. }
  287. }
  288. }
  289. }
  290. this->CreateNewProjectFile(outputDir, projectDir, filename,
  291. executable, cmakeFilePattern,
  292. fileToOpen, sessionFilename);
  293. }
  294. }
  295. void cmGlobalKdevelopGenerator
  296. ::MergeProjectFiles(const std::string& outputDir,
  297. const std::string& projectDir,
  298. const std::string& filename,
  299. const std::string& executable,
  300. const std::string& cmakeFilePattern,
  301. const std::string& fileToOpen,
  302. const std::string& sessionFilename)
  303. {
  304. std::ifstream oldProjectFile(filename.c_str());
  305. if (!oldProjectFile)
  306. {
  307. this->CreateNewProjectFile(outputDir, projectDir, filename,
  308. executable, cmakeFilePattern,
  309. fileToOpen, sessionFilename);
  310. return;
  311. }
  312. /* Read the existing project file (line by line), copy all lines
  313. into the new project file, except the ones which can be reliably
  314. set from contents of the CMakeLists.txt */
  315. std::string tmp;
  316. std::vector<std::string> lines;
  317. while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
  318. {
  319. lines.push_back(tmp);
  320. }
  321. oldProjectFile.close();
  322. cmGeneratedFileStream fout(filename.c_str());
  323. if(!fout)
  324. {
  325. return;
  326. }
  327. for (std::vector<std::string>::const_iterator it=lines.begin();
  328. it!=lines.end(); it++)
  329. {
  330. const char* line=(*it).c_str();
  331. // skip these tags as they are always replaced
  332. if ((strstr(line, "<projectdirectory>")!=0)
  333. || (strstr(line, "<projectmanagement>")!=0)
  334. || (strstr(line, "<absoluteprojectpath>")!=0)
  335. || (strstr(line, "<filelistdirectory>")!=0)
  336. || (strstr(line, "<buildtool>")!=0)
  337. || (strstr(line, "<builddir>")!=0))
  338. {
  339. continue;
  340. }
  341. // output the line from the file if it is not one of the above tags
  342. fout<<*it<<"\n";
  343. // if this is the <general> tag output the stuff that goes in the
  344. // general tag
  345. if (strstr(line, "<general>"))
  346. {
  347. fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
  348. fout<< " <projectdirectory>" <<projectDir.c_str()
  349. << "</projectdirectory>\n"; //this one is important
  350. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
  351. //and this one
  352. }
  353. // inside kdevcustomproject the <filelistdirectory> must be put
  354. if (strstr(line, "<kdevcustomproject>"))
  355. {
  356. fout<<" <filelistdirectory>"<<outputDir.c_str()
  357. <<"</filelistdirectory>\n";
  358. }
  359. // buildtool and builddir go inside <build>
  360. if (strstr(line, "<build>"))
  361. {
  362. fout<<" <buildtool>make</buildtool>\n";
  363. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n";
  364. }
  365. }
  366. }
  367. void cmGlobalKdevelopGenerator
  368. ::CreateNewProjectFile(const std::string& outputDir,
  369. const std::string& projectDir,
  370. const std::string& filename,
  371. const std::string& executable,
  372. const std::string& cmakeFilePattern,
  373. const std::string& fileToOpen,
  374. const std::string& sessionFilename)
  375. {
  376. cmGeneratedFileStream fout(filename.c_str());
  377. if(!fout)
  378. {
  379. return;
  380. }
  381. // check for a version control system
  382. bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
  383. bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
  384. bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
  385. || this->GlobalGenerator->GetLanguageEnabled("CXX"));
  386. bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
  387. std::string primaryLanguage = "C++";
  388. if (enableFortran && !enableCxx)
  389. {
  390. primaryLanguage="Fortran77";
  391. }
  392. fout<<"<?xml version = '1.0'?>\n"
  393. "<kdevelop>\n"
  394. " <general>\n"
  395. " <author></author>\n"
  396. " <email></email>\n"
  397. " <version>$VERSION$</version>\n"
  398. " <projectmanagement>KDevCustomProject</projectmanagement>\n"
  399. " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
  400. " <ignoreparts/>\n"
  401. " <projectdirectory>" << projectDir.c_str() <<
  402. "</projectdirectory>\n"; //this one is important
  403. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
  404. // setup additional languages
  405. fout<<" <secondaryLanguages>\n";
  406. if (enableFortran && enableCxx)
  407. {
  408. fout<<" <language>Fortran</language>\n";
  409. }
  410. if (enableCxx)
  411. {
  412. fout<<" <language>C</language>\n";
  413. }
  414. fout<<" </secondaryLanguages>\n";
  415. if (hasSvn)
  416. {
  417. fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
  418. }
  419. else if (hasCvs)
  420. {
  421. fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
  422. }
  423. fout<<" </general>\n"
  424. " <kdevcustomproject>\n"
  425. " <filelistdirectory>" << outputDir.c_str() <<
  426. "</filelistdirectory>\n"
  427. " <run>\n"
  428. " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
  429. " <directoryradio>custom</directoryradio>\n"
  430. " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
  431. " <programargs></programargs>\n"
  432. " <terminal>false</terminal>\n"
  433. " <autocompile>true</autocompile>\n"
  434. " <envvars/>\n"
  435. " </run>\n"
  436. " <build>\n"
  437. " <buildtool>make</buildtool>\n"; //this one is important
  438. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
  439. fout<<" </build>\n"
  440. " <make>\n"
  441. " <abortonerror>false</abortonerror>\n"
  442. " <numberofjobs>1</numberofjobs>\n"
  443. " <dontact>false</dontact>\n"
  444. " <makebin></makebin>\n"
  445. " <selectedenvironment>default</selectedenvironment>\n"
  446. " <environments>\n"
  447. " <default/>\n"
  448. " </environments>\n"
  449. " </make>\n";
  450. fout<<" <blacklist>\n";
  451. for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
  452. dirIt != this->Blacklist.end();
  453. ++dirIt)
  454. {
  455. fout<<" <path>" << dirIt->c_str() << "</path>\n";
  456. }
  457. fout<<" </blacklist>\n";
  458. fout<<" </kdevcustomproject>\n"
  459. " <kdevfilecreate>\n"
  460. " <filetypes/>\n"
  461. " <useglobaltypes>\n"
  462. " <type ext=\"ui\" />\n"
  463. " <type ext=\"cpp\" />\n"
  464. " <type ext=\"h\" />\n"
  465. " </useglobaltypes>\n"
  466. " </kdevfilecreate>\n"
  467. " <kdevdoctreeview>\n"
  468. " <projectdoc>\n"
  469. " <userdocDir>html/</userdocDir>\n"
  470. " <apidocDir>html/</apidocDir>\n"
  471. " </projectdoc>\n"
  472. " <ignoreqt_xml/>\n"
  473. " <ignoredoxygen/>\n"
  474. " <ignorekdocs/>\n"
  475. " <ignoretocs/>\n"
  476. " <ignoredevhelp/>\n"
  477. " </kdevdoctreeview>\n";
  478. if (enableCxx)
  479. {
  480. fout<<" <cppsupportpart>\n"
  481. " <filetemplates>\n"
  482. " <interfacesuffix>.h</interfacesuffix>\n"
  483. " <implementationsuffix>.cpp</implementationsuffix>\n"
  484. " </filetemplates>\n"
  485. " </cppsupportpart>\n"
  486. " <kdevcppsupport>\n"
  487. " <codecompletion>\n"
  488. " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
  489. " <includeTypes>true</includeTypes>\n"
  490. " <includeEnums>true</includeEnums>\n"
  491. " <includeTypedefs>false</includeTypedefs>\n"
  492. " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
  493. " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
  494. " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
  495. " <codeCompletionDelay>250</codeCompletionDelay>\n"
  496. " <argumentsHintDelay>400</argumentsHintDelay>\n"
  497. " <headerCompletionDelay>250</headerCompletionDelay>\n"
  498. " </codecompletion>\n"
  499. " <references/>\n"
  500. " </kdevcppsupport>\n";
  501. }
  502. if (enableFortran)
  503. {
  504. fout<<" <kdevfortransupport>\n"
  505. " <ftnchek>\n"
  506. " <division>false</division>\n"
  507. " <extern>false</extern>\n"
  508. " <declare>false</declare>\n"
  509. " <pure>false</pure>\n"
  510. " <argumentsall>false</argumentsall>\n"
  511. " <commonall>false</commonall>\n"
  512. " <truncationall>false</truncationall>\n"
  513. " <usageall>false</usageall>\n"
  514. " <f77all>false</f77all>\n"
  515. " <portabilityall>false</portabilityall>\n"
  516. " <argumentsonly/>\n"
  517. " <commononly/>\n"
  518. " <truncationonly/>\n"
  519. " <usageonly/>\n"
  520. " <f77only/>\n"
  521. " <portabilityonly/>\n"
  522. " </ftnchek>\n"
  523. " </kdevfortransupport>\n";
  524. }
  525. // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
  526. // command
  527. fout<<" <kdevfileview>\n"
  528. " <groups>\n"
  529. " <group pattern=\"" << cmakeFilePattern.c_str() <<
  530. "\" name=\"CMake\" />\n";
  531. if (enableCxx)
  532. {
  533. fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
  534. " <group pattern=\"*.c\" name=\"C Sources\" />\n"
  535. " <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
  536. "/>\n";
  537. }
  538. if (enableFortran)
  539. {
  540. fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
  541. "*.F95\" name=\"Fortran Sources\" />\n";
  542. }
  543. fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
  544. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  545. " </groups>\n"
  546. " <tree>\n"
  547. " <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
  548. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  549. " </tree>\n"
  550. " </kdevfileview>\n"
  551. "</kdevelop>\n";
  552. if (sessionFilename.empty())
  553. {
  554. return;
  555. }
  556. // and a session file, so that kdevelop opens a file if it opens the
  557. // project the first time
  558. cmGeneratedFileStream devses(sessionFilename.c_str());
  559. if(!devses)
  560. {
  561. return;
  562. }
  563. devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
  564. "<!DOCTYPE KDevPrjSession>\n"
  565. "<KDevPrjSession>\n"
  566. " <DocsAndViews NumberOfDocuments=\"1\" >\n"
  567. " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
  568. "\" >\n"
  569. " <View0 line=\"0\" Type=\"Source\" />\n"
  570. " </Doc0>\n"
  571. " </DocsAndViews>\n"
  572. "</KDevPrjSession>\n";
  573. }