cmGlobalKdevelopGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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 to the kdevelop blacklist
  260. // so they are not monitored for added or removed files
  261. // since this is basically 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. this->Blacklist.push_back(nextFile);
  277. }
  278. }
  279. }
  280. }
  281. this->CreateNewProjectFile(outputDir, projectDir, filename,
  282. executable, cmakeFilePattern,
  283. fileToOpen, sessionFilename);
  284. }
  285. }
  286. void cmGlobalKdevelopGenerator
  287. ::MergeProjectFiles(const std::string& outputDir,
  288. const std::string& projectDir,
  289. const std::string& filename,
  290. const std::string& executable,
  291. const std::string& cmakeFilePattern,
  292. const std::string& fileToOpen,
  293. const std::string& sessionFilename)
  294. {
  295. std::ifstream oldProjectFile(filename.c_str());
  296. if (!oldProjectFile)
  297. {
  298. this->CreateNewProjectFile(outputDir, projectDir, filename,
  299. executable, cmakeFilePattern,
  300. fileToOpen, sessionFilename);
  301. return;
  302. }
  303. /* Read the existing project file (line by line), copy all lines
  304. into the new project file, except the ones which can be reliably
  305. set from contents of the CMakeLists.txt */
  306. std::string tmp;
  307. std::vector<std::string> lines;
  308. while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
  309. {
  310. lines.push_back(tmp);
  311. }
  312. oldProjectFile.close();
  313. cmGeneratedFileStream fout(filename.c_str());
  314. if(!fout)
  315. {
  316. return;
  317. }
  318. for (std::vector<std::string>::const_iterator it=lines.begin();
  319. it!=lines.end(); it++)
  320. {
  321. const char* line=(*it).c_str();
  322. // skip these tags as they are always replaced
  323. if ((strstr(line, "<projectdirectory>")!=0)
  324. || (strstr(line, "<projectmanagement>")!=0)
  325. || (strstr(line, "<absoluteprojectpath>")!=0)
  326. || (strstr(line, "<filelistdirectory>")!=0)
  327. || (strstr(line, "<buildtool>")!=0)
  328. || (strstr(line, "<builddir>")!=0))
  329. {
  330. continue;
  331. }
  332. // output the line from the file if it is not one of the above tags
  333. fout<<*it<<"\n";
  334. // if this is the <general> tag output the stuff that goes in the
  335. // general tag
  336. if (strstr(line, "<general>"))
  337. {
  338. fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
  339. fout<< " <projectdirectory>" <<projectDir.c_str()
  340. << "</projectdirectory>\n"; //this one is important
  341. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
  342. //and this one
  343. }
  344. // inside kdevcustomproject the <filelistdirectory> must be put
  345. if (strstr(line, "<kdevcustomproject>"))
  346. {
  347. fout<<" <filelistdirectory>"<<outputDir.c_str()
  348. <<"</filelistdirectory>\n";
  349. }
  350. // buildtool and builddir go inside <build>
  351. if (strstr(line, "<build>"))
  352. {
  353. fout<<" <buildtool>make</buildtool>\n";
  354. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n";
  355. }
  356. }
  357. }
  358. void cmGlobalKdevelopGenerator
  359. ::CreateNewProjectFile(const std::string& outputDir,
  360. const std::string& projectDir,
  361. const std::string& filename,
  362. const std::string& executable,
  363. const std::string& cmakeFilePattern,
  364. const std::string& fileToOpen,
  365. const std::string& sessionFilename)
  366. {
  367. cmGeneratedFileStream fout(filename.c_str());
  368. if(!fout)
  369. {
  370. return;
  371. }
  372. // check for a version control system
  373. bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
  374. bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
  375. bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
  376. || this->GlobalGenerator->GetLanguageEnabled("CXX"));
  377. bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
  378. std::string primaryLanguage = "C++";
  379. if (enableFortran && !enableCxx)
  380. {
  381. primaryLanguage="Fortran77";
  382. }
  383. fout<<"<?xml version = '1.0'?>\n"
  384. "<kdevelop>\n"
  385. " <general>\n"
  386. " <author></author>\n"
  387. " <email></email>\n"
  388. " <version>$VERSION$</version>\n"
  389. " <projectmanagement>KDevCustomProject</projectmanagement>\n"
  390. " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
  391. " <ignoreparts/>\n"
  392. " <projectdirectory>" << projectDir.c_str() <<
  393. "</projectdirectory>\n"; //this one is important
  394. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
  395. // setup additional languages
  396. fout<<" <secondaryLanguages>\n";
  397. if (enableFortran && enableCxx)
  398. {
  399. fout<<" <language>Fortran</language>\n";
  400. }
  401. if (enableCxx)
  402. {
  403. fout<<" <language>C</language>\n";
  404. }
  405. fout<<" </secondaryLanguages>\n";
  406. if (hasSvn)
  407. {
  408. fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
  409. }
  410. else if (hasCvs)
  411. {
  412. fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
  413. }
  414. fout<<" </general>\n"
  415. " <kdevcustomproject>\n"
  416. " <filelistdirectory>" << outputDir.c_str() <<
  417. "</filelistdirectory>\n"
  418. " <run>\n"
  419. " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
  420. " <directoryradio>custom</directoryradio>\n"
  421. " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
  422. " <programargs></programargs>\n"
  423. " <terminal>false</terminal>\n"
  424. " <autocompile>true</autocompile>\n"
  425. " <envvars/>\n"
  426. " </run>\n"
  427. " <build>\n"
  428. " <buildtool>make</buildtool>\n"; //this one is important
  429. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
  430. fout<<" </build>\n"
  431. " <make>\n"
  432. " <abortonerror>false</abortonerror>\n"
  433. " <numberofjobs>1</numberofjobs>\n"
  434. " <dontact>false</dontact>\n"
  435. " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
  436. GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL")
  437. << " VERBOSE=1 </makebin>\n"
  438. " <selectedenvironment>default</selectedenvironment>\n"
  439. " <environments>\n"
  440. " <default/>\n"
  441. " </environments>\n"
  442. " </make>\n";
  443. fout<<" <blacklist>\n";
  444. for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
  445. dirIt != this->Blacklist.end();
  446. ++dirIt)
  447. {
  448. fout<<" <path>" << dirIt->c_str() << "</path>\n";
  449. }
  450. fout<<" </blacklist>\n";
  451. fout<<" </kdevcustomproject>\n"
  452. " <kdevfilecreate>\n"
  453. " <filetypes/>\n"
  454. " <useglobaltypes>\n"
  455. " <type ext=\"ui\" />\n"
  456. " <type ext=\"cpp\" />\n"
  457. " <type ext=\"h\" />\n"
  458. " </useglobaltypes>\n"
  459. " </kdevfilecreate>\n"
  460. " <kdevdoctreeview>\n"
  461. " <projectdoc>\n"
  462. " <userdocDir>html/</userdocDir>\n"
  463. " <apidocDir>html/</apidocDir>\n"
  464. " </projectdoc>\n"
  465. " <ignoreqt_xml/>\n"
  466. " <ignoredoxygen/>\n"
  467. " <ignorekdocs/>\n"
  468. " <ignoretocs/>\n"
  469. " <ignoredevhelp/>\n"
  470. " </kdevdoctreeview>\n";
  471. if (enableCxx)
  472. {
  473. fout<<" <cppsupportpart>\n"
  474. " <filetemplates>\n"
  475. " <interfacesuffix>.h</interfacesuffix>\n"
  476. " <implementationsuffix>.cpp</implementationsuffix>\n"
  477. " </filetemplates>\n"
  478. " </cppsupportpart>\n"
  479. " <kdevcppsupport>\n"
  480. " <codecompletion>\n"
  481. " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
  482. " <includeTypes>true</includeTypes>\n"
  483. " <includeEnums>true</includeEnums>\n"
  484. " <includeTypedefs>false</includeTypedefs>\n"
  485. " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
  486. " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
  487. " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
  488. " <codeCompletionDelay>250</codeCompletionDelay>\n"
  489. " <argumentsHintDelay>400</argumentsHintDelay>\n"
  490. " <headerCompletionDelay>250</headerCompletionDelay>\n"
  491. " </codecompletion>\n"
  492. " <references/>\n"
  493. " </kdevcppsupport>\n";
  494. }
  495. if (enableFortran)
  496. {
  497. fout<<" <kdevfortransupport>\n"
  498. " <ftnchek>\n"
  499. " <division>false</division>\n"
  500. " <extern>false</extern>\n"
  501. " <declare>false</declare>\n"
  502. " <pure>false</pure>\n"
  503. " <argumentsall>false</argumentsall>\n"
  504. " <commonall>false</commonall>\n"
  505. " <truncationall>false</truncationall>\n"
  506. " <usageall>false</usageall>\n"
  507. " <f77all>false</f77all>\n"
  508. " <portabilityall>false</portabilityall>\n"
  509. " <argumentsonly/>\n"
  510. " <commononly/>\n"
  511. " <truncationonly/>\n"
  512. " <usageonly/>\n"
  513. " <f77only/>\n"
  514. " <portabilityonly/>\n"
  515. " </ftnchek>\n"
  516. " </kdevfortransupport>\n";
  517. }
  518. // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
  519. // command
  520. fout<<" <kdevfileview>\n"
  521. " <groups>\n"
  522. " <group pattern=\"" << cmakeFilePattern.c_str() <<
  523. "\" name=\"CMake\" />\n";
  524. if (enableCxx)
  525. {
  526. fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
  527. " <group pattern=\"*.c\" name=\"C Sources\" />\n"
  528. " <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
  529. "/>\n";
  530. }
  531. if (enableFortran)
  532. {
  533. fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
  534. "*.F95\" name=\"Fortran Sources\" />\n";
  535. }
  536. fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
  537. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  538. " </groups>\n"
  539. " <tree>\n"
  540. " <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
  541. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  542. " </tree>\n"
  543. " </kdevfileview>\n"
  544. "</kdevelop>\n";
  545. if (sessionFilename.empty())
  546. {
  547. return;
  548. }
  549. // and a session file, so that kdevelop opens a file if it opens the
  550. // project the first time
  551. cmGeneratedFileStream devses(sessionFilename.c_str());
  552. if(!devses)
  553. {
  554. return;
  555. }
  556. devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
  557. "<!DOCTYPE KDevPrjSession>\n"
  558. "<KDevPrjSession>\n"
  559. " <DocsAndViews NumberOfDocuments=\"1\" >\n"
  560. " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
  561. "\" >\n"
  562. " <View0 line=\"0\" Type=\"Source\" />\n"
  563. " </Doc0>\n"
  564. " </DocsAndViews>\n"
  565. "</KDevPrjSession>\n";
  566. }