cmGlobalKdevelopGenerator.cxx 21.1 KB
Newer Older
1
2
3
4
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2004-2009 Kitware, Inc.
  Copyright 2004 Alexander Neundorf (neundorf@kde.org)
5

6
7
  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.
8

9
10
11
12
  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
13
#include "cmGlobalKdevelopGenerator.h"
Alexander Neundorf's avatar
   
Alexander Neundorf committed
14
#include "cmGlobalUnixMakefileGenerator3.h"
15
#include "cmLocalUnixMakefileGenerator3.h"
16
17
#include "cmMakefile.h"
#include "cmake.h"
18
19
#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
Alexander Neundorf's avatar
   
Alexander Neundorf committed
20
#include "cmSystemTools.h"
21

22
#include <cmsys/SystemTools.hxx>
Alexander Neundorf's avatar
   
Alexander Neundorf committed
23
#include <cmsys/Directory.hxx>
24

25
//----------------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
26
void cmGlobalKdevelopGenerator
Alexander Neundorf's avatar
   
Alexander Neundorf committed
27
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
28
{
29
30
31
  entry.Name = this->GetName();
  entry.Brief = "Generates KDevelop 3 project files.";
  entry.Full =
Ken Martin's avatar
Ken Martin committed
32
33
34
    "Project files for KDevelop 3 will be created in the top directory "
    "and in every subdirectory which features a CMakeLists.txt file "
    "containing a PROJECT() call. "
Bill Hoffman's avatar
Bill Hoffman committed
35
36
    "If you change the settings using KDevelop cmake will try its best "
    "to keep your changes when regenerating the project files. "
Ken Martin's avatar
Ken Martin committed
37
38
    "Additionally a hierarchy of UNIX makefiles is generated into the "
    "build tree.  Any "
39
    "standard UNIX-style make program can build the project through the "
Bill Hoffman's avatar
Bill Hoffman committed
40
    "default make target.  A \"make install\" target is also provided.";
41
}
42

Alexander Neundorf's avatar
   
Alexander Neundorf committed
43
44
45
46
cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
:cmExternalMakefileProjectGenerator()
{
  this->SupportedGlobalGenerators.push_back("Unix Makefiles");
47
48
49
#ifdef CMAKE_USE_NINJA
  this->SupportedGlobalGenerators.push_back("Ninja");
#endif
Alexander Neundorf's avatar
   
Alexander Neundorf committed
50
51
}

52
53
54
55
void cmGlobalKdevelopGenerator::Generate()
{
  // for each sub project in the project create 
  // a kdevelop project
Alexander Neundorf's avatar
   
Alexander Neundorf committed
56
57
58
59
  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator 
       it = this->GlobalGenerator->GetProjectMap().begin(); 
      it!= this->GlobalGenerator->GetProjectMap().end(); 
      ++it)
60
61
62
63
64
65
    {
    cmMakefile* mf = it->second[0]->GetMakefile();
    std::string outputDir=mf->GetStartOutputDirectory();
    std::string projectDir=mf->GetHomeDirectory();
    std::string projectName=mf->GetProjectName();
    std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
66
    std::string fileToOpen;
Alexander Neundorf's avatar
   
Alexander Neundorf committed
67
    const std::vector<cmLocalGenerator*>& lgs= it->second;
68
    // create the project.kdevelop.filelist file
Alexander Neundorf's avatar
   
Alexander Neundorf committed
69
    if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
70
                                 projectName, cmakeFilePattern, fileToOpen))
71
72
73
74
75
76
77
      {
      cmSystemTools::Error("Can not create filelist file");
      return;
      }
    //try to find the name of an executable so we have something to
    //run from kdevelop for now just pick the first executable found
    std::string executable;
Bill Hoffman's avatar
Bill Hoffman committed
78
79
    for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
         lg!=lgs.end(); lg++)
