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"
|
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
|
|
|
{
|
|
|
|
cmMakefile* mf = it->second[0]->GetMakefile();
|
2015-04-16 21:06:54 +03:00
|
|
|
std::string outputDir=mf->GetCurrentBinaryDirectory();
|
2005-02-10 07:22:06 +03:00
|
|
|
std::string projectDir=mf->GetHomeDirectory();
|
|
|
|
std::string projectName=mf->GetProjectName();
|
|
|
|
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
|
|
|
{
|
2006-04-24 17:39:50 +04:00
|
|
|
cmMakefile* makefile=(*lg)->GetMakefile();
|
2015-07-25 22:28:36 +03:00
|
|
|
cmGeneratorTargetsType const& targets = makefile->GetGeneratorTargets();
|
|
|
|
for (cmGeneratorTargetsType::const_iterator ti = targets.begin();
|
2006-04-24 17:39:50 +04:00
|
|
|
ti != targets.end(); ti++)
|
|
|
|
{
|
2015-07-25 22:28:36 +03:00
|
|
|
if (ti->second->GetType()==cmTarget::EXECUTABLE)
|
2006-04-24 17:39:50 +04:00
|
|
|
{
|
2013-10-28 22:47:46 +04:00
|
|
|
executable = ti->second->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;
|
|
|
|
|
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
|
|
|
|
cmTargets& targets=makefile->GetTargets();
|
2005-06-22 17:06:46 +04:00
|
|
|
for (cmTargets::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;
|
2014-02-13 20:25:00 +04:00
|
|
|
ti->second.GetSourceFiles(sources, ti->second.GetMakefile()
|
|
|
|
->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
|
|
|
|
ext = makefile->GetHeaderExtensions().begin();
|
|
|
|
ext != makefile->GetHeaderExtensions().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;
|
|
|
|
}
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <projectdirectory>" << projectDir <<
|
2007-08-31 21:42:21 +04:00
|
|
|
"</projectdirectory>\n"; //this one is important
|
2006-05-11 18:40:28 +04:00
|
|
|
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
|
2007-08-31 21:42:21 +04:00
|
|
|
|
|
|
|
// setup additional languages
|
2005-02-10 07:22:06 +03:00
|
|
|
fout<<" <secondaryLanguages>\n";
|
2007-08-31 21:42:21 +04:00
|
|
|
if (enableFortran && enableCxx)
|
|
|
|
{
|
|
|
|
fout<<" <language>Fortran</language>\n";
|
|
|
|
}
|
|
|
|
if (enableCxx)
|
|
|
|
{
|
|
|
|
fout<<" <language>C</language>\n";
|
|
|
|
}
|
2005-02-10 07:22:06 +03:00
|
|
|
fout<<" </secondaryLanguages>\n";
|
2007-06-11 03:51:26 +04:00
|
|
|
|
|
|
|
if (hasSvn)
|
|
|
|
{
|
|
|
|
fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
|
|
|
|
}
|
|
|
|
else if (hasCvs)
|
|
|
|
{
|
|
|
|
fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
|
|
|
|
}
|
|
|
|
|
2007-08-31 21:42:21 +04:00
|
|
|
fout<<" </general>\n"
|
|
|
|
" <kdevcustomproject>\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <filelistdirectory>" << outputDir <<
|
2007-08-31 21:42:21 +04:00
|
|
|
"</filelistdirectory>\n"
|
|
|
|
" <run>\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <mainprogram>" << executable << "</mainprogram>\n"
|
2007-08-31 21:42:21 +04:00
|
|
|
" <directoryradio>custom</directoryradio>\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <customdirectory>"<<outputDir<<"</customdirectory>\n"
|
2007-08-31 21:42:21 +04:00
|
|
|
" <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
|
2014-03-11 16:35:32 +04:00
|
|
|
fout<<" <builddir>"<<outputDir<<"</builddir>\n"; //and this one
|
2007-08-31 21:42:21 +04:00
|
|
|
fout<<" </build>\n"
|
|
|
|
" <make>\n"
|
|
|
|
" <abortonerror>false</abortonerror>\n"
|
|
|
|
" <numberofjobs>1</numberofjobs>\n"
|
|
|
|
" <dontact>false</dontact>\n"
|
2008-03-28 00:40:43 +03:00
|
|
|
" <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
|
2013-11-13 20:33:17 +04:00
|
|
|
GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")
|
2008-08-17 00:58:20 +04:00
|
|
|
<< " </makebin>\n"
|
2007-08-31 21:42:21 +04:00
|
|
|
" <selectedenvironment>default</selectedenvironment>\n"
|
|
|
|
" <environments>\n"
|
2008-08-17 00:58:20 +04:00
|
|
|
" <default>\n"
|
|
|
|
" <envvar value=\"1\" name=\"VERBOSE\" />\n"
|
2009-12-23 21:51:46 +03:00
|
|
|
" <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
|
2008-08-17 00:58:20 +04:00
|
|
|
" </default>\n"
|
2007-08-31 21:42:21 +04:00
|
|
|
" </environments>\n"
|
|
|
|
" </make>\n";
|
2007-08-27 03:27:33 +04:00
|
|
|
|
|
|
|
fout<<" <blacklist>\n";
|
|
|
|
for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
|
|
|
|
dirIt != this->Blacklist.end();
|
|
|
|
++dirIt)
|
|
|
|
{
|
2014-03-11 16:35:32 +04:00
|
|
|
fout<<" <path>" << *dirIt << "</path>\n";
|
2007-08-27 03:27:33 +04:00
|
|
|
}
|
|
|
|
fout<<" </blacklist>\n";
|
|
|
|
|
2007-08-31 21:42:21 +04:00
|
|
|
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"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <group pattern=\"" << cmakeFilePattern <<
|
2007-08-31 21:42:21 +04:00
|
|
|
"\" 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";
|
|
|
|
|
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;
|
|
|
|
}
|
2007-08-31 21:42:21 +04:00
|
|
|
devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
|
|
|
|
"<!DOCTYPE KDevPrjSession>\n"
|
|
|
|
"<KDevPrjSession>\n"
|
|
|
|
" <DocsAndViews NumberOfDocuments=\"1\" >\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
" <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
|
2007-08-31 21:42:21 +04:00
|
|
|
"\" >\n"
|
|
|
|
" <View0 line=\"0\" Type=\"Source\" />\n"
|
|
|
|
" </Doc0>\n"
|
|
|
|
" </DocsAndViews>\n"
|
|
|
|
"</KDevPrjSession>\n";
|
2005-02-10 07:22:06 +03:00
|
|
|
}
|
|
|
|
|