cmGlobalKdevelopGenerator.cxx 20 KB

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