cmGlobalKdevelopGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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<cmStdString, 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<cmStdString> 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. const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles();
  131. for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
  132. si!=sources.end(); si++)
  133. {
  134. tmp=(*si)->GetFullPath();
  135. std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
  136. headerBasename+="/";
  137. headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
  138. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  139. if ((tmp[0]!='/') &&
  140. (strstr(tmp.c_str(),
  141. cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
  142. (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
  143. {
  144. files.insert(tmp);
  145. // check if there's a matching header around
  146. for(std::vector<std::string>::const_iterator
  147. ext = makefile->GetHeaderExtensions().begin();
  148. ext != makefile->GetHeaderExtensions().end(); ++ext)
  149. {
  150. std::string hname=headerBasename;
  151. hname += ".";
  152. hname += *ext;
  153. if(cmSystemTools::FileExists(hname.c_str()))
  154. {
  155. cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
  156. files.insert(hname);
  157. break;
  158. }
  159. }
  160. }
  161. }
  162. for (std::vector<std::string>::const_iterator lt=listFiles.begin();
  163. lt!=listFiles.end(); lt++)
  164. {
  165. tmp=*lt;
  166. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  167. if ((tmp[0]!='/') &&
  168. (strstr(tmp.c_str(),
  169. cmake::GetCMakeFilesDirectoryPostSlash())==0))
  170. {
  171. files.insert(tmp.c_str());
  172. }
  173. }
  174. }
  175. }
  176. //check if the output file already exists and read it
  177. //insert all files which exist into the set of files
  178. cmsys::ifstream oldFilelist(filename.c_str());
  179. if (oldFilelist)
  180. {
  181. while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
  182. {
  183. if (tmp[0]=='/')
  184. {
  185. continue;
  186. }
  187. std::string completePath=projectDir+tmp;
  188. if (cmSystemTools::FileExists(completePath.c_str()))
  189. {
  190. files.insert(tmp);
  191. }
  192. }
  193. oldFilelist.close();
  194. }
  195. //now write the new filename
  196. cmGeneratedFileStream fout(filename.c_str());
  197. if(!fout)
  198. {
  199. return false;
  200. }
  201. fileToOpen="";
  202. for (std::set<cmStdString>::const_iterator it=files.begin();
  203. it!=files.end(); it++)
  204. {
  205. // get the full path to the file
  206. tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str());
  207. // just select the first source file
  208. if (fileToOpen.empty())
  209. {
  210. std::string ext = cmSystemTools::GetFilenameExtension(tmp);
  211. if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".cxx")
  212. || (ext==".C") || (ext==".h") || (ext==".hpp"))
  213. {
  214. fileToOpen=tmp;
  215. }
  216. }
  217. // make it relative to the project dir
  218. cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
  219. // only put relative paths
  220. if (tmp.size() && tmp[0] != '/')
  221. {
  222. fout << tmp.c_str() <<"\n";
  223. }
  224. }
  225. return true;
  226. }
  227. /* create the project file, if it already exists, merge it with the
  228. existing one, otherwise create a new one */
  229. void cmGlobalKdevelopGenerator
  230. ::CreateProjectFile(const std::string& outputDir,
  231. const std::string& projectDir,
  232. const std::string& projectname,
  233. const std::string& executable,
  234. const std::string& cmakeFilePattern,
  235. const std::string& fileToOpen)
  236. {
  237. this->Blacklist.clear();
  238. std::string filename=outputDir+"/";
  239. filename+=projectname+".kdevelop";
  240. std::string sessionFilename=outputDir+"/";
  241. sessionFilename+=projectname+".kdevses";
  242. if (cmSystemTools::FileExists(filename.c_str()))
  243. {
  244. this->MergeProjectFiles(outputDir, projectDir, filename,
  245. executable, cmakeFilePattern,
  246. fileToOpen, sessionFilename);
  247. }
  248. else
  249. {
  250. // add all subdirectories which are cmake build directories to the
  251. // kdevelop blacklist so they are not monitored for added or removed files
  252. // since this is handled by adding files to the cmake files
  253. cmsys::Directory d;
  254. if (d.Load(projectDir.c_str()))
  255. {
  256. size_t numf = d.GetNumberOfFiles();
  257. for (unsigned int i = 0; i < numf; i++)
  258. {
  259. std::string nextFile = d.GetFile(i);
  260. if ((nextFile!=".") && (nextFile!=".."))
  261. {
  262. std::string tmp = projectDir;
  263. tmp += "/";
  264. tmp += nextFile;
  265. if (cmSystemTools::FileIsDirectory(tmp.c_str()))
  266. {
  267. tmp += "/CMakeCache.txt";
  268. if ((nextFile == "CMakeFiles")
  269. || (cmSystemTools::FileExists(tmp.c_str())))
  270. {
  271. this->Blacklist.push_back(nextFile);
  272. }
  273. }
  274. }
  275. }
  276. }
  277. this->CreateNewProjectFile(outputDir, projectDir, filename,
  278. executable, cmakeFilePattern,
  279. fileToOpen, sessionFilename);
  280. }
  281. }
  282. void cmGlobalKdevelopGenerator
  283. ::MergeProjectFiles(const std::string& outputDir,
  284. const std::string& projectDir,
  285. const std::string& filename,
  286. const std::string& executable,
  287. const std::string& cmakeFilePattern,
  288. const std::string& fileToOpen,
  289. const std::string& sessionFilename)
  290. {
  291. cmsys::ifstream oldProjectFile(filename.c_str());
  292. if (!oldProjectFile)
  293. {
  294. this->CreateNewProjectFile(outputDir, projectDir, filename,
  295. executable, cmakeFilePattern,
  296. fileToOpen, sessionFilename);
  297. return;
  298. }
  299. /* Read the existing project file (line by line), copy all lines
  300. into the new project file, except the ones which can be reliably
  301. set from contents of the CMakeLists.txt */
  302. std::string tmp;
  303. std::vector<std::string> lines;
  304. while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
  305. {
  306. lines.push_back(tmp);
  307. }
  308. oldProjectFile.close();
  309. cmGeneratedFileStream fout(filename.c_str());
  310. if(!fout)
  311. {
  312. return;
  313. }
  314. for (std::vector<std::string>::const_iterator it=lines.begin();
  315. it!=lines.end(); it++)
  316. {
  317. const char* line=(*it).c_str();
  318. // skip these tags as they are always replaced
  319. if ((strstr(line, "<projectdirectory>")!=0)
  320. || (strstr(line, "<projectmanagement>")!=0)
  321. || (strstr(line, "<absoluteprojectpath>")!=0)
  322. || (strstr(line, "<filelistdirectory>")!=0)
  323. || (strstr(line, "<buildtool>")!=0)
  324. || (strstr(line, "<builddir>")!=0))
  325. {
  326. continue;
  327. }
  328. // output the line from the file if it is not one of the above tags
  329. fout<<*it<<"\n";
  330. // if this is the <general> tag output the stuff that goes in the
  331. // general tag
  332. if (strstr(line, "<general>"))
  333. {
  334. fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
  335. fout<< " <projectdirectory>" <<projectDir.c_str()
  336. << "</projectdirectory>\n"; //this one is important
  337. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
  338. //and this one
  339. }
  340. // inside kdevcustomproject the <filelistdirectory> must be put
  341. if (strstr(line, "<kdevcustomproject>"))
  342. {
  343. fout<<" <filelistdirectory>"<<outputDir.c_str()
  344. <<"</filelistdirectory>\n";
  345. }
  346. // buildtool and builddir go inside <build>
  347. if (strstr(line, "<build>"))
  348. {
  349. fout<<" <buildtool>make</buildtool>\n";
  350. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n";
  351. }
  352. }
  353. }
  354. void cmGlobalKdevelopGenerator
  355. ::CreateNewProjectFile(const std::string& outputDir,
  356. const std::string& projectDir,
  357. const std::string& filename,
  358. const std::string& executable,
  359. const std::string& cmakeFilePattern,
  360. const std::string& fileToOpen,
  361. const std::string& sessionFilename)
  362. {
  363. cmGeneratedFileStream fout(filename.c_str());
  364. if(!fout)
  365. {
  366. return;
  367. }
  368. // check for a version control system
  369. bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
  370. bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
  371. bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
  372. || this->GlobalGenerator->GetLanguageEnabled("CXX"));
  373. bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
  374. std::string primaryLanguage = "C++";
  375. if (enableFortran && !enableCxx)
  376. {
  377. primaryLanguage="Fortran77";
  378. }
  379. fout<<"<?xml version = '1.0'?>\n"
  380. "<kdevelop>\n"
  381. " <general>\n"
  382. " <author></author>\n"
  383. " <email></email>\n"
  384. " <version>$VERSION$</version>\n"
  385. " <projectmanagement>KDevCustomProject</projectmanagement>\n"
  386. " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
  387. " <ignoreparts/>\n"
  388. " <projectdirectory>" << projectDir.c_str() <<
  389. "</projectdirectory>\n"; //this one is important
  390. fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
  391. // setup additional languages
  392. fout<<" <secondaryLanguages>\n";
  393. if (enableFortran && enableCxx)
  394. {
  395. fout<<" <language>Fortran</language>\n";
  396. }
  397. if (enableCxx)
  398. {
  399. fout<<" <language>C</language>\n";
  400. }
  401. fout<<" </secondaryLanguages>\n";
  402. if (hasSvn)
  403. {
  404. fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
  405. }
  406. else if (hasCvs)
  407. {
  408. fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
  409. }
  410. fout<<" </general>\n"
  411. " <kdevcustomproject>\n"
  412. " <filelistdirectory>" << outputDir.c_str() <<
  413. "</filelistdirectory>\n"
  414. " <run>\n"
  415. " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
  416. " <directoryradio>custom</directoryradio>\n"
  417. " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
  418. " <programargs></programargs>\n"
  419. " <terminal>false</terminal>\n"
  420. " <autocompile>true</autocompile>\n"
  421. " <envvars/>\n"
  422. " </run>\n"
  423. " <build>\n"
  424. " <buildtool>make</buildtool>\n"; //this one is important
  425. fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
  426. fout<<" </build>\n"
  427. " <make>\n"
  428. " <abortonerror>false</abortonerror>\n"
  429. " <numberofjobs>1</numberofjobs>\n"
  430. " <dontact>false</dontact>\n"
  431. " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
  432. GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")
  433. << " </makebin>\n"
  434. " <selectedenvironment>default</selectedenvironment>\n"
  435. " <environments>\n"
  436. " <default>\n"
  437. " <envvar value=\"1\" name=\"VERBOSE\" />\n"
  438. " <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
  439. " </default>\n"
  440. " </environments>\n"
  441. " </make>\n";
  442. fout<<" <blacklist>\n";
  443. for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
  444. dirIt != this->Blacklist.end();
  445. ++dirIt)
  446. {
  447. fout<<" <path>" << dirIt->c_str() << "</path>\n";
  448. }
  449. fout<<" </blacklist>\n";
  450. fout<<" </kdevcustomproject>\n"
  451. " <kdevfilecreate>\n"
  452. " <filetypes/>\n"
  453. " <useglobaltypes>\n"
  454. " <type ext=\"ui\" />\n"
  455. " <type ext=\"cpp\" />\n"
  456. " <type ext=\"h\" />\n"
  457. " </useglobaltypes>\n"
  458. " </kdevfilecreate>\n"
  459. " <kdevdoctreeview>\n"
  460. " <projectdoc>\n"
  461. " <userdocDir>html/</userdocDir>\n"
  462. " <apidocDir>html/</apidocDir>\n"
  463. " </projectdoc>\n"
  464. " <ignoreqt_xml/>\n"
  465. " <ignoredoxygen/>\n"
  466. " <ignorekdocs/>\n"
  467. " <ignoretocs/>\n"
  468. " <ignoredevhelp/>\n"
  469. " </kdevdoctreeview>\n";
  470. if (enableCxx)
  471. {
  472. fout<<" <cppsupportpart>\n"
  473. " <filetemplates>\n"
  474. " <interfacesuffix>.h</interfacesuffix>\n"
  475. " <implementationsuffix>.cpp</implementationsuffix>\n"
  476. " </filetemplates>\n"
  477. " </cppsupportpart>\n"
  478. " <kdevcppsupport>\n"
  479. " <codecompletion>\n"
  480. " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
  481. " <includeTypes>true</includeTypes>\n"
  482. " <includeEnums>true</includeEnums>\n"
  483. " <includeTypedefs>false</includeTypedefs>\n"
  484. " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
  485. " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
  486. " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
  487. " <codeCompletionDelay>250</codeCompletionDelay>\n"
  488. " <argumentsHintDelay>400</argumentsHintDelay>\n"
  489. " <headerCompletionDelay>250</headerCompletionDelay>\n"
  490. " </codecompletion>\n"
  491. " <references/>\n"
  492. " </kdevcppsupport>\n";
  493. }
  494. if (enableFortran)
  495. {
  496. fout<<" <kdevfortransupport>\n"
  497. " <ftnchek>\n"
  498. " <division>false</division>\n"
  499. " <extern>false</extern>\n"
  500. " <declare>false</declare>\n"
  501. " <pure>false</pure>\n"
  502. " <argumentsall>false</argumentsall>\n"
  503. " <commonall>false</commonall>\n"
  504. " <truncationall>false</truncationall>\n"
  505. " <usageall>false</usageall>\n"
  506. " <f77all>false</f77all>\n"
  507. " <portabilityall>false</portabilityall>\n"
  508. " <argumentsonly/>\n"
  509. " <commononly/>\n"
  510. " <truncationonly/>\n"
  511. " <usageonly/>\n"
  512. " <f77only/>\n"
  513. " <portabilityonly/>\n"
  514. " </ftnchek>\n"
  515. " </kdevfortransupport>\n";
  516. }
  517. // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
  518. // command
  519. fout<<" <kdevfileview>\n"
  520. " <groups>\n"
  521. " <group pattern=\"" << cmakeFilePattern.c_str() <<
  522. "\" name=\"CMake\" />\n";
  523. if (enableCxx)
  524. {
  525. fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
  526. " <group pattern=\"*.c\" name=\"C Sources\" />\n"
  527. " <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
  528. "/>\n";
  529. }
  530. if (enableFortran)
  531. {
  532. fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
  533. "*.F95\" name=\"Fortran Sources\" />\n";
  534. }
  535. fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
  536. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  537. " </groups>\n"
  538. " <tree>\n"
  539. " <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
  540. " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
  541. " </tree>\n"
  542. " </kdevfileview>\n"
  543. "</kdevelop>\n";
  544. if (sessionFilename.empty())
  545. {
  546. return;
  547. }
  548. // and a session file, so that kdevelop opens a file if it opens the
  549. // project the first time
  550. cmGeneratedFileStream devses(sessionFilename.c_str());
  551. if(!devses)
  552. {
  553. return;
  554. }
  555. devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
  556. "<!DOCTYPE KDevPrjSession>\n"
  557. "<KDevPrjSession>\n"
  558. " <DocsAndViews NumberOfDocuments=\"1\" >\n"
  559. " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
  560. "\" >\n"
  561. " <View0 line=\"0\" Type=\"Source\" />\n"
  562. " </Doc0>\n"
  563. " </DocsAndViews>\n"
  564. "</KDevPrjSession>\n";
  565. }