80
      {
Bill Hoffman's avatar
Bill Hoffman committed
81
82
83
84
85
86
87
88
89
90
91
92
      cmMakefile* makefile=(*lg)->GetMakefile();
      cmTargets& targets=makefile->GetTargets();
      for (cmTargets::iterator ti = targets.begin();
           ti != targets.end(); ti++)
        {
        if (ti->second.GetType()==cmTarget::EXECUTABLE)
          {
          executable = ti->second.GetProperty("LOCATION");
          break;
          }
        }
      if (!executable.empty())
93
94
95
96
        {
        break;
        }
      }
Alexander Neundorf's avatar
   
Alexander Neundorf committed
97
      
98
99
    // now create a project file
    this->CreateProjectFile(outputDir, projectDir, projectName,
100
                            executable, cmakeFilePattern, fileToOpen);
101
102
103
104
    }
}

bool cmGlobalKdevelopGenerator
Alexander Neundorf's avatar
   
Alexander Neundorf committed
105
::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
106
107
108
                     const std::string& outputDir, 
                     const std::string& projectDirIn,
                     const std::string& projectname,
109
110
                     std::string& cmakeFilePattern,
                     std::string& fileToOpen)
111
112
{
  std::string projectDir = projectDirIn + "/";
Bill Hoffman's avatar
Bill Hoffman committed
113
  std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

  std::set<cmStdString> files;
  std::string tmp;

  for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin(); 
       it!=lgs.end(); it++)
    {
    cmMakefile* makefile=(*it)->GetMakefile();
    const std::vector<std::string>& listFiles=makefile->GetListFiles();
    for (std::vector<std::string>::const_iterator lt=listFiles.begin(); 
         lt!=listFiles.end(); lt++)
      {
      tmp=*lt;
      cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
      // make sure the file is part of this source tree
129
130
131
      if ((tmp[0]!='/') && 
          (strstr(tmp.c_str(), 
                  cmake::GetCMakeFilesDirectoryPostSlash())==0))
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
        {
        files.insert(tmp);
        tmp=cmSystemTools::GetFilenameName(tmp);
        //add all files which dont match the default 
        // */CMakeLists.txt;*cmake; to the file pattern
        if ((tmp!="CMakeLists.txt")
            && (strstr(tmp.c_str(), ".cmake")==0))
          {
          cmakeFilePattern+=tmp+";";
          }
        }
      }
  
    //get all sources
    cmTargets& targets=makefile->GetTargets();
147
    for (cmTargets::iterator ti = targets.begin();
148
149
150
151
152
153
154
         ti != targets.end(); ti++)
      {
      const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles();
      for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
           si!=sources.end(); si++)
        {
        tmp=(*si)->GetFullPath();
155
156
157
158
        std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
        headerBasename+="/";
        headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);

159
        cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
160

161
        if ((tmp[0]!='/')  && 
Ken Martin's avatar
Ken Martin committed
162
            (strstr(tmp.c_str(), 
163
164
                  cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
           (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
165
166
          {
          files.insert(tmp);
167
168

          // check if there's a matching header around
169
170
171
          for(std::vector<std::string>::const_iterator
                ext = makefile->GetHeaderExtensions().begin();
              ext !=  makefile->GetHeaderExtensions().end(); ++ext)
172
173
174
175
176
177
            {
            std::string hname=headerBasename;
            hname += ".";
            hname += *ext;
            if(cmSystemTools::FileExists(hname.c_str()))
              {
178
              cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
179
180
181
182
              files.insert(hname);
              break;
              }
            }
183
184
185
186
187
188
189
          }
        }
      for (std::vector<std::string>::const_iterator lt=listFiles.begin();
           lt!=listFiles.end(); lt++)
        {
        tmp=*lt;
        cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
190
        if ((tmp[0]!='/') && 
Ken Martin's avatar
Ken Martin committed
191
192
            (strstr(tmp.c_str(), 
                    cmake::GetCMakeFilesDirectoryPostSlash())==0))
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
          {
          files.insert(tmp.c_str());
          }
        }
      }
    }

  //check if the output file already exists and read it
  //insert all files which exist into the set of files
  std::ifstream oldFilelist(filename.c_str());
  if (oldFilelist)
    {
    while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
      {
      if (tmp[0]=='/')
        {
        continue;
        }
      std::string completePath=projectDir+tmp;
      if (cmSystemTools::FileExists(completePath.c_str()))
        {
        files.insert(tmp);
        }
      }
    oldFilelist.close();
    }

  //now write the new filename
  cmGeneratedFileStream fout(filename.c_str());
  if(!fout)
    {
    return false;
    }
   
227
  fileToOpen="";
228
229
230
231
232
  for (std::set<cmStdString>::const_iterator it=files.begin(); 
       it!=files.end(); it++)
    {
    // get the full path to the file
    tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str());
233
234
235
236
    // just select the first source file
    if (fileToOpen.empty())
    {
       std::string ext = cmSystemTools::GetFilenameExtension(tmp);
Alexander Neundorf's avatar
   
Alexander Neundorf committed
237
238
       if ((ext==".c") || (ext==".cc") || (ext==".cpp")  || (ext==".cxx")
           || (ext==".C") || (ext==".h") || (ext==".hpp"))
239
       {
Ken Martin's avatar
Ken Martin committed
240
       fileToOpen=tmp;
241
242
       }
    }
243
244
245
246
247
248
249
250
251
    // make it relative to the project dir
    cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
    // only put relative paths
    if (tmp.size() && tmp[0] != '/')
      {
      fout << tmp.c_str() <<"\n";
      }
    }
  return true;
Alexander Neundorf's avatar
   
Alexander Neundorf committed
252
}
253
254
255
256


