2007-08-01 13:18:50 +00:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
Copyright (c) 2004 Alexander Neundorf neundorf@kde.org, All rights reserved.
|
|
|
|
Copyright (c) 2007 Miguel A. Figueroa-Villanueva. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#include "cmExtraEclipseCDT4Generator.h"
|
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
|
|
|
|
#include "cmSystemTools.h"
|
2007-08-17 14:05:39 +00:00
|
|
|
#include <stdlib.h>
|
2008-02-19 21:27:03 +00:00
|
|
|
#include <assert.h>
|
2007-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExtraEclipseCDT4Generator
|
|
|
|
::cmExtraEclipseCDT4Generator() : cmExternalMakefileProjectGenerator()
|
|
|
|
{
|
2007-08-17 14:05:39 +00:00
|
|
|
// TODO: Verify if __CYGWIN__ should be checked.
|
|
|
|
//#if defined(_WIN32) && !defined(__CYGWIN__)
|
2007-08-01 15:50:26 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
this->SupportedGlobalGenerators.push_back("NMake Makefiles");
|
2007-08-17 14:05:39 +00:00
|
|
|
this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
|
2007-08-01 13:18:50 +00:00
|
|
|
// this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
|
2007-08-01 15:50:26 +00:00
|
|
|
#endif
|
2007-08-01 13:18:50 +00:00
|
|
|
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
|
|
|
|
{
|
2007-10-22 16:49:09 +00:00
|
|
|
entry.Name = this->GetName();
|
|
|
|
entry.Brief = "Generates Eclipse CDT 4.0 project files.";
|
|
|
|
entry.Full =
|
2007-08-01 13:18:50 +00:00
|
|
|
"Project files for Eclipse will be created in the top directory "
|
|
|
|
"and will have a linked resource to every subdirectory which "
|
|
|
|
"features a CMakeLists.txt file containing a PROJECT() call."
|
|
|
|
"Additionally a hierarchy of makefiles is generated into the "
|
|
|
|
"build tree. The appropriate make program can build the project through "
|
|
|
|
"the default make target. A \"make install\" target is also provided.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::SetGlobalGenerator(cmGlobalGenerator* generator)
|
|
|
|
{
|
|
|
|
cmExternalMakefileProjectGenerator::SetGlobalGenerator(generator);
|
|
|
|
cmGlobalUnixMakefileGenerator3* mf
|
|
|
|
= static_cast<cmGlobalUnixMakefileGenerator3*>(generator);
|
2008-02-15 01:18:49 +00:00
|
|
|
mf->SetToolSupportsColor(true);
|
2007-08-01 13:18:50 +00:00
|
|
|
mf->SetForceVerboseMakefiles(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::Generate()
|
|
|
|
{
|
2008-02-19 20:07:28 +00:00
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
|
|
|
|
|
// TODO: Decide if these are local or member variables
|
|
|
|
this->HomeDirectory = mf->GetHomeDirectory();
|
|
|
|
this->HomeOutputDirectory = mf->GetHomeOutputDirectory();
|
|
|
|
|
2008-02-19 21:27:03 +00:00
|
|
|
this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory);
|
|
|
|
|
|
|
|
this->GenerateSourceProject = (this->IsOutOfSourceBuild &&
|
|
|
|
mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"));
|
|
|
|
|
|
|
|
// NOTE: This is not good, since it pollutes the source tree. However,
|
|
|
|
// Eclipse doesn't allow CVS/SVN to work when the .project is not in
|
|
|
|
// the cvs/svn root directory. Hence, this is provided as an option.
|
|
|
|
if (this->GenerateSourceProject)
|
|
|
|
{
|
|
|
|
// create .project file in the source tree
|
|
|
|
this->CreateSourceProjectFile();
|
|
|
|
}
|
|
|
|
|
2007-08-01 13:18:50 +00:00
|
|
|
// create a .project file
|
|
|
|
this->CreateProjectFile();
|
|
|
|
|
|
|
|
// create a .cproject file
|
|
|
|
this->CreateCProjectFile();
|
|
|
|
}
|
|
|
|
|
2008-02-19 21:27:03 +00:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
2008-02-19 21:27:03 +00:00
|
|
|
assert(this->HomeDirectory != this->HomeOutputDirectory);
|
|
|
|
|
2008-02-19 20:07:28 +00:00
|
|
|
// set up the project name: <project>-Source@<baseSourcePathName>
|
2008-02-19 21:27:03 +00:00
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
2008-02-19 20:07:28 +00:00
|
|
|
std::string name = this->GenerateProjectName(mf->GetProjectName(), "Source",
|
|
|
|
this->GetPathBasename(this->HomeDirectory));
|
2007-08-01 13:18:50 +00:00
|
|
|
|
2008-02-19 21:27:03 +00:00
|
|
|
const std::string filename = this->HomeDirectory + "/.project";
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fout <<
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
|
|
"<projectDescription>\n"
|
|
|
|
"\t<name>" << name << "</name>\n"
|
|
|
|
"\t<comment></comment>\n"
|
|
|
|
"\t<projects>\n"
|
|
|
|
"\t</projects>\n"
|
|
|
|
"\t<buildSpec>\n"
|
|
|
|
"\t</buildSpec>\n"
|
|
|
|
"\t<natures>\n"
|
|
|
|
"\t</natures>\n"
|
|
|
|
"</projectDescription>\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::CreateProjectFile()
|
|
|
|
{
|
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
|
|
2008-02-19 20:07:28 +00:00
|
|
|
const std::string filename = this->HomeOutputDirectory + "/.project";
|
2007-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fout <<
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
|
|
"<projectDescription>\n"
|
2008-02-19 20:07:28 +00:00
|
|
|
"\t<name>" <<
|
|
|
|
this->GenerateProjectName(mf->GetProjectName(),
|
|
|
|
mf->GetDefinition("CMAKE_BUILD_TYPE"),
|
|
|
|
this->GetPathBasename(this->HomeOutputDirectory))
|
|
|
|
<< "</name>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t<comment></comment>\n"
|
|
|
|
"\t<projects>\n"
|
|
|
|
"\t</projects>\n"
|
|
|
|
"\t<buildSpec>\n"
|
|
|
|
"\t\t<buildCommand>\n"
|
|
|
|
"\t\t\t<name>org.eclipse.cdt.make.core.makeBuilder</name>\n"
|
|
|
|
"\t\t\t<triggers>clean,full,incremental,</triggers>\n"
|
|
|
|
"\t\t\t<arguments>\n"
|
|
|
|
;
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
// use clean target
|
2007-08-01 13:18:50 +00:00
|
|
|
fout <<
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>\n"
|
|
|
|
"\t\t\t\t\t<value>clean</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableCleanBuild</key>\n"
|
|
|
|
"\t\t\t\t\t<value>true</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.append_environment</key>\n"
|
|
|
|
"\t\t\t\t\t<value>true</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.stopOnError</key>\n"
|
|
|
|
"\t\t\t\t\t<value>true</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
;
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
// set the make command
|
2007-08-01 13:18:50 +00:00
|
|
|
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
fout <<
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>\n"
|
|
|
|
"\t\t\t\t\t<value>true</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.command</key>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
"\t\t\t\t\t<value>" + this->GetEclipsePath(make) + "</value>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.contents</key>\n"
|
|
|
|
"\t\t\t\t\t<value>org.eclipse.cdt.make.core.activeConfigSettings</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.inc</key>\n"
|
|
|
|
"\t\t\t\t\t<value>all</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.arguments</key>\n"
|
|
|
|
"\t\t\t\t\t<value></value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildLocation</key>\n"
|
|
|
|
"\t\t\t\t\t<value>"
|
2008-02-19 20:07:28 +00:00
|
|
|
<< this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>\n"
|
|
|
|
"\t\t\t\t\t<value>false</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// set project specific environment
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.environment</key>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
"\t\t\t\t\t<value>"
|
|
|
|
;
|
|
|
|
// set vsvars32.bat environment available at CMake time,
|
|
|
|
// but not necessarily when eclipse is open
|
|
|
|
if (make.find("nmake") != std::string::npos)
|
|
|
|
{
|
|
|
|
if (getenv("PATH"))
|
|
|
|
{
|
|
|
|
fout << "PATH=" << getenv("PATH") << "|";
|
|
|
|
}
|
|
|
|
if (getenv("INCLUDE"))
|
|
|
|
{
|
|
|
|
fout << "INCLUDE=" << getenv("INCLUDE") << "|";
|
|
|
|
}
|
|
|
|
if (getenv("LIB"))
|
|
|
|
{
|
|
|
|
fout << "LIB=" << getenv("LIB") << "|";
|
|
|
|
}
|
|
|
|
if (getenv("LIBPATH"))
|
|
|
|
{
|
|
|
|
fout << "LIBPATH=" << getenv("LIBPATH") << "|";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fout <<
|
|
|
|
"</value>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t</dictionary>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableFullBuild</key>\n"
|
|
|
|
"\t\t\t\t\t<value>true</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.auto</key>\n"
|
|
|
|
"\t\t\t\t\t<value>all</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableAutoBuild</key>\n"
|
|
|
|
"\t\t\t\t\t<value>false</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.clean</key>\n"
|
|
|
|
"\t\t\t\t\t<value>clean</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.fullBuildTarget</key>\n"
|
|
|
|
"\t\t\t\t\t<value>all</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildArguments</key>\n"
|
|
|
|
"\t\t\t\t\t<value></value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.location</key>\n"
|
|
|
|
"\t\t\t\t\t<value>"
|
2008-02-19 20:07:28 +00:00
|
|
|
<< this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t</dictionary>\n"
|
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.autoBuildTarget</key>\n"
|
|
|
|
"\t\t\t\t\t<value>all</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// set error parsers
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n"
|
|
|
|
"\t\t\t\t\t<value>"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
if (this->GetToolChainType(*mf) == EclipseToolchainOther)
|
|
|
|
{
|
|
|
|
fout << "org.eclipse.cdt.core.VCErrorParser;";
|
|
|
|
}
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"org.eclipse.cdt.core.MakeErrorParser;"
|
|
|
|
"org.eclipse.cdt.core.GCCErrorParser;"
|
|
|
|
"org.eclipse.cdt.core.GASErrorParser;"
|
|
|
|
"org.eclipse.cdt.core.GLDErrorParser;"
|
|
|
|
"</value>\n"
|
|
|
|
"\t\t\t\t</dictionary>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t\t</arguments>\n"
|
|
|
|
"\t\t</buildCommand>\n"
|
|
|
|
"\t\t<buildCommand>\n"
|
|
|
|
"\t\t\t<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>\n"
|
|
|
|
"\t\t\t<arguments>\n"
|
|
|
|
"\t\t\t</arguments>\n"
|
|
|
|
"\t\t</buildCommand>\n"
|
|
|
|
"\t</buildSpec>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// set natures for c/c++ projects
|
|
|
|
fout <<
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t<natures>\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
// TODO: ccnature only if it is c++ ???
|
2007-08-01 13:18:50 +00:00
|
|
|
"\t\t<nature>org.eclipse.cdt.core.ccnature</nature>\n"
|
|
|
|
"\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n"
|
|
|
|
"\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n"
|
|
|
|
"\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n"
|
|
|
|
"\t</natures>\n"
|
|
|
|
;
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
// TODO: refactor this
|
|
|
|
// create linked resources
|
2008-02-19 21:27:03 +00:00
|
|
|
if (this->IsOutOfSourceBuild)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
2007-08-17 14:05:39 +00:00
|
|
|
fout << "\t<linkedResources>\n";
|
|
|
|
// for each sub project create a linked resource to the source dir
|
|
|
|
// - only if it is an out-of-source build
|
|
|
|
for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it != this->GlobalGenerator->GetProjectMap().end();
|
|
|
|
++it)
|
|
|
|
{
|
2008-02-19 21:34:49 +00:00
|
|
|
std::string linkSourceDirectory = this->GetEclipsePath(
|
2008-02-07 23:24:55 +00:00
|
|
|
it->second[0]->GetMakefile()->GetStartDirectory());
|
2008-02-19 21:27:03 +00:00
|
|
|
// .project dir can't be subdir of a linked resource dir
|
2008-02-19 20:07:28 +00:00
|
|
|
if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
|
2008-02-07 23:24:55 +00:00
|
|
|
linkSourceDirectory.c_str()))
|
|
|
|
{
|
2008-02-19 21:27:03 +00:00
|
|
|
this->AppendLinkedResource(fout, it->first,
|
|
|
|
this->GetEclipsePath(linkSourceDirectory));
|
|
|
|
this->SrcLinkedResources.push_back(it->first);
|
2008-02-07 23:24:55 +00:00
|
|
|
}
|
2007-08-17 14:05:39 +00:00
|
|
|
}
|
|
|
|
// for EXECUTABLE_OUTPUT_PATH when not in binary dir
|
2008-08-06 19:35:52 +00:00
|
|
|
std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
|
2008-02-19 21:34:49 +00:00
|
|
|
if (!outputPath.empty() && !cmSystemTools::IsSubDirectory(
|
|
|
|
outputPath.c_str(), this->HomeOutputDirectory.c_str()))
|
2007-08-17 14:05:39 +00:00
|
|
|
{
|
2008-02-19 21:34:49 +00:00
|
|
|
std::string name = this->GetPathBasename(outputPath);
|
2008-02-19 21:27:03 +00:00
|
|
|
|
|
|
|
// make sure linked resource name is unique
|
2007-08-17 14:05:39 +00:00
|
|
|
while (this->GlobalGenerator->GetProjectMap().find(name)
|
|
|
|
!= this->GlobalGenerator->GetProjectMap().end())
|
|
|
|
{
|
|
|
|
name += "_";
|
|
|
|
}
|
2008-02-19 21:27:03 +00:00
|
|
|
this->AppendLinkedResource(fout, name,
|
2008-02-19 21:34:49 +00:00
|
|
|
this->GetEclipsePath(outputPath));
|
2008-02-19 21:27:03 +00:00
|
|
|
this->OutLinkedResources.push_back(name);
|
2007-08-17 14:05:39 +00:00
|
|
|
}
|
|
|
|
// for LIBRARY_OUTPUT_PATH when not in binary dir
|
2008-08-06 19:35:52 +00:00
|
|
|
if (outputPath != mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH"))
|
2007-08-17 14:05:39 +00:00
|
|
|
{
|
2008-08-06 19:35:52 +00:00
|
|
|
outputPath = mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
|
2008-02-19 21:34:49 +00:00
|
|
|
if (!outputPath.empty() && !cmSystemTools::IsSubDirectory(
|
|
|
|
outputPath.c_str(), this->HomeOutputDirectory.c_str()))
|
2007-08-17 14:05:39 +00:00
|
|
|
{
|
2008-02-19 21:34:49 +00:00
|
|
|
std::string name = this->GetPathBasename(outputPath);
|
2008-02-19 21:27:03 +00:00
|
|
|
|
|
|
|
// make sure linked resource name is unique
|
2007-08-17 14:05:39 +00:00
|
|
|
while (this->GlobalGenerator->GetProjectMap().find(name)
|
|
|
|
!= this->GlobalGenerator->GetProjectMap().end())
|
|
|
|
{
|
|
|
|
name += "_";
|
|
|
|
}
|
2008-02-19 21:27:03 +00:00
|
|
|
this->AppendLinkedResource(fout, name,
|
2008-02-19 21:34:49 +00:00
|
|
|
this->GetEclipsePath(outputPath));
|
2008-02-19 21:27:03 +00:00
|
|
|
this->OutLinkedResources.push_back(name);
|
2007-08-17 14:05:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fout << "\t</linkedResources>\n";
|
2007-08-01 13:18:50 +00:00
|
|
|
}
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
fout << "</projectDescription>\n";
|
2007-08-01 13:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
|
|
|
|
{
|
|
|
|
std::set<std::string> emmited;
|
|
|
|
|
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
|
|
2008-02-19 20:07:28 +00:00
|
|
|
const std::string filename = this->HomeOutputDirectory + "/.cproject";
|
2007-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add header
|
|
|
|
fout <<
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
|
|
"<?fileVersion 4.0.0?>\n\n"
|
|
|
|
"<cproject>\n"
|
|
|
|
"<storageModule moduleId=\"org.eclipse.cdt.core.settings\">\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
fout << "<cconfiguration id=\"org.eclipse.cdt.core.default.config.1\">\n";
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
// Configuration settings...
|
2007-08-01 13:18:50 +00:00
|
|
|
fout <<
|
|
|
|
"<storageModule"
|
|
|
|
" buildSystemId=\"org.eclipse.cdt.core.defaultConfigDataProvider\""
|
|
|
|
" id=\"org.eclipse.cdt.core.default.config.1\""
|
|
|
|
" moduleId=\"org.eclipse.cdt.core.settings\" name=\"Configuration\">\n"
|
|
|
|
"<externalSettings/>\n"
|
|
|
|
"<extensions>\n"
|
|
|
|
;
|
2007-08-17 14:05:39 +00:00
|
|
|
// TODO: refactor this out...
|
|
|
|
switch (this->GetToolChainType(*mf))
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
case EclipseToolchainLinux :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
|
|
|
|
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
|
|
|
|
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
|
|
|
|
"</extension>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
case EclipseToolchainCygwin :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
|
|
|
|
"<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
|
|
|
|
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
|
|
|
|
"<attribute key=\"cygpath\" value=\"cygpath\"/>\n"
|
|
|
|
"<attribute key=\"nm\" value=\"nm\"/>\n"
|
|
|
|
"</extension>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
case EclipseToolchainMinGW :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.PE\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
case EclipseToolchainSolaris :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
case EclipseToolchainMacOSX :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.MachO\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\">\n"
|
|
|
|
"<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
|
|
|
|
"</extension>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
case EclipseToolchainOther :
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.PE\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
// *** Should never get here ***
|
|
|
|
fout << "<error_toolchain_type/>\n";
|
|
|
|
}
|
|
|
|
fout << "</extensions>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
// ???
|
|
|
|
fout <<
|
|
|
|
"<storageModule moduleId=\"org.eclipse.cdt.core.language.mapping\">\n"
|
|
|
|
"<project-mappings/>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
// ???
|
|
|
|
fout<<"<storageModule moduleId=\"org.eclipse.cdt.core.externalSettings\"/>\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
// set the path entries (includes, libs, source dirs, etc.)
|
|
|
|
fout << "<storageModule moduleId=\"org.eclipse.cdt.core.pathentry\">\n"
|
|
|
|
;
|
|
|
|
// for each sub project with a linked resource to the source dir:
|
|
|
|
// - make it type 'src'
|
|
|
|
// - and exclude it from type 'out'
|
2008-02-19 21:34:49 +00:00
|
|
|
std::string excludeFromOut;
|
2008-02-19 21:27:03 +00:00
|
|
|
for (std::vector<std::string>::const_iterator
|
|
|
|
it = this->SrcLinkedResources.begin();
|
|
|
|
it != this->SrcLinkedResources.end();
|
2007-08-01 13:18:50 +00:00
|
|
|
++it)
|
|
|
|
{
|
2008-02-19 21:27:03 +00:00
|
|
|
fout << "<pathentry kind=\"src\" path=\"" << *it << "\"/>\n";
|
2007-08-17 14:05:39 +00:00
|
|
|
|
|
|
|
// exlude source directory from output search path
|
|
|
|
// - only if not named the same as an output directory
|
|
|
|
if (!cmSystemTools::FileIsDirectory(
|
2008-02-19 21:27:03 +00:00
|
|
|
std::string(this->HomeOutputDirectory + "/" + *it).c_str()))
|
2007-08-17 14:05:39 +00:00
|
|
|
{
|
2008-02-19 21:34:49 +00:00
|
|
|
excludeFromOut += *it + "/|";
|
2007-08-17 14:05:39 +00:00
|
|
|
}
|
2007-08-01 13:18:50 +00:00
|
|
|
}
|
2008-02-19 21:34:49 +00:00
|
|
|
excludeFromOut += "**/CMakeFiles/";
|
|
|
|
fout << "<pathentry excluding=\"" << excludeFromOut
|
2007-08-17 14:05:39 +00:00
|
|
|
<< "\" kind=\"out\" path=\"\"/>\n";
|
|
|
|
// add output entry for EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH
|
|
|
|
// - if it is a subdir of homeOutputDirectory, there is no need to add it
|
|
|
|
// - if it is not then create a linked resource and add the linked name
|
|
|
|
// but check it doesn't conflict with other linked resources names
|
2008-02-19 21:27:03 +00:00
|
|
|
for (std::vector<std::string>::const_iterator
|
|
|
|
it = this->OutLinkedResources.begin();
|
|
|
|
it != this->OutLinkedResources.end();
|
|
|
|
++it)
|
2007-08-17 14:05:39 +00:00
|
|
|
{
|
2008-02-19 21:27:03 +00:00
|
|
|
fout << "<pathentry kind=\"out\" path=\"" << *it << "\"/>\n";
|
2007-08-17 14:05:39 +00:00
|
|
|
}
|
|
|
|
|
2008-02-07 21:26:00 +00:00
|
|
|
// add pre-processor definitions to allow eclipse to gray out sections
|
|
|
|
emmited.clear();
|
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(const char* cdefs = (*it)->GetMakefile()->GetProperty(
|
|
|
|
"COMPILE_DEFINITIONS"))
|
|
|
|
{
|
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cdefs, defs);
|
|
|
|
|
|
|
|
for(std::vector<std::string>::const_iterator di = defs.begin();
|
|
|
|
di != defs.end(); ++di)
|
|
|
|
{
|
|
|
|
std::string::size_type equals = di->find('=', 0);
|
|
|
|
std::string::size_type enddef = di->length();
|
2008-02-19 21:27:03 +00:00
|
|
|
|
2008-02-07 21:26:00 +00:00
|
|
|
std::string def;
|
|
|
|
std::string val;
|
|
|
|
if (equals != std::string::npos && equals < enddef)
|
|
|
|
{
|
|
|
|
// we have -DFOO=BAR
|
|
|
|
def = di->substr(0, equals);
|
|
|
|
val = di->substr(equals + 1, enddef - equals + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// we have -DFOO
|
|
|
|
def = *di;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert the definition if not already added.
|
|
|
|
if(emmited.find(def) == emmited.end())
|
|
|
|
{
|
|
|
|
emmited.insert(def);
|
|
|
|
fout << "<pathentry kind=\"mac\" name=\"" << def
|
2009-01-08 23:09:50 +00:00
|
|
|
<< "\" path=\"\" value=\"" << this->EscapeForXML(val)
|
|
|
|
<< "\"/>\n";
|
2008-02-07 21:26:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 13:18:50 +00:00
|
|
|
// include dirs
|
|
|
|
emmited.clear();
|
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
const std::vector<std::string>& includeDirs
|
|
|
|
= (*it)->GetMakefile()->GetIncludeDirectories();
|
|
|
|
for(std::vector<std::string>::const_iterator inc = includeDirs.begin();
|
|
|
|
inc != includeDirs.end();
|
|
|
|
++inc)
|
|
|
|
{
|
2007-08-17 14:05:39 +00:00
|
|
|
std::string dir = cmSystemTools::CollapseFullPath(inc->c_str());
|
|
|
|
if(emmited.find(dir) == emmited.end())
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
2007-08-17 14:05:39 +00:00
|
|
|
emmited.insert(dir);
|
|
|
|
fout << "<pathentry include=\"" << this->GetEclipsePath(dir)
|
2007-08-01 13:18:50 +00:00
|
|
|
<< "\" kind=\"inc\" path=\"\" system=\"true\"/>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-17 14:05:39 +00:00
|
|
|
fout << "</storageModule>\n";
|
2007-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
// add build targets
|
|
|
|
fout <<
|
|
|
|
"<storageModule moduleId=\"org.eclipse.cdt.make.core.buildtargets\">\n"
|
|
|
|
"<buildTargets>\n"
|
|
|
|
;
|
|
|
|
emmited.clear();
|
2007-08-17 14:05:39 +00:00
|
|
|
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
cmGlobalGenerator* generator
|
|
|
|
= const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
|
|
|
|
if (generator->GetAllTargetName())
|
|
|
|
{
|
|
|
|
emmited.insert(generator->GetAllTargetName());
|
|
|
|
cmExtraEclipseCDT4Generator::AppendTarget(fout,
|
|
|
|
generator->GetAllTargetName(),
|
|
|
|
make);
|
|
|
|
}
|
|
|
|
if (generator->GetPreinstallTargetName())
|
|
|
|
{
|
|
|
|
emmited.insert(generator->GetPreinstallTargetName());
|
|
|
|
cmExtraEclipseCDT4Generator
|
|
|
|
::AppendTarget(fout, generator->GetPreinstallTargetName(), make);
|
|
|
|
}
|
2007-11-25 12:40:57 +00:00
|
|
|
|
|
|
|
if (generator->GetCleanTargetName())
|
|
|
|
{
|
|
|
|
emmited.insert(generator->GetCleanTargetName());
|
|
|
|
cmExtraEclipseCDT4Generator
|
|
|
|
::AppendTarget(fout, generator->GetCleanTargetName(), make);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add all executable and library targets and some of the GLOBAL
|
|
|
|
// and UTILITY targets
|
2007-08-01 13:18:50 +00:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
const cmTargets& targets = (*it)->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t)
|
|
|
|
{
|
2007-11-25 12:40:57 +00:00
|
|
|
switch(t->second.GetType())
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
2007-11-25 12:40:57 +00:00
|
|
|
case cmTarget::UTILITY:
|
|
|
|
case cmTarget::GLOBAL_TARGET:
|
|
|
|
{
|
2008-02-07 21:26:00 +00:00
|
|
|
// only add these global targets
|
|
|
|
if (!( (t->first=="install")
|
|
|
|
|| (t->first=="install/strip")
|
|
|
|
|| (t->first=="test")
|
|
|
|
|| (t->first=="Experimental")
|
|
|
|
|| (t->first=="Nightly")
|
2008-04-03 22:43:43 +00:00
|
|
|
|| (t->first=="edit_cache")
|
2008-02-07 21:26:00 +00:00
|
|
|
|| (t->first=="package")
|
|
|
|
|| (t->first=="package_source")
|
|
|
|
|| (t->first=="rebuild_cache") ))
|
2007-11-25 12:40:57 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2008-04-03 22:43:43 +00:00
|
|
|
// add the edit_cache target only if it's not ccmake
|
|
|
|
// otherwise ccmake will be executed in the log view of Eclipse,
|
|
|
|
// which is no terminal, so curses don't work there, Alex
|
|
|
|
if (t->first=="edit_cache")
|
|
|
|
{
|
|
|
|
if (strstr(mf->GetRequiredDefinition("CMAKE_EDIT_COMMAND"),
|
|
|
|
"ccmake")!=NULL)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-11-25 12:40:57 +00:00
|
|
|
}
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
{
|
|
|
|
if(emmited.find(t->first) == emmited.end())
|
|
|
|
{
|
|
|
|
emmited.insert(t->first);
|
|
|
|
cmExtraEclipseCDT4Generator::AppendTarget(fout, t->first, make);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ignore these:
|
|
|
|
case cmTarget::INSTALL_FILES:
|
|
|
|
case cmTarget::INSTALL_PROGRAMS:
|
|
|
|
case cmTarget::INSTALL_DIRECTORY:
|
|
|
|
default:
|
|
|
|
break;
|
2007-08-01 13:18:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fout << "</buildTargets>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
;
|
|
|
|
|
2009-01-09 23:58:21 +00:00
|
|
|
this->AppendStorageScanners(fout, *mf);
|
2007-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
fout << "</cconfiguration>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
"<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n"
|
|
|
|
"<project id=\"" << mf->GetProjectName() << ".null.1\""
|
|
|
|
" name=\"" << mf->GetProjectName() << "\"/>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
"</cproject>\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExtraEclipseCDT4Generator::EclipseToolchainType
|
2007-08-17 14:05:39 +00:00
|
|
|
cmExtraEclipseCDT4Generator::GetToolChainType(const cmMakefile& makefile)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
if (makefile.IsSet("UNIX"))
|
|
|
|
{
|
|
|
|
if (makefile.IsSet("CYGWIN"))
|
|
|
|
{
|
|
|
|
return EclipseToolchainCygwin;
|
|
|
|
}
|
|
|
|
if (makefile.IsSet("APPLE" ))
|
|
|
|
{
|
|
|
|
return EclipseToolchainMacOSX;
|
|
|
|
}
|
|
|
|
// *** how do I determine if it is Solaris ???
|
|
|
|
return EclipseToolchainLinux;
|
|
|
|
}
|
|
|
|
else if (makefile.IsSet("WIN32"))
|
|
|
|
{
|
|
|
|
if (makefile.IsSet("MINGW"))
|
|
|
|
{
|
|
|
|
return EclipseToolchainMinGW;
|
|
|
|
}
|
|
|
|
if (makefile.IsSet("MSYS" ))
|
|
|
|
{
|
|
|
|
return EclipseToolchainMinGW;
|
|
|
|
}
|
|
|
|
return EclipseToolchainOther;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return EclipseToolchainOther;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
2007-08-17 14:05:39 +00:00
|
|
|
cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
#if defined(__CYGWIN__)
|
2007-08-17 14:05:39 +00:00
|
|
|
std::string cmd = "cygpath -m " + path;
|
2007-08-01 13:18:50 +00:00
|
|
|
std::string out;
|
|
|
|
if (!cmSystemTools::RunCommand(cmd.c_str(), out, 0, false))
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.erase(out.find_last_of('\n'));
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
return path;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
std::string
|
|
|
|
cmExtraEclipseCDT4Generator::GetPathBasename(const std::string& path)
|
|
|
|
{
|
|
|
|
std::string outputBasename = path;
|
|
|
|
while (outputBasename.size() > 0 &&
|
|
|
|
(outputBasename[outputBasename.size() - 1] == '/' ||
|
|
|
|
outputBasename[outputBasename.size() - 1] == '\\'))
|
|
|
|
{
|
|
|
|
outputBasename.resize(outputBasename.size() - 1);
|
|
|
|
}
|
|
|
|
std::string::size_type loc = outputBasename.find_last_of("/\\");
|
|
|
|
if (loc != std::string::npos)
|
|
|
|
{
|
|
|
|
outputBasename = outputBasename.substr(loc + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return outputBasename;
|
|
|
|
}
|
|
|
|
|
2008-02-19 20:07:28 +00:00
|
|
|
std::string
|
|
|
|
cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name,
|
|
|
|
const std::string& type,
|
|
|
|
const std::string& path)
|
|
|
|
{
|
|
|
|
return name + (type.empty() ? "" : "-") + type + "@" + path;
|
|
|
|
}
|
|
|
|
|
2009-01-08 23:09:50 +00:00
|
|
|
std::string cmExtraEclipseCDT4Generator::EscapeForXML(const std::string& value)
|
|
|
|
{
|
|
|
|
std::string str = value;
|
|
|
|
cmSystemTools::ReplaceString(str, "&", "&");
|
|
|
|
cmSystemTools::ReplaceString(str, "<", "<");
|
|
|
|
cmSystemTools::ReplaceString(str, ">", ">");
|
|
|
|
cmSystemTools::ReplaceString(str, "\"", """);
|
|
|
|
// NOTE: This one is not necessary, since as of Eclipse CDT4 it will
|
|
|
|
// automatically change this to the original value (').
|
|
|
|
//cmSystemTools::ReplaceString(str, "'", "'");
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2007-08-01 13:18:50 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Helper functions
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator
|
2009-01-09 23:58:21 +00:00
|
|
|
::AppendStorageScanners(cmGeneratedFileStream& fout,
|
|
|
|
const cmMakefile& makefile)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
2009-01-09 23:58:21 +00:00
|
|
|
// we need the "make" and the C (or C++) compiler which are used, Alex
|
|
|
|
std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER");
|
|
|
|
if (compiler.empty())
|
|
|
|
{
|
|
|
|
compiler = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER");
|
|
|
|
}
|
|
|
|
if (compiler.empty()) //Hmm, what to do now ?
|
|
|
|
{
|
|
|
|
compiler = "gcc";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// the following right now hardcodes gcc behaviour :-/
|
2007-08-01 13:18:50 +00:00
|
|
|
fout <<
|
|
|
|
"<storageModule moduleId=\"scannerConfiguration\">\n"
|
|
|
|
"<autodiscovery enabled=\"true\" problemReportingEnabled=\"true\""
|
2007-08-17 14:05:39 +00:00
|
|
|
" selectedProfileId="
|
|
|
|
"\"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile\"/>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
;
|
2007-08-17 14:05:39 +00:00
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
|
2007-08-01 13:18:50 +00:00
|
|
|
"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile",
|
|
|
|
true, "", true, "specsFile",
|
|
|
|
"-E -P -v -dD ${plugin_state_location}/${specs_file}",
|
2009-01-09 23:58:21 +00:00
|
|
|
compiler, true, true);
|
2007-08-17 14:05:39 +00:00
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
|
2007-08-01 13:18:50 +00:00
|
|
|
"org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile",
|
|
|
|
true, "", true, "makefileGenerator",
|
|
|
|
"-f ${project_name}_scd.mk",
|
2009-01-09 23:58:21 +00:00
|
|
|
make, true, true);
|
2007-08-01 13:18:50 +00:00
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
fout << "</storageModule>\n";
|
2007-08-01 13:18:50 +00:00
|
|
|
}
|
|
|
|
|
2007-08-17 14:05:39 +00:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
|
|
|
|
const std::string& target,
|
|
|
|
const std::string& make)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
fout <<
|
|
|
|
"<target name=\"" << target << "\""
|
|
|
|
" path=\"\""
|
|
|
|
" targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
|
2007-08-17 14:05:39 +00:00
|
|
|
"<buildCommand>"
|
|
|
|
<< cmExtraEclipseCDT4Generator::GetEclipsePath(make)
|
|
|
|
<< "</buildCommand>\n"
|
2007-08-01 13:18:50 +00:00
|
|
|
"<buildArguments/>\n"
|
|
|
|
"<buildTarget>" << target << "</buildTarget>\n"
|
|
|
|
"<stopOnError>true</stopOnError>\n"
|
|
|
|
"<useDefaultCommand>false</useDefaultCommand>\n"
|
|
|
|
"</target>\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::AppendScannerProfile(cmGeneratedFileStream& fout,
|
|
|
|
const std::string& profileID,
|
|
|
|
bool openActionEnabled,
|
|
|
|
const std::string& openActionFilePath,
|
|
|
|
bool pParserEnabled,
|
|
|
|
const std::string& scannerInfoProviderID,
|
|
|
|
const std::string& runActionArguments,
|
|
|
|
const std::string& runActionCommand,
|
|
|
|
bool runActionUseDefault,
|
2007-08-17 14:05:39 +00:00
|
|
|
bool sipParserEnabled)
|
2007-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
fout <<
|
|
|
|
"<profile id=\"" << profileID << "\">\n"
|
|
|
|
"<buildOutputProvider>\n"
|
|
|
|
"<openAction enabled=\"" << (openActionEnabled ? "true" : "false")
|
|
|
|
<< "\" filePath=\"" << openActionFilePath << "\"/>\n"
|
|
|
|
"<parser enabled=\"" << (pParserEnabled ? "true" : "false") << "\"/>\n"
|
|
|
|
"</buildOutputProvider>\n"
|
|
|
|
"<scannerInfoProvider id=\"" << scannerInfoProviderID << "\">\n"
|
|
|
|
"<runAction arguments=\"" << runActionArguments << "\""
|
|
|
|
" command=\"" << runActionCommand
|
|
|
|
<< "\" useDefault=\"" << (runActionUseDefault ? "true":"false") << "\"/>\n"
|
|
|
|
"<parser enabled=\"" << (sipParserEnabled ? "true" : "false") << "\"/>\n"
|
|
|
|
"</scannerInfoProvider>\n"
|
|
|
|
"</profile>\n"
|
|
|
|
;
|
|
|
|
}
|
2008-02-19 21:27:03 +00:00
|
|
|
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::AppendLinkedResource (cmGeneratedFileStream& fout,
|
|
|
|
const std::string& name,
|
|
|
|
const std::string& path)
|
|
|
|
{
|
|
|
|
fout <<
|
|
|
|
"\t\t<link>\n"
|
|
|
|
"\t\t\t<name>" << name << "</name>\n"
|
|
|
|
"\t\t\t<type>2</type>\n"
|
|
|
|
"\t\t\t<location>"
|
|
|
|
<< path
|
|
|
|
<< "</location>\n"
|
|
|
|
"\t\t</link>\n"
|
|
|
|
;
|
|
|
|
}
|