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)
|
|
|
|
Copyright 2007 Miguel A. Figueroa-Villanueva
|
2007-08-01 17:18:50 +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.
|
2007-08-01 17:18:50 +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.
|
|
|
|
============================================================================*/
|
2007-08-01 17:18:50 +04:00
|
|
|
#include "cmExtraEclipseCDT4Generator.h"
|
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
|
|
|
|
#include "cmSystemTools.h"
|
2007-08-17 18:05:39 +04:00
|
|
|
#include <stdlib.h>
|
2008-02-20 00:27:03 +03:00
|
|
|
#include <assert.h>
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExtraEclipseCDT4Generator
|
|
|
|
::cmExtraEclipseCDT4Generator() : cmExternalMakefileProjectGenerator()
|
|
|
|
{
|
2007-08-17 18:05:39 +04:00
|
|
|
// TODO: Verify if __CYGWIN__ should be checked.
|
|
|
|
//#if defined(_WIN32) && !defined(__CYGWIN__)
|
2007-08-01 19:50:26 +04:00
|
|
|
#if defined(_WIN32)
|
|
|
|
this->SupportedGlobalGenerators.push_back("NMake Makefiles");
|
2007-08-17 18:05:39 +04:00
|
|
|
this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
|
2007-08-01 17:18:50 +04:00
|
|
|
// this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
|
2007-08-01 19:50:26 +04:00
|
|
|
#endif
|
2007-08-01 17:18:50 +04:00
|
|
|
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
entry.Name = this->GetName();
|
|
|
|
entry.Brief = "Generates Eclipse CDT 4.0 project files.";
|
|
|
|
entry.Full =
|
2010-02-13 19:08:42 +03:00
|
|
|
"Project files for Eclipse will be created in the top directory. "
|
|
|
|
"In out of source builds, a linked resource to the top level source "
|
|
|
|
"directory will be created."
|
2007-08-01 17:18:50 +04:00
|
|
|
"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::Generate()
|
|
|
|
{
|
2008-02-19 23:07:28 +03: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-20 00:27:03 +03:00
|
|
|
this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory);
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
this->GenerateSourceProject = (this->IsOutOfSourceBuild &&
|
2008-02-20 00:27:03 +03:00
|
|
|
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 17:18:50 +04:00
|
|
|
// create a .project file
|
|
|
|
this->CreateProjectFile();
|
|
|
|
|
|
|
|
// create a .cproject file
|
|
|
|
this->CreateCProjectFile();
|
|
|
|
}
|
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2008-02-20 00:27:03 +03:00
|
|
|
assert(this->HomeDirectory != this->HomeOutputDirectory);
|
|
|
|
|
2008-02-19 23:07:28 +03:00
|
|
|
// set up the project name: <project>-Source@<baseSourcePathName>
|
2008-02-20 00:27:03 +03:00
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
2008-02-19 23:07:28 +03:00
|
|
|
std::string name = this->GenerateProjectName(mf->GetProjectName(), "Source",
|
|
|
|
this->GetPathBasename(this->HomeDirectory));
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
const std::string filename = this->HomeDirectory + "/.project";
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2008-02-20 00:27:03 +03:00
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
|
|
"<projectDescription>\n"
|
2011-02-13 03:15:11 +03:00
|
|
|
"\t<name>" << this->EscapeForXML(name) << "</name>\n"
|
2008-02-20 00:27:03 +03:00
|
|
|
"\t<comment></comment>\n"
|
|
|
|
"\t<projects>\n"
|
|
|
|
"\t</projects>\n"
|
|
|
|
"\t<buildSpec>\n"
|
|
|
|
"\t</buildSpec>\n"
|
|
|
|
"\t<natures>\n"
|
|
|
|
"\t</natures>\n"
|
|
|
|
"</projectDescription>\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-12-23 21:56:01 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
|
|
|
|
const char* envVar, cmMakefile* mf)
|
|
|
|
{
|
2010-11-12 00:02:07 +03:00
|
|
|
// get the variables from the environment and from the cache and then
|
2009-12-23 21:56:01 +03:00
|
|
|
// figure out which one to use:
|
|
|
|
|
|
|
|
const char* envVarValue = getenv(envVar);
|
|
|
|
|
|
|
|
std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
|
|
|
|
cacheEntryName += envVar;
|
|
|
|
const char* cacheValue = mf->GetCacheManager()->GetCacheValue(
|
|
|
|
cacheEntryName.c_str());
|
|
|
|
|
|
|
|
// now we have both, decide which one to use
|
|
|
|
std::string valueToUse;
|
|
|
|
if (envVarValue==0 && cacheValue==0)
|
|
|
|
{
|
|
|
|
// nothing known, do nothing
|
|
|
|
valueToUse = "";
|
|
|
|
}
|
|
|
|
else if (envVarValue!=0 && cacheValue==0)
|
|
|
|
{
|
2010-11-12 00:02:07 +03:00
|
|
|
// The variable is in the env, but not in the cache. Use it and put it
|
2009-12-23 21:56:01 +03:00
|
|
|
// in the cache
|
|
|
|
valueToUse = envVarValue;
|
|
|
|
mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
|
|
|
|
cacheEntryName.c_str(), cmCacheManager::STRING,
|
|
|
|
true);
|
|
|
|
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
|
|
|
|
}
|
|
|
|
else if (envVarValue==0 && cacheValue!=0)
|
|
|
|
{
|
|
|
|
// It is already in the cache, but not in the env, so use it from the cache
|
|
|
|
valueToUse = cacheValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// It is both in the cache and in the env.
|
|
|
|
// Use the version from the env. except if the value from the env is
|
|
|
|
// completely contained in the value from the cache (for the case that we
|
|
|
|
// now have a PATH without MSVC dirs in the env. but had the full PATH with
|
|
|
|
// all MSVC dirs during the cmake run which stored the var in the cache:
|
|
|
|
valueToUse = cacheValue;
|
|
|
|
if (valueToUse.find(envVarValue) == std::string::npos)
|
|
|
|
{
|
|
|
|
valueToUse = envVarValue;
|
|
|
|
mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
|
|
|
|
cacheEntryName.c_str(), cmCacheManager::STRING,
|
|
|
|
true);
|
|
|
|
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!valueToUse.empty())
|
|
|
|
{
|
|
|
|
fout << envVar << "=" << valueToUse << "|";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::CreateProjectFile()
|
|
|
|
{
|
2009-12-23 21:56:01 +03:00
|
|
|
cmMakefile* mf
|
2008-02-20 00:27:03 +03:00
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
|
|
2008-02-19 23:07:28 +03:00
|
|
|
const std::string filename = this->HomeOutputDirectory + "/.project";
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-23 21:56:01 +03:00
|
|
|
std::string compilerId = mf->GetSafeDefinition("CMAKE_C_COMPILER_ID");
|
|
|
|
if (compilerId.empty()) // no C compiler, try the C++ compiler:
|
|
|
|
{
|
|
|
|
compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
|
|
|
|
}
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
|
|
"<projectDescription>\n"
|
2008-02-19 23:07:28 +03:00
|
|
|
"\t<name>" <<
|
|
|
|
this->GenerateProjectName(mf->GetProjectName(),
|
2010-12-21 23:59:39 +03:00
|
|
|
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
|
2008-02-19 23:07:28 +03:00
|
|
|
this->GetPathBasename(this->HomeOutputDirectory))
|
|
|
|
<< "</name>\n"
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
// use clean target
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"\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 18:05:39 +04:00
|
|
|
// set the make command
|
2007-08-01 17:18:50 +04:00
|
|
|
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"\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 18:05:39 +04:00
|
|
|
"\t\t\t\t\t<value>" + this->GetEclipsePath(make) + "</value>\n"
|
2007-08-01 17:18:50 +04: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 23:07:28 +03:00
|
|
|
<< this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
;
|
|
|
|
|
|
|
|
// set project specific environment
|
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"\t\t\t\t<dictionary>\n"
|
|
|
|
"\t\t\t\t\t<key>org.eclipse.cdt.make.core.environment</key>\n"
|
2009-12-30 15:31:10 +03:00
|
|
|
"\t\t\t\t\t<value>VERBOSE=1|CMAKE_NO_VERBOSE=1|" //verbose Makefile output
|
2007-08-17 18:05:39 +04:00
|
|
|
;
|
|
|
|
// set vsvars32.bat environment available at CMake time,
|
|
|
|
// but not necessarily when eclipse is open
|
2009-12-23 21:56:01 +03:00
|
|
|
if (compilerId == "MSVC")
|
2009-12-23 21:51:46 +03:00
|
|
|
{
|
2009-12-23 21:56:01 +03:00
|
|
|
AddEnvVar(fout, "PATH", mf);
|
|
|
|
AddEnvVar(fout, "INCLUDE", mf);
|
|
|
|
AddEnvVar(fout, "LIB", mf);
|
|
|
|
AddEnvVar(fout, "LIBPATH", mf);
|
2009-12-23 21:51:46 +03:00
|
|
|
}
|
2009-12-23 21:56:01 +03:00
|
|
|
else if (compilerId == "Intel")
|
2009-12-23 21:51:46 +03:00
|
|
|
{
|
2009-12-23 21:56:01 +03:00
|
|
|
// if the env.var is set, use this one and put it in the cache
|
2010-11-12 00:02:07 +03:00
|
|
|
// if the env.var is not set, but the value is in the cache,
|
2009-12-30 15:31:10 +03:00
|
|
|
// use it from the cache:
|
2009-12-23 21:56:01 +03:00
|
|
|
AddEnvVar(fout, "INTEL_LICENSE_FILE", mf);
|
2007-08-17 18:05:39 +04:00
|
|
|
}
|
|
|
|
fout <<
|
|
|
|
"</value>\n"
|
2007-08-01 17:18:50 +04:00
|
|
|
"\t\t\t\t</dictionary>\n"
|
2007-08-17 18:05:39 +04:00
|
|
|
;
|
|
|
|
|
|
|
|
fout <<
|
2007-08-01 17:18:50 +04: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 23:07:28 +03:00
|
|
|
<< this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
;
|
|
|
|
|
|
|
|
// set error parsers
|
|
|
|
fout <<
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
;
|
2009-11-22 13:01:04 +03:00
|
|
|
if (compilerId == "MSVC")
|
2007-08-17 18:05:39 +04:00
|
|
|
{
|
|
|
|
fout << "org.eclipse.cdt.core.VCErrorParser;";
|
|
|
|
}
|
2009-11-22 13:01:04 +03:00
|
|
|
else if (compilerId == "Intel")
|
|
|
|
{
|
|
|
|
fout << "org.eclipse.cdt.core.ICCErrorParser;";
|
|
|
|
}
|
2007-08-17 18:05:39 +04:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
;
|
|
|
|
|
|
|
|
fout <<
|
2007-08-01 17:18:50 +04: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 18:05:39 +04:00
|
|
|
;
|
|
|
|
|
|
|
|
// set natures for c/c++ projects
|
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"\t<natures>\n"
|
2007-08-17 18:05:39 +04:00
|
|
|
// TODO: ccnature only if it is c++ ???
|
2007-08-01 17:18:50 +04: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"
|
|
|
|
;
|
|
|
|
|
2011-02-13 03:15:11 +03:00
|
|
|
fout << "\t<linkedResources>\n";
|
2007-08-17 18:05:39 +04:00
|
|
|
// create linked resources
|
2008-02-20 00:27:03 +03:00
|
|
|
if (this->IsOutOfSourceBuild)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2010-02-13 19:08:42 +03:00
|
|
|
// create a linked resource to CMAKE_SOURCE_DIR
|
2010-11-12 00:02:07 +03:00
|
|
|
// (this is not done anymore for each project because of
|
|
|
|
// http://public.kitware.com/Bug/view.php?id=9978 and because I found it
|
|
|
|
// actually quite confusing in bigger projects with many directories and
|
2010-02-13 19:08:42 +03:00
|
|
|
// projects, Alex
|
|
|
|
|
|
|
|
std::string sourceLinkedResourceName = "[Source directory]";
|
|
|
|
std::string linkSourceDirectory = this->GetEclipsePath(
|
|
|
|
mf->GetStartDirectory());
|
|
|
|
// .project dir can't be subdir of a linked resource dir
|
|
|
|
if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
|
2008-02-08 02:24:55 +03:00
|
|
|
linkSourceDirectory.c_str()))
|
2010-02-13 19:08:42 +03:00
|
|
|
{
|
|
|
|
this->AppendLinkedResource(fout, sourceLinkedResourceName,
|
|
|
|
this->GetEclipsePath(linkSourceDirectory));
|
|
|
|
this->SrcLinkedResources.push_back(sourceLinkedResourceName);
|
2007-08-17 18:05:39 +04:00
|
|
|
}
|
2010-02-13 19:08:42 +03:00
|
|
|
|
2011-02-13 03:15:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// for each sub project create a linked resource to the source dir
|
|
|
|
// - only if it is an out-of-source build
|
|
|
|
this->AppendLinkedResource(fout, "[Subprojects]",
|
2011-05-07 00:44:45 +04:00
|
|
|
"virtual:/virtual", true);
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2011-02-13 03:15:11 +03:00
|
|
|
for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it != this->GlobalGenerator->GetProjectMap().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
std::string linkSourceDirectory = this->GetEclipsePath(
|
|
|
|
it->second[0]->GetMakefile()->GetStartDirectory());
|
|
|
|
// a linked resource must not point to a parent directory of .project or
|
|
|
|
// .project itself
|
|
|
|
if ((this->HomeOutputDirectory != linkSourceDirectory) &&
|
|
|
|
!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
|
|
|
|
linkSourceDirectory.c_str()))
|
|
|
|
{
|
|
|
|
std::string linkName = "[Subprojects]/";
|
|
|
|
linkName += it->first;
|
|
|
|
this->AppendLinkedResource(fout, linkName,
|
|
|
|
this->GetEclipsePath(linkSourceDirectory));
|
|
|
|
this->SrcLinkedResources.push_back(it->first);
|
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2011-02-13 03:15:11 +03:00
|
|
|
// I'm not sure this makes too much sense. There can be different
|
|
|
|
// output directories in different subdirs, so we would need more of them.
|
|
|
|
|
|
|
|
// for EXECUTABLE_OUTPUT_PATH when not in binary dir
|
|
|
|
this->AppendOutLinkedResource(fout,
|
|
|
|
mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"),
|
|
|
|
mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"));
|
|
|
|
// for LIBRARY_OUTPUT_PATH when not in binary dir
|
|
|
|
this->AppendOutLinkedResource(fout,
|
|
|
|
mf->GetSafeDefinition("CMAKE_LIBRARY_OUTPUT_DIRECTORY"),
|
|
|
|
mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH"));
|
|
|
|
|
|
|
|
fout << "\t</linkedResources>\n";
|
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
fout << "</projectDescription>\n";
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2009-03-13 23:52:58 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
|
|
|
|
cmGeneratedFileStream& fout,
|
|
|
|
const std::vector<std::string>& includeDirs,
|
|
|
|
std::set<std::string>& emittedDirs)
|
|
|
|
{
|
|
|
|
for(std::vector<std::string>::const_iterator inc = includeDirs.begin();
|
|
|
|
inc != includeDirs.end();
|
|
|
|
++inc)
|
|
|
|
{
|
|
|
|
if (!inc->empty())
|
|
|
|
{
|
|
|
|
std::string dir = cmSystemTools::CollapseFullPath(inc->c_str());
|
|
|
|
if(emittedDirs.find(dir) == emittedDirs.end())
|
|
|
|
{
|
|
|
|
emittedDirs.insert(dir);
|
2010-11-12 00:02:07 +03:00
|
|
|
fout << "<pathentry include=\""
|
2011-02-13 00:01:27 +03:00
|
|
|
<< cmExtraEclipseCDT4Generator::EscapeForXML(
|
|
|
|
cmExtraEclipseCDT4Generator::GetEclipsePath(dir))
|
2009-03-13 23:52:58 +03:00
|
|
|
<< "\" kind=\"inc\" path=\"\" system=\"true\"/>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
|
|
|
|
{
|
|
|
|
std::set<std::string> emmited;
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
const cmMakefile* mf
|
|
|
|
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
|
|
|
|
|
2008-02-19 23:07:28 +03:00
|
|
|
const std::string filename = this->HomeOutputDirectory + "/.cproject";
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
cmGeneratedFileStream fout(filename.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add header
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<?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 18:05:39 +04:00
|
|
|
// Configuration settings...
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<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 18:05:39 +04:00
|
|
|
// TODO: refactor this out...
|
2009-11-22 13:01:04 +03:00
|
|
|
std::string executableFormat = mf->GetSafeDefinition(
|
|
|
|
"CMAKE_EXECUTABLE_FORMAT");
|
|
|
|
if (executableFormat == "ELF")
|
|
|
|
{
|
|
|
|
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"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
|
|
|
if (systemName == "CYGWIN")
|
|
|
|
{
|
2007-08-01 17:18:50 +04:00
|
|
|
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"
|
|
|
|
;
|
2009-11-22 13:01:04 +03:00
|
|
|
}
|
|
|
|
else if (systemName == "Windows")
|
|
|
|
{
|
2007-08-01 17:18:50 +04:00
|
|
|
fout << "<extension id=\"org.eclipse.cdt.core.PE\""
|
|
|
|
" point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
|
|
|
|
;
|
2009-11-22 13:01:04 +03:00
|
|
|
}
|
|
|
|
else if (systemName == "Darwin")
|
|
|
|
{
|
2007-08-01 17:18:50 +04:00
|
|
|
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"
|
|
|
|
;
|
2009-11-22 13:01:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-01 17:18:50 +04:00
|
|
|
// *** Should never get here ***
|
|
|
|
fout << "<error_toolchain_type/>\n";
|
2009-11-22 13:01:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
fout << "</extensions>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
;
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// ???
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<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-20 00:34:49 +03:00
|
|
|
std::string excludeFromOut;
|
2008-02-20 00:27:03 +03:00
|
|
|
for (std::vector<std::string>::const_iterator
|
|
|
|
it = this->SrcLinkedResources.begin();
|
|
|
|
it != this->SrcLinkedResources.end();
|
2007-08-01 17:18:50 +04:00
|
|
|
++it)
|
|
|
|
{
|
2011-02-13 03:15:11 +03:00
|
|
|
fout << "<pathentry kind=\"src\" path=\"" << this->EscapeForXML(*it)
|
|
|
|
<< "\"/>\n";
|
2007-08-17 18:05:39 +04:00
|
|
|
|
|
|
|
// exlude source directory from output search path
|
|
|
|
// - only if not named the same as an output directory
|
|
|
|
if (!cmSystemTools::FileIsDirectory(
|
2008-02-20 00:27:03 +03:00
|
|
|
std::string(this->HomeOutputDirectory + "/" + *it).c_str()))
|
2007-08-17 18:05:39 +04:00
|
|
|
{
|
2011-02-13 03:15:11 +03:00
|
|
|
excludeFromOut += this->EscapeForXML(*it) + "/|";
|
2007-08-17 18:05:39 +04:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2008-02-20 00:34:49 +03:00
|
|
|
excludeFromOut += "**/CMakeFiles/";
|
|
|
|
fout << "<pathentry excluding=\"" << excludeFromOut
|
2007-08-17 18:05:39 +04: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-20 00:27:03 +03:00
|
|
|
for (std::vector<std::string>::const_iterator
|
|
|
|
it = this->OutLinkedResources.begin();
|
|
|
|
it != this->OutLinkedResources.end();
|
|
|
|
++it)
|
2007-08-17 18:05:39 +04:00
|
|
|
{
|
2011-02-13 03:15:11 +03:00
|
|
|
fout << "<pathentry kind=\"out\" path=\"" << this->EscapeForXML(*it)
|
|
|
|
<< "\"/>\n";
|
2007-08-17 18:05:39 +04:00
|
|
|
}
|
|
|
|
|
2008-02-08 00:26:00 +03: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-20 00:27:03 +03:00
|
|
|
|
2008-02-08 00:26:00 +03: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;
|
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2008-02-08 00:26:00 +03:00
|
|
|
// insert the definition if not already added.
|
|
|
|
if(emmited.find(def) == emmited.end())
|
|
|
|
{
|
|
|
|
emmited.insert(def);
|
|
|
|
fout << "<pathentry kind=\"mac\" name=\"" << def
|
2010-11-12 00:02:07 +03:00
|
|
|
<< "\" path=\"\" value=\"" << this->EscapeForXML(val)
|
2009-01-09 02:09:50 +03:00
|
|
|
<< "\"/>\n";
|
2008-02-08 00:26:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-16 22:37:21 +04:00
|
|
|
// add system defined c macros
|
|
|
|
const char* cDefs=mf->GetDefinition("CMAKE_ECLIPSE_C_SYSTEM_DEFINED_MACROS");
|
|
|
|
if(cDefs)
|
|
|
|
{
|
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cDefs, defs, true);
|
|
|
|
|
|
|
|
// the list must contain only definition-value pairs:
|
|
|
|
if ((defs.size() % 2) == 0)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::const_iterator di = defs.begin();
|
|
|
|
while (di != defs.end())
|
|
|
|
{
|
|
|
|
std::string def = *di;
|
|
|
|
++di;
|
|
|
|
std::string val;
|
|
|
|
if (di != defs.end())
|
|
|
|
{
|
|
|
|
val = *di;
|
|
|
|
++di;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert the definition if not already added.
|
|
|
|
if(emmited.find(def) == emmited.end())
|
|
|
|
{
|
|
|
|
emmited.insert(def);
|
|
|
|
fout << "<pathentry kind=\"mac\" name=\"" << def
|
|
|
|
<< "\" path=\"\" value=\"" << this->EscapeForXML(val)
|
|
|
|
<< "\"/>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add system defined c++ macros
|
|
|
|
const char* cxxDefs = mf->GetDefinition(
|
|
|
|
"CMAKE_ECLIPSE_CXX_SYSTEM_DEFINED_MACROS");
|
|
|
|
if(cxxDefs)
|
|
|
|
{
|
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cxxDefs, defs, true);
|
|
|
|
|
|
|
|
// the list must contain only definition-value pairs:
|
|
|
|
if ((defs.size() % 2) == 0)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::const_iterator di = defs.begin();
|
|
|
|
while (di != defs.end())
|
|
|
|
{
|
|
|
|
std::string def = *di;
|
|
|
|
++di;
|
|
|
|
std::string val;
|
|
|
|
if (di != defs.end())
|
|
|
|
{
|
|
|
|
val = *di;
|
|
|
|
++di;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert the definition if not already added.
|
|
|
|
if(emmited.find(def) == emmited.end())
|
|
|
|
{
|
|
|
|
emmited.insert(def);
|
|
|
|
fout << "<pathentry kind=\"mac\" name=\"" << def
|
|
|
|
<< "\" path=\"\" value=\"" << this->EscapeForXML(val)
|
|
|
|
<< "\"/>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-08 00:26:00 +03:00
|
|
|
|
2007-08-01 17:18:50 +04: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();
|
2009-03-13 23:52:58 +03:00
|
|
|
this->AppendIncludeDirectories(fout, includeDirs, emmited);
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
// now also the system include directories, in case we found them in
|
|
|
|
// CMakeSystemSpecificInformation.cmake. This makes Eclipse find the
|
2009-03-13 23:52:58 +03:00
|
|
|
// standard headers.
|
|
|
|
mf->GetDefinition("CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS");
|
|
|
|
std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER");
|
|
|
|
if (!compiler.empty())
|
|
|
|
{
|
|
|
|
std::string systemIncludeDirs = mf->GetSafeDefinition(
|
|
|
|
"CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS");
|
|
|
|
std::vector<std::string> dirs;
|
|
|
|
cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
|
|
|
|
this->AppendIncludeDirectories(fout, dirs, emmited);
|
|
|
|
}
|
|
|
|
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
|
|
|
|
if (!compiler.empty())
|
|
|
|
{
|
|
|
|
std::string systemIncludeDirs = mf->GetSafeDefinition(
|
|
|
|
"CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS");
|
|
|
|
std::vector<std::string> dirs;
|
|
|
|
cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
|
|
|
|
this->AppendIncludeDirectories(fout, dirs, emmited);
|
|
|
|
}
|
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
fout << "</storageModule>\n";
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
// add build targets
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<storageModule moduleId=\"org.eclipse.cdt.make.core.buildtargets\">\n"
|
|
|
|
"<buildTargets>\n"
|
|
|
|
;
|
|
|
|
emmited.clear();
|
2007-08-17 18:05:39 +04:00
|
|
|
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
2010-12-12 18:52:20 +03:00
|
|
|
const std::string makeArgs = mf->GetSafeDefinition(
|
|
|
|
"CMAKE_ECLIPSE_MAKE_ARGUMENTS");
|
2007-08-17 18:05:39 +04:00
|
|
|
cmGlobalGenerator* generator
|
|
|
|
= const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2009-09-17 02:01:23 +04:00
|
|
|
std::string allTarget;
|
|
|
|
std::string cleanTarget;
|
2007-08-17 18:05:39 +04:00
|
|
|
if (generator->GetAllTargetName())
|
|
|
|
{
|
2009-09-17 02:01:23 +04:00
|
|
|
allTarget = generator->GetAllTargetName();
|
2007-08-17 18:05:39 +04:00
|
|
|
}
|
2007-11-25 15:40:57 +03:00
|
|
|
if (generator->GetCleanTargetName())
|
|
|
|
{
|
2009-09-17 02:01:23 +04:00
|
|
|
cleanTarget = generator->GetCleanTargetName();
|
2007-11-25 15:40:57 +03:00
|
|
|
}
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
// add all executable and library targets and some of the GLOBAL
|
2007-11-25 15:40:57 +03:00
|
|
|
// and UTILITY targets
|
2007-08-01 17:18:50 +04:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator
|
|
|
|
it = this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end();
|
|
|
|
++it)
|
|
|
|
{
|
|
|
|
const cmTargets& targets = (*it)->GetMakefile()->GetTargets();
|
2009-09-10 21:49:51 +04:00
|
|
|
cmMakefile* makefile=(*it)->GetMakefile();
|
2009-09-17 02:01:23 +04:00
|
|
|
std::string subdir = (*it)->Convert(makefile->GetCurrentOutputDirectory(),
|
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
|
|
|
if (subdir == ".")
|
|
|
|
{
|
|
|
|
subdir = "";
|
|
|
|
}
|
|
|
|
|
2009-09-10 21:49:51 +04:00
|
|
|
for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2009-09-10 21:49:51 +04:00
|
|
|
switch(ti->second.GetType())
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2007-11-25 15:40:57 +03:00
|
|
|
case cmTarget::GLOBAL_TARGET:
|
|
|
|
{
|
2009-09-10 21:49:51 +04:00
|
|
|
bool insertTarget = false;
|
2010-11-12 00:02:07 +03:00
|
|
|
// Only add the global targets from CMAKE_BINARY_DIR,
|
2009-09-10 21:49:51 +04:00
|
|
|
// not from the subdirs
|
2009-09-17 02:01:23 +04:00
|
|
|
if (subdir.empty())
|
2009-09-10 21:49:51 +04:00
|
|
|
{
|
|
|
|
insertTarget = true;
|
|
|
|
// only add the "edit_cache" target if it's not ccmake, because
|
|
|
|
// this will not work within the IDE
|
|
|
|
if (ti->first == "edit_cache")
|
|
|
|
{
|
2009-10-21 01:14:12 +04:00
|
|
|
const char* editCommand = makefile->GetDefinition
|
|
|
|
("CMAKE_EDIT_COMMAND");
|
|
|
|
if (editCommand == 0)
|
|
|
|
{
|
|
|
|
insertTarget = false;
|
|
|
|
}
|
|
|
|
else if (strstr(editCommand, "ccmake")!=NULL)
|
2009-09-10 21:49:51 +04:00
|
|
|
{
|
|
|
|
insertTarget = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (insertTarget)
|
|
|
|
{
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, ti->first, make, makeArgs, subdir, ": ");
|
2009-09-10 21:49:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::UTILITY:
|
|
|
|
// Add all utility targets, except the Nightly/Continuous/
|
|
|
|
// Experimental-"sub"targets as e.g. NightlyStart
|
|
|
|
if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly"))
|
|
|
|
|| ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous"))
|
2010-11-12 00:02:07 +03:00
|
|
|
|| ((ti->first.find("Experimental")==0)
|
2009-09-10 21:49:51 +04:00
|
|
|
&& (ti->first!="Experimental")))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, ti->first, make, makeArgs, subdir, ": ");
|
2009-09-10 21:49:51 +04:00
|
|
|
break;
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
{
|
2009-09-17 02:01:23 +04:00
|
|
|
const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ?
|
|
|
|
"[exe] " : "[lib] ");
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, ti->first, make, makeArgs, subdir, prefix);
|
2009-09-10 21:49:51 +04:00
|
|
|
std::string fastTarget = ti->first;
|
|
|
|
fastTarget += "/fast";
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, fastTarget, make, makeArgs, subdir, prefix);
|
2009-09-10 21:49:51 +04:00
|
|
|
}
|
|
|
|
break;
|
2007-11-25 15:40:57 +03:00
|
|
|
// ignore these:
|
|
|
|
case cmTarget::INSTALL_FILES:
|
|
|
|
case cmTarget::INSTALL_PROGRAMS:
|
|
|
|
case cmTarget::INSTALL_DIRECTORY:
|
|
|
|
default:
|
|
|
|
break;
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2009-09-17 02:01:23 +04:00
|
|
|
// insert the all and clean targets in every subdir
|
|
|
|
if (!allTarget.empty())
|
|
|
|
{
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, allTarget, make, makeArgs, subdir, ": ");
|
2009-09-17 02:01:23 +04:00
|
|
|
}
|
|
|
|
if (!cleanTarget.empty())
|
|
|
|
{
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, cleanTarget, make, makeArgs, subdir, ": ");
|
2009-09-17 02:01:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//insert rules for compiling, preprocessing and assembling individual files
|
|
|
|
cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it;
|
|
|
|
std::vector<std::string> objectFileTargets;
|
|
|
|
lumg->GetIndividualFileTargets(objectFileTargets);
|
|
|
|
for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin();
|
|
|
|
fit != objectFileTargets.end();
|
|
|
|
++fit)
|
|
|
|
{
|
|
|
|
const char* prefix = "[obj] ";
|
|
|
|
if ((*fit)[fit->length()-1] == 's')
|
|
|
|
{
|
|
|
|
prefix = "[to asm] ";
|
|
|
|
}
|
|
|
|
else if ((*fit)[fit->length()-1] == 'i')
|
|
|
|
{
|
|
|
|
prefix = "[pre] ";
|
|
|
|
}
|
2010-12-12 18:52:20 +03:00
|
|
|
this->AppendTarget(fout, *fit, make, makeArgs, subdir, prefix);
|
2009-09-17 02:01:23 +04:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2009-09-17 02:01:23 +04:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
fout << "</buildTargets>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
;
|
|
|
|
|
2009-01-10 02:58:21 +03:00
|
|
|
this->AppendStorageScanners(fout, *mf);
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
fout << "</cconfiguration>\n"
|
|
|
|
"</storageModule>\n"
|
|
|
|
"<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n"
|
2011-02-12 23:49:08 +03:00
|
|
|
"<project id=\"" << this->EscapeForXML(mf->GetProjectName())
|
|
|
|
<< ".null.1\" name=\"" << this->EscapeForXML(mf->GetProjectName())
|
|
|
|
<< "\"/>\n"
|
2007-08-01 17:18:50 +04:00
|
|
|
"</storageModule>\n"
|
|
|
|
"</cproject>\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
2007-08-17 18:05:39 +04:00
|
|
|
cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
|
|
|
#if defined(__CYGWIN__)
|
2007-08-17 18:05:39 +04:00
|
|
|
std::string cmd = "cygpath -m " + path;
|
2007-08-01 17:18:50 +04: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 18:05:39 +04: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 23:07:28 +03:00
|
|
|
std::string
|
|
|
|
cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name,
|
|
|
|
const std::string& type,
|
|
|
|
const std::string& path)
|
|
|
|
{
|
2011-02-12 23:49:08 +03:00
|
|
|
return cmExtraEclipseCDT4Generator::EscapeForXML(name)
|
|
|
|
+(type.empty() ? "" : "-") + type + "@" + path;
|
2008-02-19 23:07:28 +03:00
|
|
|
}
|
|
|
|
|
2009-01-09 02:09:50 +03: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 17:18:50 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Helper functions
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExtraEclipseCDT4Generator
|
2010-11-12 00:02:07 +03:00
|
|
|
::AppendStorageScanners(cmGeneratedFileStream& fout,
|
2009-01-10 02:58:21 +03:00
|
|
|
const cmMakefile& makefile)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2009-01-10 02:58:21 +03: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 :-/
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<storageModule moduleId=\"scannerConfiguration\">\n"
|
|
|
|
"<autodiscovery enabled=\"true\" problemReportingEnabled=\"true\""
|
2007-08-17 18:05:39 +04:00
|
|
|
" selectedProfileId="
|
|
|
|
"\"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile\"/>\n"
|
2007-08-01 17:18:50 +04:00
|
|
|
;
|
2007-08-17 18:05:39 +04:00
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
|
2007-08-01 17:18:50 +04:00
|
|
|
"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile",
|
|
|
|
true, "", true, "specsFile",
|
|
|
|
"-E -P -v -dD ${plugin_state_location}/${specs_file}",
|
2009-01-10 02:58:21 +03:00
|
|
|
compiler, true, true);
|
2007-08-17 18:05:39 +04:00
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
|
2007-08-01 17:18:50 +04:00
|
|
|
"org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile",
|
|
|
|
true, "", true, "makefileGenerator",
|
|
|
|
"-f ${project_name}_scd.mk",
|
2009-01-10 02:58:21 +03:00
|
|
|
make, true, true);
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
fout << "</storageModule>\n";
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2009-09-17 02:01:23 +04:00
|
|
|
// The prefix is prepended before the actual name of the target. The purpose
|
|
|
|
// of that is to sort the targets in the view of Eclipse, so that at first
|
|
|
|
// the global/utility/all/clean targets appear ": ", then the executable
|
|
|
|
// targets "[exe] ", then the libraries "[lib]", then the rules for the
|
2010-11-12 00:02:07 +03:00
|
|
|
// object files "[obj]", then for preprocessing only "[pre] " and
|
|
|
|
// finally the assembly files "[to asm] ". Note the "to" in "to asm",
|
2009-09-17 02:01:23 +04:00
|
|
|
// without it, "asm" would be the first targets in the list, with the "to"
|
|
|
|
// they are the last targets, which makes more sense.
|
2007-08-17 18:05:39 +04:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
|
|
|
|
const std::string& target,
|
2009-09-17 02:01:23 +04:00
|
|
|
const std::string& make,
|
2010-12-12 18:52:20 +03:00
|
|
|
const std::string& makeArgs,
|
2009-09-17 02:01:23 +04:00
|
|
|
const std::string& path,
|
|
|
|
const char* prefix)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2011-02-12 23:54:02 +03:00
|
|
|
std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target);
|
2011-02-13 00:01:27 +03:00
|
|
|
std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2011-02-12 23:54:02 +03:00
|
|
|
"<target name=\"" << prefix << targetXml << "\""
|
2011-02-13 00:01:27 +03:00
|
|
|
" path=\"" << pathXml.c_str() << "\""
|
2007-08-01 17:18:50 +04:00
|
|
|
" targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
|
2007-08-17 18:05:39 +04:00
|
|
|
"<buildCommand>"
|
|
|
|
<< cmExtraEclipseCDT4Generator::GetEclipsePath(make)
|
|
|
|
<< "</buildCommand>\n"
|
2010-12-12 18:52:20 +03:00
|
|
|
"<buildArguments>" << makeArgs << "</buildArguments>\n"
|
2011-02-12 23:54:02 +03:00
|
|
|
"<buildTarget>" << targetXml << "</buildTarget>\n"
|
2007-08-01 17:18:50 +04:00
|
|
|
"<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 18:05:39 +04:00
|
|
|
bool sipParserEnabled)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2010-11-12 00:02:07 +03:00
|
|
|
fout <<
|
2007-08-01 17:18:50 +04:00
|
|
|
"<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-20 00:27:03 +03:00
|
|
|
|
|
|
|
void cmExtraEclipseCDT4Generator
|
|
|
|
::AppendLinkedResource (cmGeneratedFileStream& fout,
|
|
|
|
const std::string& name,
|
2011-05-07 00:44:45 +04:00
|
|
|
const std::string& path,
|
|
|
|
bool isVirtualFolder)
|
2008-02-20 00:27:03 +03:00
|
|
|
{
|
2011-05-07 00:44:45 +04:00
|
|
|
const char* locationTag = "location";
|
|
|
|
if (isVirtualFolder) // ... and not a linked folder
|
|
|
|
{
|
|
|
|
locationTag = "locationURI";
|
|
|
|
}
|
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
fout <<
|
|
|
|
"\t\t<link>\n"
|
2011-02-13 03:15:11 +03:00
|
|
|
"\t\t\t<name>"
|
|
|
|
<< cmExtraEclipseCDT4Generator::EscapeForXML(name)
|
|
|
|
<< "</name>\n"
|
2008-02-20 00:27:03 +03:00
|
|
|
"\t\t\t<type>2</type>\n"
|
2011-05-07 00:44:45 +04:00
|
|
|
"\t\t\t<" << locationTag << ">"
|
2011-02-13 03:15:11 +03:00
|
|
|
<< cmExtraEclipseCDT4Generator::EscapeForXML(path)
|
2011-05-07 00:44:45 +04:00
|
|
|
<< "</" << locationTag << ">\n"
|
2008-02-20 00:27:03 +03:00
|
|
|
"\t\t</link>\n"
|
|
|
|
;
|
|
|
|
}
|
2009-01-11 20:18:44 +03:00
|
|
|
|
|
|
|
bool cmExtraEclipseCDT4Generator
|
|
|
|
::AppendOutLinkedResource(cmGeneratedFileStream& fout,
|
|
|
|
const std::string& defname,
|
|
|
|
const std::string& altdefname)
|
|
|
|
{
|
|
|
|
if (defname.empty() && altdefname.empty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string outputPath = (defname.empty() ? altdefname : defname);
|
|
|
|
|
|
|
|
if (!cmSystemTools::FileIsFullPath(outputPath.c_str()))
|
|
|
|
{
|
|
|
|
outputPath = this->HomeOutputDirectory + "/" + outputPath;
|
|
|
|
}
|
|
|
|
if (cmSystemTools::IsSubDirectory(outputPath.c_str(),
|
|
|
|
this->HomeOutputDirectory.c_str()))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name = this->GetPathBasename(outputPath);
|
|
|
|
|
|
|
|
// make sure linked resource name is unique
|
|
|
|
while (this->GlobalGenerator->GetProjectMap().find(name)
|
|
|
|
!= this->GlobalGenerator->GetProjectMap().end())
|
|
|
|
{
|
|
|
|
name += "_";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (std::find(this->OutLinkedResources.begin(),
|
|
|
|
this->OutLinkedResources.end(),
|
|
|
|
name)
|
|
|
|
!= this->OutLinkedResources.end())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->AppendLinkedResource(fout, name,
|
|
|
|
this->GetEclipsePath(outputPath));
|
|
|
|
this->OutLinkedResources.push_back(name);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|