/* create the project file, if it already exists, merge it with the
existing one, otherwise create a new one */
Ken Martin's avatar
Ken Martin committed
257
258
259
260
261
262
263
void cmGlobalKdevelopGenerator
::CreateProjectFile(const std::string& outputDir,
                    const std::string& projectDir,
                    const std::string& projectname, 
                    const std::string& executable,
                    const std::string& cmakeFilePattern,
                    const std::string& fileToOpen)
264
{
Alexander Neundorf's avatar
   
Alexander Neundorf committed
265
266
  this->Blacklist.clear();

267
268
  std::string filename=outputDir+"/";
  filename+=projectname+".kdevelop";
269
270
  std::string sessionFilename=outputDir+"/";
  sessionFilename+=projectname+".kdevses";
271
272
273
274

  if (cmSystemTools::FileExists(filename.c_str()))
    {
    this->MergeProjectFiles(outputDir, projectDir, filename, 
Ken Martin's avatar
Ken Martin committed
275
276
                            executable, cmakeFilePattern, 
                            fileToOpen, sessionFilename);
277
278
279
    }
  else
    {
280
281
282
    // add all subdirectories which are cmake build directories to the 
    // kdevelop blacklist so they are not monitored for added or removed files
    // since this is handled by adding files to the cmake files
Alexander Neundorf's avatar
   
Alexander Neundorf committed
283
284
285
286
287
288
289
290
291
292
293
294
295
296
    cmsys::Directory d;
    if (d.Load(projectDir.c_str()))
      {
      size_t numf = d.GetNumberOfFiles();
      for (unsigned int i = 0; i < numf; i++)
        {
        std::string nextFile = d.GetFile(i);
        if ((nextFile!=".") && (nextFile!=".."))
          {
          std::string tmp = projectDir;
          tmp += "/";
          tmp += nextFile;
          if (cmSystemTools::FileIsDirectory(tmp.c_str()))
            {
297
298
299
300
301
302
            tmp += "/CMakeCache.txt";
            if ((nextFile == "CMakeFiles") 
                || (cmSystemTools::FileExists(tmp.c_str())))
              {
              this->Blacklist.push_back(nextFile);
              }
Alexander Neundorf's avatar
   
Alexander Neundorf committed
303
304
305
306
            }
          }
        }
      }
307
    this->CreateNewProjectFile(outputDir, projectDir, filename,
Ken Martin's avatar
Ken Martin committed
308
309
                               executable, cmakeFilePattern, 
                               fileToOpen, sessionFilename);
310
    }
Alexander Neundorf's avatar
   
Alexander Neundorf committed
311

312
313
}

