cmGlobalKdevelopGenerator.cxx 21 KB

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