cmGlobalKdevelopGenerator.cxx 21 KB

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