Ken Martin's avatar
Ken Martin committed
314
315
316
317
318
319
320
321
void cmGlobalKdevelopGenerator
::MergeProjectFiles(const std::string& outputDir, 
                    const std::string& projectDir, 
                    const std::string& filename, 
                    const std::string& executable, 
                    const std::string& cmakeFilePattern,
                    const std::string& fileToOpen,
                    const std::string& sessionFilename)
322
323
324
325
{
  std::ifstream oldProjectFile(filename.c_str());
  if (!oldProjectFile)
    {
Ken Martin's avatar
Ken Martin committed
326
327
328
    this->CreateNewProjectFile(outputDir, projectDir, filename, 
                               executable, cmakeFilePattern, 
                               fileToOpen, sessionFilename);
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
    return;
    }

  /* Read the existing project file (line by line), copy all lines
    into the new project file, except the ones which can be reliably
    set from contents of the CMakeLists.txt */
  std::string tmp;
  std::vector<std::string> lines;
  while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
    {
    lines.push_back(tmp);
    }
  oldProjectFile.close();

  cmGeneratedFileStream fout(filename.c_str());
  if(!fout)
    {
    return;
    }

  for (std::vector<std::string>::const_iterator it=lines.begin(); 
       it!=lines.end(); it++)
    {
    const char* line=(*it).c_str();
    // skip these tags as they are always replaced
    if ((strstr(line, "<projectdirectory>")!=0)
        || (strstr(line, "<projectmanagement>")!=0)
        || (strstr(line, "<absoluteprojectpath>")!=0)
        || (strstr(line, "<filelistdirectory>")!=0)
        || (strstr(line, "<buildtool>")!=0)
        || (strstr(line, "<builddir>")!=0))
      {
      continue;
      }

    // output the line from the file if it is not one of the above tags
    fout<<*it<<"\n";
Ken Martin's avatar
Ken Martin committed
366
367
    // if this is the <general> tag output the stuff that goes in the
    // general tag
368
369
    if (strstr(line, "<general>"))
      {
Ken Martin's avatar
Ken Martin committed
370
371
372
373
374
      fout<< "  <projectmanagement>KDevCustomProject</projectmanagement>\n";
      fout<< "  <projectdirectory>" <<projectDir.c_str() 
          << "</projectdirectory>\n";   //this one is important
      fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n";
      //and this one
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
      }
    // inside kdevcustomproject the <filelistdirectory> must be put
    if (strstr(line, "<kdevcustomproject>"))
      {
      fout<<"    <filelistdirectory>"<<outputDir.c_str()
          <<"</filelistdirectory>\n";
      }
    // buildtool and builddir go inside <build>
    if (strstr(line, "<build>"))
      {
      fout<<"      <buildtool>make</buildtool>\n";
      fout<<"      <builddir>"<<outputDir.c_str()<<"</builddir>\n";
      }
    }
}

Ken Martin's avatar
Ken Martin committed
391
392
393
394
395
396
397
398
void cmGlobalKdevelopGenerator
::CreateNewProjectFile(const std::string& outputDir,
                       const std::string& projectDir,
                       const std::string& filename,
                       const std::string& executable,
                       const std::string& cmakeFilePattern,
                       const std::string& fileToOpen,
                       const std::string& sessionFilename)
399
400
401
402
403
404
405
{
  cmGeneratedFileStream fout(filename.c_str());
  if(!fout)
    {
    return;
    }

Alexander Neundorf's avatar
   
Alexander Neundorf committed
406
407
408
  // check for a version control system
  bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
  bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
Alexander Neundorf's avatar
   
Alexander Neundorf committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429

  bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C") 
                          || this->GlobalGenerator->GetLanguageEnabled("CXX"));
  bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
  std::string primaryLanguage = "C++";
  if (enableFortran && !enableCxx)
    {
    primaryLanguage="Fortran77";
    }

  fout<<"<?xml version = '1.0'?>\n"
        "<kdevelop>\n"
        "  <general>\n"
        "  <author></author>\n"
        "  <email></email>\n"
        "  <version>$VERSION$</version>\n"
        "  <projectmanagement>KDevCustomProject</projectmanagement>\n"
        "  <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
        "  <ignoreparts/>\n"
        "  <projectdirectory>" << projectDir.c_str() << 
        "</projectdirectory>\n";   //this one is important
