cmGlobalKdevelopGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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. #include <cmsys/FStream.hxx>
  22. //----------------------------------------------------------------------------
  23. void cmGlobalKdevelopGenerator
  24. ::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
  25. {
  26. entry.Name = this->GetName();
  27. entry.Brief = "Generates KDevelop 3 project files.";
  28. }
  29. cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
  30. :cmExternalMakefileProjectGenerator()
  31. {
  32. this->SupportedGlobalGenerators.push_back("Unix Makefiles");
  33. #ifdef CMAKE_USE_NINJA
  34. this->SupportedGlobalGenerators.push_back("Ninja");
  35. #endif
  36. }
  37. void cmGlobalKdevelopGenerator::Generate()
  38. {
  39. // for each sub project in the project create
  40. // a kdevelop project
  41. for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
  42. it = this->GlobalGenerator->GetProjectMap().begin();
  43. it!= this->GlobalGenerator->GetProjectMap().end();
  44. ++it)
  45. {
  46. cmMakefile* mf = it->second[0]->GetMakefile();
  47. std::string outputDir=mf->GetCurrentBinaryDirectory();
  48. std::string projectDir=mf->GetHomeDirectory();
  49. std::string projectName=mf->GetProjectName();
  50. std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
  51. std::string fileToOpen;
  52. const std::vector<cmLocalGenerator*>& lgs= it->second;
  53. // create the project.kdevelop.filelist file
  54. if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
  55. projectName, cmakeFilePattern, fileToOpen))
  56. {
  57. cmSystemTools::Error("Can not create filelist file");
  58. return;
  59. }
  60. //try to find the name of an executable so we have something to
  61. //run from kdevelop for now just pick the first executable found
  62. std::string executable;
  63. for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
  64. lg!=lgs.end(); lg++)
  65. {
  66. cmMakefile* makefile=(*lg)->GetMakefile();
  67. cmGeneratorTargetsType const& targets = makefile->GetGeneratorTargets();
  68. for (cmGeneratorTargetsType::const_iterator ti = targets.begin();
  69. ti != targets.end(); ti++)
  70. {
  71. if (ti->second->GetType()==cmTarget::EXECUTABLE)
  72. {
  73. executable = ti->second->GetLocation("");
  74. break;
  75. }
  76. }
  77. if (!executable.empty())
  78. {
  79. break;
  80. }
  81. }
  82. // now create a project file
  83. this->CreateProjectFile(outputDir, projectDir, projectName,
  84. executable, cmakeFilePattern, fileToOpen);
  85. }
  86. }
  87. bool cmGlobalKdevelopGenerator
  88. ::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
  89. const std::string& outputDir,
  90. const std::string& projectDirIn,
  91. const std::string& projectname,
  92. std::string& cmakeFilePattern,
  93. std::string& fileToOpen)
  94. {
  95. std::string projectDir = projectDirIn + "/";
  96. std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
  97. std::set<std::string> files;
  98. std::string tmp;
  99. for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
  100. it!=lgs.end(); it++)
  101. {
  102. cmMakefile* makefile=(*it)->GetMakefile();
  103. const std::vector<std::string>& listFiles=makefile->GetListFiles();
  104. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  105. lt!=listFiles.end(); lt++)
  106. {
  107. tmp=*lt;
  108. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  109. // make sure the file is part of this source tree
  110. if ((tmp[0]!='/') &&
  111. (strstr(tmp.c_str(),
  112. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  113. {
  114. files.insert(tmp);
  115. tmp=cmSystemTools::GetFilenameName(tmp);
  116. //add all files which dont match the default
  117. // */CMakeLists.txt;*cmake; to the file pattern
  118. if ((tmp!="CMakeLists.txt")
  119. && (strstr(tmp.c_str(), ".cmake")==0))
  120. {
  121. cmakeFilePattern+=tmp+";";
  122. }
  123. }
  124. }
  125. //get all sources
  126. cmTargets& targets=makefile->GetTargets();
  127. for (cmTargets::iterator ti = targets.begin();
  128. ti != targets.end(); ti++)
  129. {
  130. std::vector<cmSourceFile*> sources;
  131. cmGeneratorTarget* gt =
  132. this->GlobalGenerator->GetGeneratorTarget(&ti->second);
  133. gt->GetSourceFiles(sources, ti->second.GetMakefile()
  134. ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
  135. for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
  136. si!=sources.end(); si++)
  137. {
  138. tmp=(*si)->GetFullPath();
  139. std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
  140. headerBasename+="/";
  141. headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
  142. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  143. if ((tmp[0]!='/') &&
  144. (strstr(tmp.c_str(),
  145. cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
  146. (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
  147. {
  148. files.insert(tmp);
  149. // check if there's a matching header around
  150. for(std::vector<std::string>::const_iterator
  151. ext = makefile->GetHeaderExtensions().begin();
  152. ext != makefile->GetHeaderExtensions().end(); ++ext)
  153. {
  154. std::string hname=headerBasename;
  155. hname += ".";
  156. hname += *ext;
  157. if(cmSystemTools::FileExists(hname.c_str()))
  158. {
  159. cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
  160. files.insert(hname);
  161. break;
  162. }
  163. }
  164. }
  165. }
  166. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  167. lt!=listFiles.end(); lt++)
  168. {
  169. tmp=*lt;
  170. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  171. if ((tmp[0]!='/') &&
  172. (strstr(tmp.c_str(),
  173. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  174. {
  175. files.insert(tmp);
  176. }
  177. }
  178. }
  179. }
  180. //check if the output file already exists and read it
  181. //insert all files which exist into the set of files
  182. cmsys::ifstream oldFilelist(filename.c_str());
  183. if (oldFilelist)
  184. {
  185. while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
  186. {
  187. if (tmp[0]=='/')
  188. {
  189. continue;
  190. }
  191. std::string completePath=projectDir+tmp;
  192. if (cmSystemTools::FileExists(completePath.c_str()))
  193. {
  194. files.insert(tmp);
  195. }
  196. }
  197. oldFilelist.close();
  198. }
  199. //now write the new filename
  200. cmGeneratedFileStream fout(filename.c_str());
  201. if(!fout)
  202. {
  203. return false;
  204. }
  205. fileToOpen="";
  206. for (std::set<std::string>::const_iterator it=files.begin();
  207. it!=files.end(); it++)
  208. {
  209. // get the full path to the file
  210. tmp=cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
  211. // just select the first source file
  212. if (fileToOpen.empty())
  213. {
  214. std::string ext = cmSystemTools::GetFilenameExtension(tmp);
  215. if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".cxx")
  216. || (ext==".C") || (ext==".h") || (ext==".hpp"))
  217. {
  218. fileToOpen=tmp;
  219. }
  220. }
  221. // make it relative to the project dir
  222. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  223. // only put relative paths
  224. if (!tmp.empty() && tmp[0] != '/')
  225. {
  226. fout << tmp.c_str() <<"\n";
  227. }
  228. }
  229. return true;
  230. }
  231. /* create the project file, if it already exists, merge it with the
  232. existing one, otherwise create a new one */
  233. void cmGlobalKdevelopGenerator
  234. ::CreateProjectFile(const std::string& outputDir,
  235. const std::string& projectDir,
  236. const std::string& projectname,
  237. const std::string& executable,
  238. const std::string& cmakeFilePattern,
  239. const std::string& fileToOpen)
  240. {
  241. this->Blacklist.clear();
  242. std::string filename=outputDir+"/";
  243. filename+=projectname+".kdevelop";
  244. std::string sessionFilename=outputDir+"/";
  245. sessionFilename+=projectname+".kdevses";
  246. if (cmSystemTools::FileExists(filename.c_str()))
  247. {
  248. this->MergeProjectFiles(outputDir, projectDir, filename,
  249. executable, cmakeFilePattern,
  250. fileToOpen, sessionFilename);
  251. }
  252. else
  253. {
  254. // add all subdirectories which are cmake build directories to the
  255. // kdevelop blacklist so they are not monitored for added or removed files
  256. // since this is handled by adding files to the cmake files
  257. cmsys::Directory d;
  258. if (d.Load(projectDir))
  259. {
  260. size_t numf = d.GetNumberOfFiles();
  261. for (unsigned int i = 0; i < numf; i++)
  262. {
  263. std::string nextFile = d.GetFile(i);
  264. if ((nextFile!=".") && (nextFile!=".."))
  265. {
  266. std::string tmp = projectDir;
  267. tmp += "/";
  268. tmp += nextFile;
  269. if (cmSystemTools::FileIsDirectory(tmp))
  270. {
  271. tmp += "/CMakeCache.txt";
  272. if ((nextFile == "CMakeFiles")
  273. || (cmSystemTools::FileExists(tmp.c_str())))
  274. {
  275. this->Blacklist.push_back(nextFile);
  276. }
  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. cmsys::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
  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
  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<<"</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 <<
  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 <<
  417. "</filelistdirectory>\n"
  418. " <run>\n"
  419. " <mainprogram>" << executable << "</mainprogram>\n"
  420. " <directoryradio>custom</directoryradio>\n"
  421. " <customdirectory>"<<outputDir<<"</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<<"</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_MAKE_PROGRAM")
  437. << " </makebin>\n"
  438. " <selectedenvironment>default</selectedenvironment>\n"
  439. " <environments>\n"
  440. " <default>\n"
  441. " <envvar value=\"1\" name=\"VERBOSE\" />\n"
  442. " <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
  443. " </default>\n"
  444. " </environments>\n"
  445. " </make>\n";
  446. fout<<" <blacklist>\n";
  447. for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
  448. dirIt != this->Blacklist.end();
  449. ++dirIt)
  450. {
  451. fout<<" <path>" << *dirIt << "</path>\n";
  452. }
  453. fout<<" </blacklist>\n";
  454. fout<<" </kdevcustomproject>\n"
  455. " <kdevfilecreate>\n"
  456. " <filetypes/>\n"
  457. " <useglobaltypes>\n"
  458. " <type ext=\"ui\" />\n"
  459. " <type ext=\"cpp\" />\n"
  460. " <type ext=\"h\" />\n"
  461. " </useglobaltypes>\n"
  462. " </kdevfilecreate>\n"
  463. " <kdevdoctreeview>\n"
  464. " <projectdoc>\n"
  465. " <userdocDir>html/</userdocDir>\n"
  466. " <apidocDir>html/</apidocDir>\n"
  467. " </projectdoc>\n"
  468. " <ignoreqt_xml/>\n"
  469. " <ignoredoxygen/>\n"
  470. " <ignorekdocs/>\n"
  471. " <ignoretocs/>\n"
  472. " <ignoredevhelp/>\n"
  473. " </kdevdoctreeview>\n";
  474. if (enableCxx)
  475. {
  476. fout<<" <cppsupportpart>\n"
  477. " <filetemplates>\n"
  478. " <interfacesuffix>.h</interfacesuffix>\n"
  479. " <implementationsuffix>.cpp</implementationsuffix>\n"
  480. " </filetemplates>\n"
  481. " </cppsupportpart>\n"
  482. " <kdevcppsupport>\n"
  483. " <codecompletion>\n"
  484. " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
  485. " <includeTypes>true</includeTypes>\n"
  486. " <includeEnums>true</includeEnums>\n"
  487. " <includeTypedefs>false</includeTypedefs>\n"
  488. " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
  489. " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
  490. " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
  491. " <codeCompletionDelay>250</codeCompletionDelay>\n"
  492. " <argumentsHintDelay>400</argumentsHintDelay>\n"
  493. " <headerCompletionDelay>250</headerCompletionDelay>\n"
  494. " </codecompletion>\n"
  495. " <references/>\n"
  496. " </kdevcppsupport>\n";
  497. }
  498. if (enableFortran)
  499. {
  500. fout<<" <kdevfortransupport>\n"
  501. " <ftnchek>\n"
  502. " <division>false</division>\n"
  503. " <extern>false</extern>\n"
  504. " <declare>false</declare>\n"
  505. " <pure>false</pure>\n"
  506. " <argumentsall>false</argumentsall>\n"
  507. " <commonall>false</commonall>\n"
  508. " <truncationall>false</truncationall>\n"
  509. " <usageall>false</usageall>\n"
  510. " <f77all>false</f77all>\n"
  511. " <portabilityall>false</portabilityall>\n"
  512. " <argumentsonly/>\n"
  513. " <commononly/>\n"
  514. " <truncationonly/>\n"
  515. " <usageonly/>\n"
  516. " <f77only/>\n"
  517. " <portabilityonly/>\n"
  518. " </ftnchek>\n"
  519. " </kdevfortransupport>\n";
  520. }
  521. // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
  522. // command
  523. fout<<" <kdevfileview>\n"
  524. " <groups>\n"
  525. " <group pattern=\"" << cmakeFilePattern <<
  526. "\" name=\"CMake\" />\n";
  527. if (enableCxx)
  528. {
  529. fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
  530. " <group pattern=\"*.c\" name=\"C Sources\" />\n"
  531. " <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
  532. "/>\n";
  533. }
  534. if (enableFortran)
  535. {
  536. fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
  537. "*.F95\" name=\"Fortran Sources\" />\n";
  538. }
  539. fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
  540. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  541. " </groups>\n"
  542. " <tree>\n"
  543. " <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
  544. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  545. " </tree>\n"
  546. " </kdevfileview>\n"
  547. "</kdevelop>\n";
  548. if (sessionFilename.empty())
  549. {
  550. return;
  551. }
  552. // and a session file, so that kdevelop opens a file if it opens the
  553. // project the first time
  554. cmGeneratedFileStream devses(sessionFilename.c_str());
  555. if(!devses)
  556. {
  557. return;
  558. }
  559. devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
  560. "<!DOCTYPE KDevPrjSession>\n"
  561. "<KDevPrjSession>\n"
  562. " <DocsAndViews NumberOfDocuments=\"1\" >\n"
  563. " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
  564. "\" >\n"
  565. " <View0 line=\"0\" Type=\"Source\" />\n"
  566. " </Doc0>\n"
  567. " </DocsAndViews>\n"
  568. "</KDevPrjSession>\n";
  569. }