ENH: Support not writing files to the source tree. Generate single project file for whole project, some other little cleanups
This commit is contained in:
parent
914932fa13
commit
800784175f
@ -23,12 +23,12 @@
|
|||||||
#include "cmMakeDepend.h"
|
#include "cmMakeDepend.h"
|
||||||
#include "cmCacheManager.h"
|
#include "cmCacheManager.h"
|
||||||
#include "cmGeneratedFileStream.h"
|
#include "cmGeneratedFileStream.h"
|
||||||
|
#include "cmake.h"
|
||||||
|
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
cmLocalKdevelopGenerator::cmLocalKdevelopGenerator()
|
cmLocalKdevelopGenerator::cmLocalKdevelopGenerator()
|
||||||
:cmLocalUnixMakefileGenerator()
|
:cmLocalUnixMakefileGenerator()
|
||||||
{
|
{
|
||||||
@ -45,6 +45,10 @@ cmLocalKdevelopGenerator::~cmLocalKdevelopGenerator()
|
|||||||
void cmLocalKdevelopGenerator::Generate(bool fromTheTop)
|
void cmLocalKdevelopGenerator::Generate(bool fromTheTop)
|
||||||
{
|
{
|
||||||
cmLocalUnixMakefileGenerator::Generate(fromTheTop);
|
cmLocalUnixMakefileGenerator::Generate(fromTheTop);
|
||||||
|
if ( m_GlobalGenerator->GetCMakeInstance()->GetLocal() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool containsTargets=false;
|
bool containsTargets=false;
|
||||||
std::string executable;
|
std::string executable;
|
||||||
@ -70,15 +74,13 @@ void cmLocalKdevelopGenerator::Generate(bool fromTheTop)
|
|||||||
|
|
||||||
if (containsTargets)
|
if (containsTargets)
|
||||||
{
|
{
|
||||||
std::string projectFileDir=m_Makefile->GetStartOutputDirectory();
|
std::string filelistDir=m_Makefile->GetHomeOutputDirectory();
|
||||||
std::string filelistDir=m_Makefile->GetDefinition("PROJECT_SOURCE_DIR");
|
|
||||||
//build the project name by taking the subdir
|
//build the project name by taking the subdir
|
||||||
std::string projectName=m_Makefile->GetProjectName();
|
std::vector<cmLocalGenerator *> lgs;
|
||||||
projectName+=m_Makefile->GetStartOutputDirectory();
|
m_GlobalGenerator->GetLocalGenerators(lgs);
|
||||||
cmSystemTools::ReplaceString(projectName, filelistDir.c_str(), "");
|
std::string projectName=lgs[0]->GetMakefile()->GetProjectName();
|
||||||
cmSystemTools::ReplaceString(projectName, "/", "_");
|
|
||||||
|
|
||||||
std::string cmakeFilePattern("*/CMakeLists.txt;*.cmake;");
|
std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
|
||||||
|
|
||||||
if (!this->CreateFilelistFile(filelistDir, projectName, cmakeFilePattern))
|
if (!this->CreateFilelistFile(filelistDir, projectName, cmakeFilePattern))
|
||||||
{
|
{
|
||||||
@ -304,7 +306,7 @@ bool cmLocalKdevelopGenerator::CreateFilelistFile(const std::string& _dir,
|
|||||||
if ((tmp!="CMakeLists.txt")
|
if ((tmp!="CMakeLists.txt")
|
||||||
&& (strstr(tmp.c_str(), ".cmake")==0))
|
&& (strstr(tmp.c_str(), ".cmake")==0))
|
||||||
{
|
{
|
||||||
cmakeFilePattern+="*/"+tmp+";";
|
cmakeFilePattern+=tmp+";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,27 +315,17 @@ bool cmLocalKdevelopGenerator::CreateFilelistFile(const std::string& _dir,
|
|||||||
cmTargets& targets=m_Makefile->GetTargets();
|
cmTargets& targets=m_Makefile->GetTargets();
|
||||||
for (cmTargets::const_iterator ti = targets.begin(); ti != targets.end(); ti++)
|
for (cmTargets::const_iterator ti = targets.begin(); ti != targets.end(); ti++)
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& sources=ti->second.GetSourceLists();
|
const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles();
|
||||||
for (std::vector<std::string>::const_iterator it=sources.begin(); it!=sources.end(); it++)
|
for (std::vector<cmSourceFile*>::const_iterator it=sources.begin();
|
||||||
|
it!=sources.end(); it++)
|
||||||
{
|
{
|
||||||
tmp=*it;
|
files.insert((*it)->GetFullPath());
|
||||||
|
}
|
||||||
if (tmp[0]!='/') //no absolute path
|
const std::vector<std::string>& listFiles=m_Makefile->GetListFiles();
|
||||||
{
|
for (std::vector<std::string>::const_iterator it=listFiles.begin();
|
||||||
tmp=std::string(m_Makefile->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"))+"/"+tmp;
|
it!=listFiles.end(); it++)
|
||||||
}
|
{
|
||||||
|
files.insert(it->c_str());
|
||||||
tmp=cmSystemTools::CollapseFullPath(tmp.c_str());
|
|
||||||
cmSystemTools::ReplaceString(tmp, filelistDir.c_str(), "");
|
|
||||||
if (tmp[0]=='/')
|
|
||||||
{
|
|
||||||
std::string errorMessage("In order to get working KDevelop project files, you have to call "
|
|
||||||
"PROJECT() in a directory which is a parent directory of all source files. The source file ");
|
|
||||||
errorMessage+=tmp+" is not located beneath your current project directory "+filelistDir+" .";
|
|
||||||
cmSystemTools::Error(errorMessage.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
files.insert(tmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +362,7 @@ bool cmLocalKdevelopGenerator::CreateFilelistFile(const std::string& _dir,
|
|||||||
|
|
||||||
for (std::set<cmStdString>::const_iterator it=files.begin(); it!=files.end(); it++)
|
for (std::set<cmStdString>::const_iterator it=files.begin(); it!=files.end(); it++)
|
||||||
{
|
{
|
||||||
fout<<*it<<"\n";
|
fout<< cmSystemTools::RelativePath(_dir.c_str(), it->c_str())<<"\n";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user