Ken Martin's avatar
Ken Martin committed
430
  fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
Alexander Neundorf's avatar
   
Alexander Neundorf committed
431
432

  // setup additional languages
433
  fout<<"  <secondaryLanguages>\n";
Alexander Neundorf's avatar
   
Alexander Neundorf committed
434
435
436
437
438
439
440
441
  if (enableFortran && enableCxx)
    {
    fout<<"     <language>Fortran</language>\n";
    }
  if (enableCxx)
    {
    fout<<"     <language>C</language>\n";
    }
442
  fout<<"  </secondaryLanguages>\n";
Alexander Neundorf's avatar
   
Alexander Neundorf committed
443
444
445
446
447
448
449
450
451
452

  if (hasSvn)
    {
    fout << "  <versioncontrol>kdevsubversion</versioncontrol>\n";
    }
  else if (hasCvs)
    {
    fout << "  <versioncontrol>kdevcvsservice</versioncontrol>\n";
    }

Alexander Neundorf's avatar
   
Alexander Neundorf committed
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
  fout<<"  </general>\n"
        "  <kdevcustomproject>\n"
        "    <filelistdirectory>" << outputDir.c_str() <<
        "</filelistdirectory>\n"
        "    <run>\n"
        "      <mainprogram>" << executable.c_str() << "</mainprogram>\n"
        "      <directoryradio>custom</directoryradio>\n"
        "      <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
        "      <programargs></programargs>\n"
        "      <terminal>false</terminal>\n"
        "      <autocompile>true</autocompile>\n"
        "      <envvars/>\n"
        "    </run>\n"
        "    <build>\n"
        "      <buildtool>make</buildtool>\n"; //this one is important
Alexander Neundorf's avatar
ENH:    
Alexander Neundorf committed
468
  fout<<"      <builddir>"<<outputDir.c_str()<<"</builddir>\n";  //and this one
Alexander Neundorf's avatar
   
Alexander Neundorf committed
469
470
471
472
473
  fout<<"    </build>\n"
        "    <make>\n"
        "      <abortonerror>false</abortonerror>\n"
        "      <numberofjobs>1</numberofjobs>\n"
        "      <dontact>false</dontact>\n"
474
475
        "      <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
            GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL") 
476
            << " </makebin>\n"
Alexander Neundorf's avatar
   
Alexander Neundorf committed
477
478
        "      <selectedenvironment>default</selectedenvironment>\n"
        "      <environments>\n"
479
480
        "        <default>\n"
        "          <envvar value=\"1\" name=\"VERBOSE\" />\n"
481
        "          <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
482
        "        </default>\n"
Alexander Neundorf's avatar
   
Alexander Neundorf committed
483
484
        "      </environments>\n"
        "    </make>\n";
Alexander Neundorf's avatar
   
Alexander Neundorf committed
485
486
487
488
489
490

  fout<<"    <blacklist>\n";
  for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
      dirIt != this->Blacklist.end();
      ++dirIt)
    {
Alexander Neundorf's avatar
   
Alexander Neundorf committed
491
    fout<<"      <path>" << dirIt->c_str() << "</path>\n";
Alexander Neundorf's avatar
   
Alexander Neundorf committed
492
493
494
    }
  fout<<"    </blacklist>\n";

Alexander Neundorf's avatar
   
