2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2004-2009 Kitware, Inc.
|
|
|
|
Copyright 2004 Alexander Neundorf (neundorf@kde.org)
|
2004-10-11 19:32:14 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2004-10-11 19:32:14 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2004-10-11 19:32:14 +04:00
|
|
|
#include "cmGlobalKdevelopGenerator.h"
|
2007-06-08 19:57:16 +04:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2007-01-25 23:44:52 +03:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
2004-10-11 19:32:14 +04:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmake.h"
|
2005-02-10 07:22:06 +03:00
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
2007-08-27 03:27:33 +04:00
|
|
|
#include "cmSystemTools.h"
|
2015-07-17 00:07:15 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2004-10-11 19:32:14 +04:00
|
|
|
|
2006-10-02 18:49:55 +04:00
|
|
|
#include <cmsys/SystemTools.hxx>
|
2007-08-27 03:27:33 +04:00
|
|
|
#include <cmsys/Directory.hxx>
|
2014-01-04 09:47:13 +04:00
|
|
|
#include <cmsys/FStream.hxx>
|
2006-10-02 18:49:55 +04:00
|
|
|
|
2004-10-11 19:32:14 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2006-05-11 18:40:28 +04:00
|
|
|
void cmGlobalKdevelopGenerator
|
2014-02-25 02:36:27 +04:00
|
|
|
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
|
2004-10-11 19:32:14 +04:00
|
|
|
{
|
2007-10-22 21:28:49 +04:00
|
|
|
entry.Name = this->GetName();
|
|
|
|
entry.Brief = "Generates KDevelop 3 project files.";
|
2004-10-11 19:32:14 +04:00
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
|
2007-06-08 19:57:16 +04:00
|
|
|
cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
|
|
|
|
:cmExternalMakefileProjectGenerator()
|
|
|
|
{
|
|
|
|
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
|
2012-06-15 14:14:13 +04:00
|
|
|
#ifdef CMAKE_USE_NINJA
|
|
|
|
this->SupportedGlobalGenerators.push_back("Ninja");
|
|
|
|
#endif
|
2007-06-08 19:57:16 +04:00
|
|
|
}
|
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
void cmGlobalKdevelopGenerator::Generate()
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
// for each sub project in the project create
|
2005-02-10 07:22:06 +03:00
|
|
|
// a kdevelop project
|
2014-02-10 09:21:34 +04:00
|
|
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
2012-08-13 21:42:58 +04:00
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it!= this->GlobalGenerator->GetProjectMap().end();
|
2007-06-08 19:57:16 +04:00
|
|
|
++it)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
2015-09-25 01:13:20 +03:00
|
|
|
std::string outputDir=it->second[0]->GetCurrentBinaryDirectory();
|
2015-10-07 02:17:48 +03:00
|
|
|
std::string projectDir=it->second[0]->GetSourceDirectory();
|
2015-10-07 01:29:25 +03:00
|
|
|
std::string projectName=it->second[0]->GetProjectName();
|
2005-02-10 07:22:06 +03:00
|
|
|
std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
|
2006-02-18 19:03:36 +03:00
|
|
|
std::string fileToOpen;
|
2007-06-08 19:57:16 +04:00
|
|
|
const std::vector<cmLocalGenerator*>& lgs= it->second;
|
2005-02-10 07:22:06 +03:00
|
|
|
// create the project.kdevelop.filelist file
|
2007-06-08 19:57:16 +04:00
|
|
|
if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
|
2006-02-18 19:03:36 +03:00
|
|
|
projectName, cmakeFilePattern, fileToOpen))
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
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;
|
2006-04-24 17:39:50 +04:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
|
|
|
|
lg!=lgs.end(); lg++)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> const& targets =
|
|
|
|
(*lg)->GetGeneratorTargets();
|
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator ti =
|
|
|
|
targets.begin(); ti != targets.end(); ti++)
|
2006-04-24 17:39:50 +04:00
|
|
|
{
|
2015-10-18 17:53:00 +03:00
|
|
|
if ((*ti)->GetType()==cmState::EXECUTABLE)
|
2006-04-24 17:39:50 +04:00
|
|
|
{
|
2015-10-18 17:53:00 +03:00
|
|
|
executable = (*ti)->GetLocation("");
|
2006-04-24 17:39:50 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!executable.empty())
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
// now create a project file
|
|
|
|
this->CreateProjectFile(outputDir, projectDir, projectName,
|
2006-02-18 19:03:36 +03:00
|
|
|
executable, cmakeFilePattern, fileToOpen);
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGlobalKdevelopGenerator
|
2007-06-08 19:57:16 +04:00
|
|
|
::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
|
2012-08-13 21:42:58 +04:00
|
|
|
const std::string& outputDir,
|
2005-02-10 07:22:06 +03:00
|
|
|
const std::string& projectDirIn,
|
|
|
|
const std::string& projectname,
|
2006-02-18 19:03:36 +03:00
|
|
|
std::string& cmakeFilePattern,
|
|
|
|
std::string& fileToOpen)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
std::string projectDir = projectDirIn + "/";
|
2005-02-10 15:44:06 +03:00
|
|
|
std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
|
2005-02-10 07:22:06 +03:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> files;
|
2005-02-10 07:22:06 +03:00
|
|
|
std::string tmp;
|
|
|
|
|
2015-10-24 15:58:23 +03:00
|
|
|
std::vector<std::string> hdrExts =
|
|
|
|
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
|
2005-02-10 07:22:06 +03:00
|
|
|
it!=lgs.end(); it++)
|
|
|
|
{
|
|
|
|
cmMakefile* makefile=(*it)->GetMakefile();
|
|
|
|
const std::vector<std::string>& listFiles=makefile->GetListFiles();
|
2012-08-13 21:42:58 +04:00
|
|
|
for (std::vector<std::string>::const_iterator lt=listFiles.begin();
|
2005-02-10 07:22:06 +03:00
|
|
|
lt!=listFiles.end(); lt++)
|
|
|
|
{
|
|
|
|
tmp=*lt;
|
|
|
|
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
|
|
|
|
// make sure the file is part of this source tree
|
2012-08-13 21:42:58 +04:00
|
|
|
if ((tmp[0]!='/') &&
|
|
|
|
(strstr(tmp.c_str(),
|
2006-06-14 20:28:32 +04:00
|
|
|
cmake::GetCMakeFilesDirectoryPostSlash())==0))
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
files.insert(tmp);
|
|
|
|
tmp=cmSystemTools::GetFilenameName(tmp);
|
2012-08-13 21:42:58 +04:00
|
|
|
//add all files which dont match the default
|
2005-02-10 07:22:06 +03:00
|
|
|
// */CMakeLists.txt;*cmake; to the file pattern
|
|
|
|
if ((tmp!="CMakeLists.txt")
|
|
|
|
&& (strstr(tmp.c_str(), ".cmake")==0))
|
|
|
|
{
|
|
|
|
cmakeFilePattern+=tmp+";";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
//get all sources
|
2015-10-18 18:06:14 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets=(*it)->GetGeneratorTargets();
|
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
|
2005-02-10 07:22:06 +03:00
|
|
|
ti != targets.end(); ti++)
|
|
|
|
{
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> sources;
|
2015-10-18 18:06:14 +03:00
|
|
|
cmGeneratorTarget* gt = *ti;
|
|
|
|
gt->GetSourceFiles(sources, gt->Target->GetMakefile()
|
2014-02-13 20:25:00 +04:00
|
|
|
->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
2005-02-10 07:22:06 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
|
|
|
|
si!=sources.end(); si++)
|
|
|
|
{
|
|
|
|
tmp=(*si)->GetFullPath();
|
2006-10-02 18:49:55 +04:00
|
|
|
std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
|
|
|
|
headerBasename+="/";
|
|
|
|
headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
|
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
|
2006-10-02 18:49:55 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
if ((tmp[0]!='/') &&
|
|
|
|
(strstr(tmp.c_str(),
|
2006-10-02 18:49:55 +04:00
|
|
|
cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
|
|
|
|
(cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
files.insert(tmp);
|
2006-10-02 18:49:55 +04:00
|
|
|
|
|
|
|
// check if there's a matching header around
|
2006-10-03 17:12:27 +04:00
|
|
|
for(std::vector<std::string>::const_iterator
|
2015-10-24 15:58:23 +03:00
|
|
|
ext = hdrExts.begin(); ext != hdrExts.end(); ++ext)
|
2006-10-02 18:49:55 +04:00
|
|
|
{
|
|
|
|
std::string hname=headerBasename;
|
|
|
|
hname += ".";
|
|
|
|
hname += *ext;
|
|
|
|
if(cmSystemTools::FileExists(hname.c_str()))
|
|
|
|
{
|
2007-01-25 23:44:52 +03:00
|
|
|
cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
|
2006-10-02 18:49:55 +04:00
|
|
|
files.insert(hname);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator lt=listFiles.begin();
|
|
|
|
lt!=listFiles.end(); lt++)
|
|
|
|
{
|
|
|
|
tmp=*lt;
|
|
|
|
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
|
2012-08-13 21:42:58 +04:00
|
|
|
if ((tmp[0]!='/') &&
|
|
|
|
(strstr(tmp.c_str(),
|
2006-06-15 19:51:51 +04:00
|
|
|
cmake::GetCMakeFilesDirectoryPostSlash())==0))
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
files.insert(tmp);
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//check if the output file already exists and read it
|
|
|
|
//insert all files which exist into the set of files
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream oldFilelist(filename.c_str());
|
2005-02-10 07:22:06 +03:00
|
|
|
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;
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2006-02-18 19:03:36 +03:00
|
|
|
fileToOpen="";
|
2014-02-10 09:21:34 +04:00
|
|
|
for (std::set<std::string>::const_iterator it=files.begin();
|
2005-02-10 07:22:06 +03:00
|
|
|
it!=files.end(); it++)
|
|
|
|
{
|
|
|
|
// get the full path to the file
|
2014-10-15 16:54:05 +04:00
|
|
|
tmp=cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
|
2006-02-18 19:03:36 +03:00
|
|
|
// just select the first source file
|
|
|
|
if (fileToOpen.empty())
|
|
|
|
{
|
|
|
|
std::string ext = cmSystemTools::GetFilenameExtension(tmp);
|
2007-08-21 21:47:29 +04:00
|
|
|
if ((ext==".c") || (ext==".cc") || (ext==".cpp") || (ext==".cxx")
|
|
|
|
|| (ext==".C") || (ext==".h") || (ext==".hpp"))
|
2006-02-18 19:03:36 +03:00
|
|
|
{
|
2006-05-11 18:40:28 +04:00
|
|
|
fileToOpen=tmp;
|
2006-02-18 19:03:36 +03:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
// make it relative to the project dir
|
|
|
|
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
|
|
|
|
// only put relative paths
|
2015-01-16 01:04:33 +03:00
|
|
|
if (!tmp.empty() && tmp[0] != '/')
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
fout << tmp.c_str() <<"\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2007-06-08 19:57:16 +04:00
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* create the project file, if it already exists, merge it with the
|
|
|
|
existing one, otherwise create a new one */
|
2006-05-11 18:40:28 +04:00
|
|
|
void cmGlobalKdevelopGenerator
|
|
|
|
::CreateProjectFile(const std::string& outputDir,
|
|
|
|
const std::string& projectDir,
|
2012-08-13 21:42:58 +04:00
|
|
|
const std::string& projectname,
|
2006-05-11 18:40:28 +04:00
|
|
|
const std::string& executable,
|
|
|
|
const std::string& cmakeFilePattern,
|
|
|
|
const std::string& fileToOpen)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
2007-08-27 03:27:33 +04:00
|
|
|
this->Blacklist.clear();
|
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
std::string filename=outputDir+"/";
|
|
|
|
filename+=projectname+".kdevelop";
|
2006-02-18 19:03:36 +03:00
|
|
|
std::string sessionFilename=outputDir+"/";
|
|
|
|
sessionFilename+=projectname+".kdevses";
|
2005-02-10 07:22:06 +03:00
|
|
|
|
|
|
|
if (cmSystemTools::FileExists(filename.c_str()))
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
this->MergeProjectFiles(outputDir, projectDir, filename,
|
|
|
|
executable, cmakeFilePattern,
|
2006-05-11 18:40:28 +04:00
|
|
|
fileToOpen, sessionFilename);
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
// add all subdirectories which are cmake build directories to the
|
2008-08-17 00:33:47 +04:00
|
|
|
// kdevelop blacklist so they are not monitored for added or removed files
|
|
|
|
// since this is handled by adding files to the cmake files
|
2007-08-31 21:42:21 +04:00
|
|
|
cmsys::Directory d;
|
2014-10-15 16:54:05 +04:00
|
|
|
if (d.Load(projectDir))
|
2007-08-31 21:42:21 +04:00
|
|
|
{
|
|
|
|
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;
|
2014-10-15 16:54:05 +04:00
|
|
|
if (cmSystemTools::FileIsDirectory(tmp))
|
2007-08-31 21:42:21 +04:00
|
|
|
{
|
2008-08-17 00:33:47 +04:00
|
|
|
tmp += "/CMakeCache.txt";
|
2012-08-13 21:42:58 +04:00
|
|
|
if ((nextFile == "CMakeFiles")
|
2008-08-17 00:33:47 +04:00
|
|
|
|| (cmSystemTools::FileExists(tmp.c_str())))
|
|
|
|
{
|
|
|
|
this->Blacklist.push_back(nextFile);
|
|
|
|
}
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
this->CreateNewProjectFile(outputDir, projectDir, filename,
|
2012-08-13 21:42:58 +04:00
|
|
|
executable, cmakeFilePattern,
|
2006-05-11 18:40:28 +04:00
|
|
|
fileToOpen, sessionFilename);
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
2007-08-27 03:27:33 +04:00
|
|
|
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
|
2006-05-11 18:40:28 +04:00
|
|
|
void cmGlobalKdevelopGenerator
|
2012-08-13 21:42:58 +04:00
|
|
|
::MergeProjectFiles(const std::string& outputDir,
|
|
|
|
const std::string& projectDir,
|
|
|
|
const std::string& filename,
|
|
|
|
const std::string& executable,
|
2006-05-11 18:40:28 +04:00
|
|
|
const std::string& cmakeFilePattern,
|
|
|
|
const std::string& fileToOpen,
|
|
|
|
const std::string& sessionFilename)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream oldProjectFile(filename.c_str());
|
2005-02-10 07:22:06 +03:00
|
|
|
if (!oldProjectFile)
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
this->CreateNewProjectFile(outputDir, projectDir, filename,
|
|
|
|
executable, cmakeFilePattern,
|
2006-05-11 18:40:28 +04:00
|
|
|
fileToOpen, sessionFilename);
|
2005-02-10 07:22:06 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
for (std::vector<std::string>::const_iterator it=lines.begin();
|
2005-02-10 07:22:06 +03:00
|
|
|
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";
|
2006-05-11 18:40:28 +04:00
|
|
|
// if this is the <general> tag output the stuff that goes in the
|
|
|
|
// general tag
|
2005-02-10 07:22:06 +03:00
|
|
|
if (strstr(line, "<general>"))
|
|
|
|
{
|
2006-05-11 18:40:28 +04:00
|
|
|
fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
|
2014-03-11 16:35:32 +04:00
|
|
|
fout<< " <projectdirectory>" <<projectDir
|
2006-05-11 18:40:28 +04:00
|
|
|
<< "</projectdirectory>\n"; //this one is important
|
|
|
|
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
|
|
|
|
//and this one
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
// inside kdevcustomproject the <filelistdirectory> must be put
|
|
|
|
if (strstr(line, "<kdevcustomproject>"))
|
|
|
|
{
|
2014-03-11 16:35:32 +04:00
|
|
|
fout<<" <filelistdirectory>"<<outputDir
|
2005-02-10 07:22:06 +03:00
|
|
|
<<"</filelistdirectory>\n";
|
|
|
|
}
|
|
|
|
// buildtool and builddir go inside <build>
|
|
|
|
if (strstr(line, "<build>"))
|
|
|
|
{
|
|
|
|
fout<<" <buildtool>make</buildtool>\n";
|
2014-03-11 16:35:32 +04:00
|
|
|
fout<<" <builddir>"<<outputDir<<"</builddir>\n";
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-11 18:40:28 +04:00
|
|
|
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)
|
2005-02-10 07:22:06 +03:00
|
|
|
{
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if(!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-07-17 00:07:15 +03:00
|
|
|
cmXMLWriter xml(fout);
|
2005-02-10 07:22:06 +03:00
|
|
|
|
2007-06-11 03:51:26 +04:00
|
|
|
// check for a version control system
|
|
|
|
bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
|
|
|
|
bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
|
2007-08-31 21:42:21 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
|
2007-08-31 21:42:21 +04:00
|
|
|
|| this->GlobalGenerator->GetLanguageEnabled("CXX"));
|
|
|
|
bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
|
|
|
|
std::string primaryLanguage = "C++";
|
|
|
|
if (enableFortran && !enableCxx)
|
|
|
|
{
|
|
|
|
primaryLanguage="Fortran77";
|
|
|
|
}
|
|
|
|
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartDocument();
|
|
|
|
xml.StartElement("kdevelop");
|
|
|
|
xml.StartElement("general");
|
|
|
|
|
|
|
|
xml.Element("author", "");
|
|
|
|
xml.Element("email", "");
|
|
|
|
xml.Element("version", "$VERSION$");
|
|
|
|
xml.Element("projectmanagement", "KDevCustomProject");
|
|
|
|
xml.Element("primarylanguage", primaryLanguage);
|
|
|
|
xml.Element("ignoreparts");
|
|
|
|
xml.Element("projectdirectory", projectDir); // this one is important
|
|
|
|
xml.Element("absoluteprojectpath", "true"); // and this one
|
2007-08-31 21:42:21 +04:00
|
|
|
|
|
|
|
// setup additional languages
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("secondaryLanguages");
|
2007-08-31 21:42:21 +04:00
|
|
|
if (enableFortran && enableCxx)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.Element("language", "Fortran");
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
if (enableCxx)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.Element("language", "C");
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.EndElement();
|
2007-06-11 03:51:26 +04:00
|
|
|
|
|
|
|
if (hasSvn)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.Element("versioncontrol", "kdevsubversion");
|
2007-06-11 03:51:26 +04:00
|
|
|
}
|
|
|
|
else if (hasCvs)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.Element("versioncontrol", "kdevcvsservice");
|
2007-06-11 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.EndElement(); // general
|
|
|
|
xml.StartElement("kdevcustomproject");
|
|
|
|
|
|
|
|
xml.Element("filelistdirectory", outputDir);
|
|
|
|
|
|
|
|
xml.StartElement("run");
|
|
|
|
xml.Element("mainprogram", executable);
|
|
|
|
xml.Element("directoryradio", "custom");
|
|
|
|
xml.Element("customdirectory", outputDir);
|
|
|
|
xml.Element("programargs", "");
|
|
|
|
xml.Element("terminal", "false");
|
|
|
|
xml.Element("autocompile", "true");
|
|
|
|
xml.Element("envvars");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("build");
|
|
|
|
xml.Element("buildtool", "make"); // this one is important
|
|
|
|
xml.Element("builddir", outputDir); // and this one
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("make");
|
|
|
|
xml.Element("abortonerror", "false");
|
|
|
|
xml.Element("numberofjobs", 1);
|
|
|
|
xml.Element("dontact", "false");
|
|
|
|
xml.Element("makebin", this->GlobalGenerator->GetLocalGenerators()[0]->
|
|
|
|
GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"));
|
|
|
|
xml.Element("selectedenvironment", "default");
|
|
|
|
|
|
|
|
xml.StartElement("environments");
|
|
|
|
xml.StartElement("default");
|
|
|
|
|
|
|
|
xml.StartElement("envvar");
|
|
|
|
xml.Attribute("value", 1);
|
|
|
|
xml.Attribute("name", "VERBOSE");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("envvar");
|
|
|
|
xml.Attribute("value", 1);
|
|
|
|
xml.Attribute("name", "CMAKE_NO_VERBOSE");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.EndElement(); // default
|
|
|
|
xml.EndElement(); // environments
|
|
|
|
xml.EndElement(); // make
|
|
|
|
|
|
|
|
xml.StartElement("blacklist");
|
2007-08-27 03:27:33 +04:00
|
|
|
for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
|
|
|
|
dirIt != this->Blacklist.end();
|
|
|
|
++dirIt)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.Element("path", *dirIt);
|
2007-08-27 03:27:33 +04:00
|
|
|
}
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.EndElement(); // kdevcustomproject
|
|
|
|
|
|
|
|
xml.StartElement("kdevfilecreate");
|
|
|
|
xml.Element("filetypes");
|
|
|
|
xml.StartElement("useglobaltypes");
|
|
|
|
|
|
|
|
xml.StartElement("type");
|
|
|
|
xml.Attribute("ext", "ui");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("type");
|
|
|
|
xml.Attribute("ext", "cpp");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("type");
|
|
|
|
xml.Attribute("ext", "h");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.EndElement(); // useglobaltypes
|
|
|
|
xml.EndElement(); // kdevfilecreate
|
|
|
|
|
|
|
|
xml.StartElement("kdevdoctreeview");
|
|
|
|
xml.StartElement("projectdoc");
|
|
|
|
xml.Element("userdocDir", "html/");
|
|
|
|
xml.Element("apidocDir", "html/");
|
|
|
|
xml.EndElement(); // projectdoc
|
|
|
|
xml.Element("ignoreqt_xml");
|
|
|
|
xml.Element("ignoredoxygen");
|
|
|
|
xml.Element("ignorekdocs");
|
|
|
|
xml.Element("ignoretocs");
|
|
|
|
xml.Element("ignoredevhelp");
|
|
|
|
xml.EndElement(); // kdevdoctreeview;
|
2007-08-31 21:42:21 +04:00
|
|
|
|
|
|
|
if (enableCxx)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("cppsupportpart");
|
|
|
|
xml.StartElement("filetemplates");
|
|
|
|
xml.Element("interfacesuffix", ".h");
|
|
|
|
xml.Element("implementationsuffix", ".cpp");
|
|
|
|
xml.EndElement(); // filetemplates
|
|
|
|
xml.EndElement(); // cppsupportpart
|
|
|
|
|
|
|
|
xml.StartElement("kdevcppsupport");
|
|
|
|
xml.StartElement("codecompletion");
|
|
|
|
xml.Element("includeGlobalFunctions", "true");
|
|
|
|
xml.Element("includeTypes", "true");
|
|
|
|
xml.Element("includeEnums", "true");
|
|
|
|
xml.Element("includeTypedefs", "false");
|
|
|
|
xml.Element("automaticCodeCompletion", "true");
|
|
|
|
xml.Element("automaticArgumentsHint", "true");
|
|
|
|
xml.Element("automaticHeaderCompletion", "true");
|
|
|
|
xml.Element("codeCompletionDelay", 250);
|
|
|
|
xml.Element("argumentsHintDelay", 400);
|
|
|
|
xml.Element("headerCompletionDelay", 250);
|
|
|
|
xml.EndElement(); // codecompletion
|
|
|
|
xml.Element("references");
|
|
|
|
xml.EndElement(); // kdevcppsupport;
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (enableFortran)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("kdevfortransupport");
|
|
|
|
xml.StartElement("ftnchek");
|
|
|
|
xml.Element("division", "false");
|
|
|
|
xml.Element("extern", "false");
|
|
|
|
xml.Element("declare", "false");
|
|
|
|
xml.Element("pure", "false");
|
|
|
|
xml.Element("argumentsall", "false");
|
|
|
|
xml.Element("commonall", "false");
|
|
|
|
xml.Element("truncationall", "false");
|
|
|
|
xml.Element("usageall", "false");
|
|
|
|
xml.Element("f77all", "false");
|
|
|
|
xml.Element("portabilityall", "false");
|
|
|
|
xml.Element("argumentsonly");
|
|
|
|
xml.Element("commononly");
|
|
|
|
xml.Element("truncationonly");
|
|
|
|
xml.Element("usageonly");
|
|
|
|
xml.Element("f77only");
|
|
|
|
xml.Element("portabilityonly");
|
|
|
|
xml.EndElement(); // ftnchek
|
|
|
|
xml.EndElement(); // kdevfortransupport;
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
|
|
|
|
// command
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("kdevfileview");
|
|
|
|
xml.StartElement("groups");
|
|
|
|
|
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern", cmakeFilePattern);
|
|
|
|
xml.Attribute("name", "CMake");
|
|
|
|
xml.EndElement();
|
2007-08-31 21:42:21 +04:00
|
|
|
|
|
|
|
if (enableCxx)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern", "*.h;*.hxx;*.hpp");
|
|
|
|
xml.Attribute("name", "Header");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern", "*.c");
|
|
|
|
xml.Attribute("name", "C Sources");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern", "*.cpp;*.C;*.cxx;*.cc");
|
|
|
|
xml.Attribute("name", "C++ Sources");
|
|
|
|
xml.EndElement();
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (enableFortran)
|
|
|
|
{
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern",
|
|
|
|
"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95");
|
|
|
|
xml.Attribute("name", "Fortran Sources");
|
|
|
|
xml.EndElement();
|
2007-08-31 21:42:21 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 00:07:15 +03:00
|
|
|
xml.StartElement("group");
|
|
|
|
xml.Attribute("pattern", "*.ui");
|
|
|
|
xml.Attribute("name", "Qt Designer files");
|
|
|
|
xml.EndElement();
|
|
|
|
|
|
|
|
xml.Element("hidenonprojectfiles", "true");
|
|
|
|
xml.EndElement(); // groups
|
|
|
|
|
|
|
|
xml.StartElement("tree");
|
|
|
|
xml.Element("hidepatterns", "*.o,*.lo,CVS,*~,cmake*");
|
|
|
|
xml.Element("hidenonprojectfiles", "true");
|
|
|
|
xml.EndElement(); // tree
|
|
|
|
|
|
|
|
xml.EndElement(); // kdevfileview
|
|
|
|
xml.EndElement(); // kdevelop;
|
|
|
|
xml.EndDocument();
|
2007-08-31 21:42:21 +04:00
|
|
|
|
2006-02-18 19:03:36 +03:00
|
|
|
if (sessionFilename.empty())
|
2007-05-18 00:50:53 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-02-18 19:03:36 +03:00
|
|
|
|
2006-05-11 18:40:28 +04:00
|
|
|
// and a session file, so that kdevelop opens a file if it opens the
|
|
|
|
// project the first time
|
2006-02-18 19:03:36 +03:00
|
|
|
cmGeneratedFileStream devses(sessionFilename.c_str());
|
|
|
|
if(!devses)
|
2007-05-18 00:50:53 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-07-17 00:07:15 +03:00
|
|
|
cmXMLWriter sesxml(devses);
|
|
|
|
sesxml.StartDocument("UTF-8");
|
|
|
|
sesxml.Doctype("KDevPrjSession");
|
|
|
|
sesxml.StartElement("KDevPrjSession");
|
|
|
|
|
|
|
|
sesxml.StartElement("DocsAndViews");
|
|
|
|
sesxml.Attribute("NumberOfDocuments", 1);
|
|
|
|
|
|
|
|
sesxml.StartElement("Doc0");
|
|
|
|
sesxml.Attribute("NumberOfViews", 1);
|
|
|
|
sesxml.Attribute("URL", "file://" + fileToOpen);
|
|
|
|
|
|
|
|
sesxml.StartElement("View0");
|
|
|
|
sesxml.Attribute("line", 0);
|
|
|
|
sesxml.Attribute("Type", "Source");
|
|
|
|
sesxml.EndElement(); // View0
|
|
|
|
|
|
|
|
sesxml.EndElement(); // Doc0
|
|
|
|
sesxml.EndElement(); // DocsAndViews
|
|
|
|
sesxml.EndElement(); // KDevPrjSession;
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|