cmGlobalKdevelopGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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::Generate()
  47. {
  48. // for each sub project in the project create
  49. // a kdevelop project
  50. for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
  51. it = this->GlobalGenerator->GetProjectMap().begin();
  52. it!= this->GlobalGenerator->GetProjectMap().end();
  53. ++it)
  54. {
  55. cmMakefile* mf = it->second[0]->GetMakefile();
  56. std::string outputDir=mf->GetStartOutputDirectory();
  57. std::string projectDir=mf->GetHomeDirectory();
  58. std::string projectName=mf->GetProjectName();
  59. std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
  60. std::string fileToOpen;
  61. const std::vector<cmLocalGenerator*>& lgs= it->second;
  62. // create the project.kdevelop.filelist file
  63. if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
  64. projectName, cmakeFilePattern, fileToOpen))
  65. {
  66. cmSystemTools::Error("Can not create filelist file");
  67. return;
  68. }
  69. //try to find the name of an executable so we have something to
  70. //run from kdevelop for now just pick the first executable found
  71. std::string executable;
  72. for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
  73. lg!=lgs.end(); lg++)
  74. {
  75. cmMakefile* makefile=(*lg)->GetMakefile();
  76. cmTargets& targets=makefile->GetTargets();
  77. for (cmTargets::iterator ti = targets.begin();
  78. ti != targets.end(); ti++)
  79. {
  80. if (ti->second.GetType()==cmTarget::EXECUTABLE)
  81. {
  82. executable = ti->second.GetProperty("LOCATION");
  83. break;
  84. }
  85. }
  86. if (!executable.empty())
  87. {
  88. break;
  89. }
  90. }
  91. // now create a project file
  92. this->CreateProjectFile(outputDir, projectDir, projectName,
  93. executable, cmakeFilePattern, fileToOpen);
  94. }
  95. }
  96. bool cmGlobalKdevelopGenerator
  97. ::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
  98. const std::string& outputDir,
  99. const std::string& projectDirIn,
  100. const std::string& projectname,
  101. std::string& cmakeFilePattern,
  102. std::string& fileToOpen)
  103. {
  104. std::string projectDir = projectDirIn + "/";
  105. std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
  106. std::set<cmStdString> files;
  107. std::string tmp;
  108. for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
  109. it!=lgs.end(); it++)
  110. {
  111. cmMakefile* makefile=(*it)->GetMakefile();
  112. const std::vector<std::string>& listFiles=makefile->GetListFiles();
  113. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  114. lt!=listFiles.end(); lt++)
  115. {
  116. tmp=*lt;
  117. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  118. // make sure the file is part of this source tree
  119. if ((tmp[0]!='/') &&
  120. (strstr(tmp.c_str(),
  121. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  122. {
  123. files.insert(tmp);
  124. tmp=cmSystemTools::GetFilenameName(tmp);
  125. //add all files which dont match the default
  126. // */CMakeLists.txt;*cmake; to the file pattern
  127. if ((tmp!="CMakeLists.txt")
  128. && (strstr(tmp.c_str(), ".cmake")==0))
  129. {
  130. cmakeFilePattern+=tmp+";";
  131. }
  132. }
  133. }
  134. //get all sources
  135. cmTargets& targets=makefile->GetTargets();
  136. for (cmTargets::iterator ti = targets.begin();
  137. ti != targets.end(); ti++)
  138. {
  139. const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles();
  140. for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
  141. si!=sources.end(); si++)
  142. {
  143. tmp=(*si)->GetFullPath();
  144. std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
  145. headerBasename+="/";
  146. headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
  147. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  148. if ((tmp[0]!='/') &&
  149. (strstr(tmp.c_str(),
  150. cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
  151. (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
  152. {
  153. files.insert(tmp);
  154. // check if there's a matching header around
  155. for(std::vector<std::string>::const_iterator
  156. ext = makefile->GetHeaderExtensions().begin();
  157. ext != makefile->GetHeaderExtensions().end(); ++ext)
  158. {
  159. std::string hname=headerBasename;
  160. hname += ".";
  161. hname += *ext;
  162. if(cmSystemTools::FileExists(hname.c_str()))
  163. {
  164. cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
  165. files.insert(hname);
  166. break;
  167. }
  168. }
  169. }
  170. }
  171. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  172. lt!=listFiles.end(); lt++)
  173. {
  174. tmp=*lt;
  175. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  176. if ((tmp[0]!='/') &&
  177. (strstr(tmp.c_str(),
  178. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  179. {
  180. files.insert(tmp.c_str());
  181. }
  182. }
  183. }
  184. }
  185. //check if the output file already exists and read it
  186. //insert all files which exist into the set of files
  187. std::ifstream oldFilelist(filename.c_str());
  188. if (oldFilelist)
  189. {
  190. while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
  191. {
  192. if (tmp[0]=='/')
  193. {
  194. continue;
  195. }
  196. std::string completePath=projectDir+tmp;
  197. if (cmSystemTools::FileExists(completePath.c_str()))
  198. {
  199. files.insert(tmp);
  200. }
  201. }
  202. oldFilelist.close();
  203. }
  204. //now write the new filename
  205. cmGeneratedFileStream fout(filename.c_str());
  206. if(!fout)
  207. {
  208. return false;
  209. }
  210. fileToOpen="";
  211. for (std::set<cmStdString>::const_iterator it=files.begin();
  212. it!=files.end(); it++)
  213. {
  214. // get the full path to the file
  215. tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str());
  216. // just select the first source file
  217. if (fileToOpen.empty())
  218. {
  219. std::string ext = cmSystemTools::GetFilenameExtension(tmp);
  220. if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".cxx")
  221. || (ext==".C") || (ext==".h") || (ext==".hpp"))
  222. {
  223. fileToOpen=tmp;
  224. }
  225. }
  226. // make it relative to the project dir
  227. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  228. // only put relative paths
  229. if (tmp.size() && tmp[0] != '/')
  230. {
  231. fout << tmp.c_str() <<"\n";
  232. }
  233. }
  234. return true;
  235. }
  236. /* create the project file, if it already exists, merge it with the
  237. existing one, otherwise create a new one */
  238. void cmGlobalKdevelopGenerator
  239. ::CreateProjectFile(const std::string& outputDir,
  240. const std::string& projectDir,
  241. const std::string& projectname,
  242. const std::string& executable,
  243. const std::string& cmakeFilePattern,
  244. const std::string& fileToOpen)
  245. {
  246. this->Blacklist.clear();
  247. std::string filename=outputDir+"/";
  248. filename+=projectname+".kdevelop";
  249. std::string sessionFilename=outputDir+"/";
  250. sessionFilename+=projectname+".kdevses";
  251. if (cmSystemTools::FileExists(filename.c_str()))
  252. {
  253. this->MergeProjectFiles(outputDir, projectDir, filename,
  254. executable, cmakeFilePattern,
  255. fileToOpen, sessionFilename);
  256. }
  257. else
  258. {
  259. // add all subdirectories which are cmake build directories to the
  260. // kdevelop blacklist so they are not monitored for added or removed files
  261. // since this is handled by adding files to the cmake files
  262. cmsys::Directory d;
  263. if (d.Load(projectDir.c_str()))
  264. {
  265. size_t numf = d.GetNumberOfFiles();
  266. for (unsigned int i = 0; i < numf; i++)
  267. {
  268. std::string nextFile = d.GetFile(i);
  269. if ((nextFile!=".") && (nextFile!=".."))
  270. {
  271. std::string tmp = projectDir;
  272. tmp += "/";
  273. tmp += nextFile;
  274. if (cmSystemTools::FileIsDirectory(tmp.c_str()))
  275. {
  276. tmp += "/CMakeCache.txt";
  277. if ((nextFile == "CMakeFiles")
  278. || (cmSystemTools::FileExists(tmp.c_str())))
  279. {
  280. this->Blacklist.push_back(nextFile);
  281. }
  282. }
  283. }
  284. }
  285. }
  286. this->CreateNewProjectFile(outputDir, projectDir, filename,
  287. executable, cmakeFilePattern,
  288. fileToOpen, sessionFilename);
  289. }
  290. }
  291. void cmGlobalKdevelopGenerator
  292. ::MergeProjectFiles(const std::string& outputDir,
  293. const std::string& projectDir,
  294. const std::string& filename,
  295. const std::string& executable,
  296. const std::string& cmakeFilePattern,
  297. const std::string& fileToOpen,
  298. const std::string& sessionFilename)
  299. {
  300. std::ifstream oldProjectFile(filename.c_str());
  301. if (!oldProjectFile)
  302. {
  303. this->CreateNewProjectFile(outputDir, projectDir, filename,
  304. executable, cmakeFilePattern,
  305. fileToOpen, sessionFilename);
  306. return;
  307. }
  308. /* Read the existing project file (line by line), copy all lines
  309. into the new project file, except the ones which can be reliably
  310. set from contents of the CMakeLists.txt */
  311. std::string tmp;
  312. std::vector<std::string> lines;
  313. while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
  314. {
  315. lines.push_back(tmp);
  316. }
  317. oldProjectFile.close();
  318. cmGeneratedFileStream fout(filename.c_str());
  319. if(!fout)
  320. {
  321. return;
  322. }
  323. for (std::vector<std::string>::const_iterator it=lines.begin();
  324. it!=lines.end(); it++)
  325. {
  326. const char* line=(*it).c_str();
  327. // skip these tags as they are always replaced
  328. if ((strstr(line, "<projectdirectory>")!=0)
  329. || (strstr(line, "<projectmanagement>")!=0)
  330. || (strstr(line, "<absoluteprojectpath>")!=0)
  331. || (strstr(line, "<filelistdirectory>")!=0)
  332. || (strstr(line, "<buildtool>")!=0)
  333. || (strstr(line, "<builddir>")!=0))
  334. {
  335. continue;
  336. }
  337. // output the line from the file if it is not one of the above tags
  338. fout<<*it<<"\n";
  339. // if this is the <general> tag output the stuff that goes in the
  340. // general tag
  341. if (strstr(line, "<general>"))
  342. {
  343. fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
  344. fout<< " <projectdirectory>" <<projectDir.c_str()
  345. << "</projectdirectory>\n"; //this one is important
  346. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
  347. //and this one
  348. }
  349. // inside kdevcustomproject the <filelistdirectory> must be put
  350. if (strstr(line, "<kdevcustomproject>"))
  351. {
  352. fout<<" <filelistdirectory>"<<outputDir.c_str()
  353. <<"</filelistdirectory>\n";
  354. }
  355. // buildtool and builddir go inside <build>
  356. if (strstr(line, "<build>"))
  357. {
  358. fout<<" <buildtool>make</buildtool>\n";
  359. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n";
  360. }
  361. }
  362. }
  363. void cmGlobalKdevelopGenerator
  364. ::CreateNewProjectFile(const std::string& outputDir,
  365. const std::string& projectDir,
  366. const std::string& filename,
  367. const std::string& executable,
  368. const std::string& cmakeFilePattern,
  369. const std::string& fileToOpen,
  370. const std::string& sessionFilename)
  371. {
  372. cmGeneratedFileStream fout(filename.c_str());
  373. if(!fout)
  374. {
  375. return;
  376. }
  377. // check for a version control system
  378. bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
  379. bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
  380. bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
  381. || this->GlobalGenerator->GetLanguageEnabled("CXX"));
  382. bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
  383. std::string primaryLanguage = "C++";
  384. if (enableFortran && !enableCxx)
  385. {
  386. primaryLanguage="Fortran77";
  387. }
  388. fout<<"<?xml version = '1.0'?>\n"
  389. "<kdevelop>\n"
  390. " <general>\n"
  391. " <author></author>\n"
  392. " <email></email>\n"
  393. " <version>$VERSION$</version>\n"
  394. " <projectmanagement>KDevCustomProject</projectmanagement>\n"
  395. " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
  396. " <ignoreparts/>\n"
  397. " <projectdirectory>" << projectDir.c_str() <<
  398. "</projectdirectory>\n"; //this one is important
  399. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
  400. // setup additional languages
  401. fout<<" <secondaryLanguages>\n";
  402. if (enableFortran && enableCxx)
  403. {
  404. fout<<" <language>Fortran</language>\n";
  405. }
  406. if (enableCxx)
  407. {
  408. fout<<" <language>C</language>\n";
  409. }
  410. fout<<" </secondaryLanguages>\n";
  411. if (hasSvn)
  412. {
  413. fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
  414. }
  415. else if (hasCvs)
  416. {
  417. fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
  418. }
  419. fout<<" </general>\n"
  420. " <kdevcustomproject>\n"
  421. " <filelistdirectory>" << outputDir.c_str() <<
  422. "</filelistdirectory>\n"
  423. " <run>\n"
  424. " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
  425. " <directoryradio>custom</directoryradio>\n"
  426. " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
  427. " <programargs></programargs>\n"
  428. " <terminal>false</terminal>\n"
  429. " <autocompile>true</autocompile>\n"
  430. " <envvars/>\n"
  431. " </run>\n"
  432. " <build>\n"
  433. " <buildtool>make</buildtool>\n"; //this one is important
  434. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
  435. fout<<" </build>\n"
  436. " <make>\n"
  437. " <abortonerror>false</abortonerror>\n"
  438. " <numberofjobs>1</numberofjobs>\n"
  439. " <dontact>false</dontact>\n"
  440. " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
  441. GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL")
  442. << " </makebin>\n"
  443. " <selectedenvironment>default</selectedenvironment>\n"
  444. " <environments>\n"
  445. " <default>\n"
  446. " <envvar value=\"1\" name=\"VERBOSE\" />\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. }