Alexander Neundorf committed
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
  fout<<"  </kdevcustomproject>\n"
        "  <kdevfilecreate>\n"
        "    <filetypes/>\n"
        "    <useglobaltypes>\n"
        "      <type ext=\"ui\" />\n"
        "      <type ext=\"cpp\" />\n"
        "      <type ext=\"h\" />\n"
        "    </useglobaltypes>\n"
        "  </kdevfilecreate>\n"
        "  <kdevdoctreeview>\n"
        "    <projectdoc>\n"
        "      <userdocDir>html/</userdocDir>\n"
        "      <apidocDir>html/</apidocDir>\n"
        "    </projectdoc>\n"
        "    <ignoreqt_xml/>\n"
        "    <ignoredoxygen/>\n"
        "    <ignorekdocs/>\n"
        "    <ignoretocs/>\n"
        "    <ignoredevhelp/>\n"
        "  </kdevdoctreeview>\n";

  if (enableCxx)
    {
    fout<<"  <cppsupportpart>\n"
          "    <filetemplates>\n"
          "      <interfacesuffix>.h</interfacesuffix>\n"
          "      <implementationsuffix>.cpp</implementationsuffix>\n"
          "    </filetemplates>\n"
          "  </cppsupportpart>\n"
          "  <kdevcppsupport>\n"
          "    <codecompletion>\n"
          "      <includeGlobalFunctions>true</includeGlobalFunctions>\n"
          "      <includeTypes>true</includeTypes>\n"
          "      <includeEnums>true</includeEnums>\n"
          "      <includeTypedefs>false</includeTypedefs>\n"
          "      <automaticCodeCompletion>true</automaticCodeCompletion>\n"
          "      <automaticArgumentsHint>true</automaticArgumentsHint>\n"
          "      <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
          "      <codeCompletionDelay>250</codeCompletionDelay>\n"
          "      <argumentsHintDelay>400</argumentsHintDelay>\n"
          "      <headerCompletionDelay>250</headerCompletionDelay>\n"
          "    </codecompletion>\n"
          "    <references/>\n"
          "  </kdevcppsupport>\n";
    }

  if (enableFortran)
    {
    fout<<"  <kdevfortransupport>\n"
          "    <ftnchek>\n"
          "      <division>false</division>\n"
          "      <extern>false</extern>\n"
          "      <declare>false</declare>\n"
          "      <pure>false</pure>\n"
          "      <argumentsall>false</argumentsall>\n"
          "      <commonall>false</commonall>\n"
          "      <truncationall>false</truncationall>\n"
          "      <usageall>false</usageall>\n"
          "      <f77all>false</f77all>\n"
          "      <portabilityall>false</portabilityall>\n"
          "      <argumentsonly/>\n"
          "      <commononly/>\n"
          "      <truncationonly/>\n"
          "      <usageonly/>\n"
          "      <f77only/>\n"
          "      <portabilityonly/>\n"
          "    </ftnchek>\n"
          "  </kdevfortransupport>\n";
    }

  // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
  // command
  fout<<"  <kdevfileview>\n"
        "    <groups>\n"
        "      <group pattern=\"" << cmakeFilePattern.c_str() <<
        "\" name=\"CMake\" />\n";

  if (enableCxx)
    {
    fout<<"      <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
          "      <group pattern=\"*.c\" name=\"C Sources\" />\n"
          "      <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
          "/>\n";
    }

  if (enableFortran)
    {
    fout<<"      <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
          "*.F95\" name=\"Fortran Sources\" />\n";
    }

  fout<<"      <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
        "      <hidenonprojectfiles>true</hidenonprojectfiles>\n"
        "    </groups>\n"
        "    <tree>\n"
        "      <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
        "      <hidenonprojectfiles>true</hidenonprojectfiles>\n"
        "    </tree>\n"
        "  </kdevfileview>\n"
        "</kdevelop>\n";

596
  if (sessionFilename.empty())
Alexander Neundorf's avatar
   
Alexander Neundorf committed
597
598
599
    {
    return;
    }
600

Ken Martin's avatar
Ken Martin committed
601
602
  // and a session file, so that kdevelop opens a file if it opens the
  // project the first time
603
604
  cmGeneratedFileStream devses(sessionFilename.c_str());
  if(!devses)
Alexander Neundorf's avatar
   
Alexander Neundorf committed
605
606
607
    {
    return;
    }
Alexander Neundorf's avatar
   
Alexander Neundorf committed
608
609
610
611
612
613
614
615
616
617
  devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
          "<!DOCTYPE KDevPrjSession>\n"
          "<KDevPrjSession>\n"
          " <DocsAndViews NumberOfDocuments=\"1\" >\n"
          "  <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
          "\" >\n"
          "   <View0 line=\"0\" Type=\"Source\" />\n"
          "  </Doc0>\n"
          " </DocsAndViews>\n"
          "</KDevPrjSession>\n";
618
619
}