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"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
|
#include "cmGeneratorTarget.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2007-08-01 17:18:50 +04:00
|
|
|
#include "cmMakefile.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmOutputConverter.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmSourceFile.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmSourceGroup.h"
|
2015-04-06 11:52:45 +03:00
|
|
|
#include "cmState.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmSystemTools.h"
|
2015-08-02 23:06:38 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmake.h"
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <algorithm>
|
2008-02-20 00:27:03 +03:00
|
|
|
#include <assert.h>
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
#include <map>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <utility>
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
static void AppendAttribute(cmXMLWriter& xml, const char* keyval)
|
|
|
|
{
|
|
|
|
xml.StartElement("attribute");
|
|
|
|
xml.Attribute("key", keyval);
|
|
|
|
xml.Attribute("value", keyval);
|
|
|
|
xml.EndElement();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename T>
|
2015-08-02 23:06:38 +03:00
|
|
|
void AppendDictionary(cmXMLWriter& xml, const char* key, T const& value)
|
|
|
|
{
|
|
|
|
xml.StartElement("dictionary");
|
|
|
|
xml.Element("key", key);
|
|
|
|
xml.Element("value", value);
|
|
|
|
xml.EndElement();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExtraEclipseCDT4Generator::cmExtraEclipseCDT4Generator()
|
|
|
|
: cmExternalMakefileProjectGenerator()
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2011-10-15 21:40:21 +04:00
|
|
|
this->SupportsVirtualFolders = true;
|
2012-10-18 01:45:02 +04:00
|
|
|
this->GenerateLinkedResources = true;
|
2013-03-23 02:50:38 +04:00
|
|
|
this->SupportsGmakeErrorParser = true;
|
2014-01-01 20:52:57 +04:00
|
|
|
this->SupportsMachO64Parser = true;
|
2016-02-25 00:13:04 +03:00
|
|
|
this->CEnabled = false;
|
|
|
|
this->CXXEnabled = false;
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2016-07-20 19:28:39 +03:00
|
|
|
cmExternalMakefileProjectGeneratorFactory*
|
|
|
|
cmExtraEclipseCDT4Generator::GetFactory()
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2016-07-20 19:28:39 +03:00
|
|
|
static cmExternalMakefileProjectGeneratorSimpleFactory<
|
|
|
|
cmExtraEclipseCDT4Generator>
|
|
|
|
factory("Eclipse CDT4", "Generates Eclipse CDT 4.0 project files.");
|
|
|
|
|
|
|
|
if (factory.GetSupportedGlobalGenerators().empty()) {
|
|
|
|
// TODO: Verify if __CYGWIN__ should be checked.
|
|
|
|
//#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
#if defined(_WIN32)
|
|
|
|
factory.AddSupportedGlobalGenerator("NMake Makefiles");
|
|
|
|
factory.AddSupportedGlobalGenerator("MinGW Makefiles");
|
|
|
|
// factory.AddSupportedGlobalGenerator("MSYS Makefiles");
|
|
|
|
#endif
|
|
|
|
factory.AddSupportedGlobalGenerator("Ninja");
|
|
|
|
factory.AddSupportedGlobalGenerator("Unix Makefiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
return &factory;
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::EnableLanguage(
|
2016-08-17 02:49:57 +03:00
|
|
|
std::vector<std::string> const& languages, cmMakefile* /*unused*/,
|
|
|
|
bool /*optional*/)
|
2013-08-29 22:46:17 +04:00
|
|
|
{
|
|
|
|
for (std::vector<std::string>::const_iterator lit = languages.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
lit != languages.end(); ++lit) {
|
|
|
|
if (*lit == "CXX") {
|
2013-08-29 22:46:17 +04:00
|
|
|
this->Natures.insert("org.eclipse.cdt.core.ccnature");
|
2014-09-26 16:38:54 +04:00
|
|
|
this->Natures.insert("org.eclipse.cdt.core.cnature");
|
2016-02-25 00:13:04 +03:00
|
|
|
this->CXXEnabled = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (*lit == "C") {
|
2013-08-29 22:46:17 +04:00
|
|
|
this->Natures.insert("org.eclipse.cdt.core.cnature");
|
2016-02-25 00:13:04 +03:00
|
|
|
this->CEnabled = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (*lit == "Java") {
|
2013-08-29 22:46:17 +04:00
|
|
|
this->Natures.insert("org.eclipse.jdt.core.javanature");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-29 22:46:17 +04:00
|
|
|
}
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
void cmExtraEclipseCDT4Generator::Generate()
|
|
|
|
{
|
2015-10-07 02:17:48 +03:00
|
|
|
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
|
|
|
|
const cmMakefile* mf = lg->GetMakefile();
|
2008-02-19 23:07:28 +03:00
|
|
|
|
2011-10-15 21:40:21 +04:00
|
|
|
std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION");
|
|
|
|
cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (regex.find(eclipseVersion.c_str())) {
|
2011-10-15 21:40:21 +04:00
|
|
|
unsigned int majorVersion = 0;
|
|
|
|
unsigned int minorVersion = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
int res =
|
|
|
|
sscanf(regex.match(1).c_str(), "%u.%u", &majorVersion, &minorVersion);
|
|
|
|
if (res == 2) {
|
2011-10-15 21:40:21 +04:00
|
|
|
int version = majorVersion * 1000 + minorVersion;
|
|
|
|
if (version < 3006) // 3.6 is Helios
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2011-10-15 21:40:21 +04:00
|
|
|
this->SupportsVirtualFolders = false;
|
2014-01-01 20:52:57 +04:00
|
|
|
this->SupportsMachO64Parser = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-03-23 02:50:38 +04:00
|
|
|
if (version < 3007) // 3.7 is Indigo
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2013-03-23 02:50:38 +04:00
|
|
|
this->SupportsGmakeErrorParser = false;
|
2011-10-15 21:40:21 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-15 21:40:21 +04:00
|
|
|
|
2008-02-19 23:07:28 +03:00
|
|
|
// TODO: Decide if these are local or member variables
|
2016-05-16 17:34:04 +03:00
|
|
|
this->HomeDirectory = lg->GetSourceDirectory();
|
2015-10-07 02:17:48 +03:00
|
|
|
this->HomeOutputDirectory = lg->GetBinaryDirectory();
|
2008-02-19 23:07:28 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GenerateLinkedResources =
|
|
|
|
mf->IsOn("CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES");
|
2012-10-18 01:45:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->IsOutOfSourceBuild =
|
|
|
|
(this->HomeDirectory != this->HomeOutputDirectory);
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GenerateSourceProject =
|
|
|
|
(this->IsOutOfSourceBuild &&
|
|
|
|
mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
|
2011-11-19 14:18:51 +04:00
|
|
|
|
2016-06-02 00:29:53 +03:00
|
|
|
if (!this->GenerateSourceProject &&
|
2016-05-16 17:34:04 +03:00
|
|
|
(mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) {
|
|
|
|
mf->IssueMessage(
|
|
|
|
cmake::WARNING,
|
|
|
|
"ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
|
|
|
|
"but this variable is not supported anymore since CMake 2.8.7.\n"
|
|
|
|
"Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
|
|
|
|
}
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->HomeDirectory)) {
|
|
|
|
mf->IssueMessage(cmake::WARNING,
|
|
|
|
"The build directory is a subdirectory "
|
2011-11-01 13:41:23 +04:00
|
|
|
"of the source directory.\n"
|
|
|
|
"This is not supported well by Eclipse. It is strongly "
|
|
|
|
"recommended to use a build directory which is a "
|
|
|
|
"sibling of the source directory.");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-11-01 13:41:23 +04:00
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
// 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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GenerateSourceProject) {
|
2008-02-20 00:27:03 +03:00
|
|
|
// create .project file in the source tree
|
|
|
|
this->CreateSourceProjectFile();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// create a .project file
|
|
|
|
this->CreateProjectFile();
|
|
|
|
|
|
|
|
// create a .cproject file
|
|
|
|
this->CreateCProjectFile();
|
|
|
|
}
|
|
|
|
|
2011-11-19 14:01:03 +04:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
|
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>
|
2015-10-07 01:29:25 +03:00
|
|
|
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string name =
|
|
|
|
this->GenerateProjectName(lg->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());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
2008-02-20 00:27:03 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
cmXMLWriter xml(fout);
|
|
|
|
xml.StartDocument("UTF-8");
|
|
|
|
xml.StartElement("projectDescription");
|
|
|
|
xml.Element("name", name);
|
|
|
|
xml.Element("comment", "");
|
|
|
|
xml.Element("projects", "");
|
|
|
|
xml.Element("buildSpec", "");
|
|
|
|
xml.Element("natures", "");
|
|
|
|
xml.StartElement("linkedResources");
|
2011-11-19 14:01:03 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SupportsVirtualFolders) {
|
2015-08-02 23:06:38 +03:00
|
|
|
this->CreateLinksToSubprojects(xml, this->HomeDirectory);
|
2011-11-19 14:01:03 +04:00
|
|
|
this->SrcLinkedResources.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-11-19 14:01:03 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // linkedResources
|
|
|
|
xml.EndElement(); // projectDescription
|
|
|
|
xml.EndDocument();
|
2008-02-20 00:27:03 +03:00
|
|
|
}
|
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
|
2015-10-07 01:58:45 +03:00
|
|
|
const char* envVar,
|
|
|
|
cmLocalGenerator* lg)
|
2009-12-23 21:56:01 +03:00
|
|
|
{
|
2015-10-07 01:58:45 +03:00
|
|
|
cmMakefile* mf = lg->GetMakefile();
|
|
|
|
|
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:
|
|
|
|
|
2016-07-08 00:54:05 +03:00
|
|
|
std::string envVarValue;
|
|
|
|
const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue);
|
2009-12-23 21:56:01 +03:00
|
|
|
|
|
|
|
std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
|
|
|
|
cacheEntryName += envVar;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cacheValue =
|
|
|
|
lg->GetState()->GetInitializedCacheValue(cacheEntryName);
|
2009-12-23 21:56:01 +03:00
|
|
|
|
|
|
|
// now we have both, decide which one to use
|
|
|
|
std::string valueToUse;
|
2016-07-08 00:54:05 +03:00
|
|
|
if (!envVarSet && cacheValue == CM_NULLPTR) {
|
2009-12-23 21:56:01 +03:00
|
|
|
// nothing known, do nothing
|
|
|
|
valueToUse = "";
|
2016-07-08 00:54:05 +03:00
|
|
|
} else if (envVarSet && cacheValue == CM_NULLPTR) {
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
cacheEntryName.c_str(), cmState::STRING, true);
|
2015-10-07 02:17:48 +03:00
|
|
|
mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
|
2016-07-08 00:54:05 +03:00
|
|
|
} else if (!envVarSet && cacheValue != CM_NULLPTR) {
|
2009-12-23 21:56:01 +03:00
|
|
|
// It is already in the cache, but not in the env, so use it from the cache
|
|
|
|
valueToUse = cacheValue;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-12-23 21:56:01 +03:00
|
|
|
// 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (valueToUse.find(envVarValue) == std::string::npos) {
|
2009-12-23 21:56:01 +03:00
|
|
|
valueToUse = envVarValue;
|
2014-03-11 03:04:11 +04:00
|
|
|
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
cacheEntryName.c_str(), cmState::STRING, true);
|
2015-10-07 02:17:48 +03:00
|
|
|
mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
|
2009-12-23 21:56:01 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-23 21:56:01 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!valueToUse.empty()) {
|
2015-08-02 23:06:38 +03:00
|
|
|
out << envVar << "=" << valueToUse << "|";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-23 21:56:01 +03:00
|
|
|
}
|
|
|
|
|
2008-02-20 00:27:03 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateProjectFile()
|
|
|
|
{
|
2015-10-07 01:29:25 +03:00
|
|
|
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
|
|
|
|
cmMakefile* mf = lg->GetMakefile();
|
2008-02-20 00:27:03 +03:00
|
|
|
|
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());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
2007-08-01 17:18:50 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2009-12-23 21:56:01 +03:00
|
|
|
std::string compilerId = mf->GetSafeDefinition("CMAKE_C_COMPILER_ID");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (compilerId.empty()) // no C compiler, try the C++ compiler:
|
|
|
|
{
|
2009-12-23 21:56:01 +03:00
|
|
|
compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-23 21:56:01 +03:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
cmXMLWriter xml(fout);
|
|
|
|
|
|
|
|
xml.StartDocument("UTF-8");
|
|
|
|
xml.StartElement("projectDescription");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Element("name", this->GenerateProjectName(
|
|
|
|
lg->GetProjectName(),
|
|
|
|
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
|
|
|
|
this->GetPathBasename(this->HomeOutputDirectory)));
|
2015-08-02 23:06:38 +03:00
|
|
|
|
|
|
|
xml.Element("comment", "");
|
|
|
|
xml.Element("projects", "");
|
|
|
|
|
|
|
|
xml.StartElement("buildSpec");
|
|
|
|
xml.StartElement("buildCommand");
|
|
|
|
xml.Element("name", "org.eclipse.cdt.make.core.makeBuilder");
|
|
|
|
xml.Element("triggers", "clean,full,incremental,");
|
|
|
|
xml.StartElement("arguments");
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
// use clean target
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.cleanBuildTarget", "clean");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.enableCleanBuild", "true");
|
2016-05-16 17:34:04 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.append_environment",
|
|
|
|
"true");
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.stopOnError", "true");
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
// set the make command
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.enabledIncrementalBuild",
|
2016-05-16 17:34:04 +03:00
|
|
|
"true");
|
|
|
|
AppendDictionary(
|
|
|
|
xml, "org.eclipse.cdt.make.core.build.command",
|
|
|
|
this->GetEclipsePath(mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")));
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.contents",
|
2016-05-16 17:34:04 +03:00
|
|
|
"org.eclipse.cdt.make.core.activeConfigSettings");
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.inc", "all");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.arguments",
|
2016-05-16 17:34:04 +03:00
|
|
|
mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS"));
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.buildLocation",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetEclipsePath(this->HomeOutputDirectory));
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.useDefaultBuildCmd",
|
|
|
|
"false");
|
2007-08-17 18:05:39 +04:00
|
|
|
|
|
|
|
// set project specific environment
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream environment;
|
2016-05-16 17:34:04 +03:00
|
|
|
environment << "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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (compilerId == "MSVC") {
|
2015-08-02 23:06:38 +03:00
|
|
|
AddEnvVar(environment, "PATH", lg);
|
|
|
|
AddEnvVar(environment, "INCLUDE", lg);
|
|
|
|
AddEnvVar(environment, "LIB", lg);
|
|
|
|
AddEnvVar(environment, "LIBPATH", lg);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (compilerId == "Intel") {
|
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:
|
2015-08-02 23:06:38 +03:00
|
|
|
AddEnvVar(environment, "INTEL_LICENSE_FILE", lg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.environment",
|
|
|
|
environment.str());
|
|
|
|
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.enableFullBuild", "true");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.auto", "all");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.enableAutoBuild", "false");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.clean",
|
2016-05-16 17:34:04 +03:00
|
|
|
"clean");
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.fullBuildTarget", "all");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.buildArguments", "");
|
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.location",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetEclipsePath(this->HomeOutputDirectory));
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all");
|
2007-08-17 18:05:39 +04:00
|
|
|
|
|
|
|
// set error parsers
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream errorOutputParser;
|
2015-08-02 23:06:38 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (compilerId == "MSVC") {
|
2015-08-02 23:06:38 +03:00
|
|
|
errorOutputParser << "org.eclipse.cdt.core.VCErrorParser;";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (compilerId == "Intel") {
|
2015-08-02 23:06:38 +03:00
|
|
|
errorOutputParser << "org.eclipse.cdt.core.ICCErrorParser;";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-03-23 02:50:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SupportsGmakeErrorParser) {
|
2015-08-02 23:06:38 +03:00
|
|
|
errorOutputParser << "org.eclipse.cdt.core.GmakeErrorParser;";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-02 23:06:38 +03:00
|
|
|
errorOutputParser << "org.eclipse.cdt.core.MakeErrorParser;";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-03-23 02:50:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
errorOutputParser << "org.eclipse.cdt.core.GCCErrorParser;"
|
|
|
|
"org.eclipse.cdt.core.GASErrorParser;"
|
|
|
|
"org.eclipse.cdt.core.GLDErrorParser;";
|
2015-08-02 23:06:38 +03:00
|
|
|
AppendDictionary(xml, "org.eclipse.cdt.core.errorOutputParser",
|
2016-05-16 17:34:04 +03:00
|
|
|
errorOutputParser.str());
|
2015-08-02 23:06:38 +03:00
|
|
|
|
|
|
|
xml.EndElement(); // arguments
|
|
|
|
xml.EndElement(); // buildCommand
|
|
|
|
xml.StartElement("buildCommand");
|
|
|
|
xml.Element("name", "org.eclipse.cdt.make.core.ScannerConfigBuilder");
|
|
|
|
xml.StartElement("arguments");
|
|
|
|
xml.EndElement(); // arguments
|
|
|
|
xml.EndElement(); // buildCommand
|
|
|
|
xml.EndElement(); // buildSpec
|
2007-08-17 18:05:39 +04:00
|
|
|
|
|
|
|
// set natures for c/c++ projects
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("natures");
|
|
|
|
xml.Element("nature", "org.eclipse.cdt.make.core.makeNature");
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");
|
|
|
|
;
|
2013-08-29 22:46:17 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<std::string>::const_iterator nit = this->Natures.begin();
|
|
|
|
nit != this->Natures.end(); ++nit) {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Element("nature", *nit);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-29 22:46:17 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* extraNaturesProp =
|
|
|
|
mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_NATURES")) {
|
2013-08-29 22:51:59 +04:00
|
|
|
std::vector<std::string> extraNatures;
|
|
|
|
cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);
|
|
|
|
for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
nit != extraNatures.end(); ++nit) {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Element("nature", *nit);
|
2013-08-29 22:51:59 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-29 22:51:59 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // natures
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("linkedResources");
|
2007-08-17 18:05:39 +04:00
|
|
|
// create linked resources
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOutOfSourceBuild) {
|
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
|
2016-08-12 22:06:35 +03:00
|
|
|
// https://gitlab.kitware.com/cmake/cmake/issues/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]";
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string linkSourceDirectory =
|
|
|
|
this->GetEclipsePath(lg->GetCurrentSourceDirectory());
|
2010-02-13 19:08:42 +03:00
|
|
|
// .project dir can't be subdir of a linked resource dir
|
2014-10-15 16:54:05 +04:00
|
|
|
if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
|
2016-05-16 17:34:04 +03:00
|
|
|
linkSourceDirectory)) {
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendLinkedResource(xml, sourceLinkedResourceName,
|
2011-10-20 00:02:14 +04:00
|
|
|
this->GetEclipsePath(linkSourceDirectory),
|
|
|
|
LinkToFolder);
|
2010-02-13 19:08:42 +03:00
|
|
|
this->SrcLinkedResources.push_back(sourceLinkedResourceName);
|
2011-02-13 03:15:11 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-02-13 03:15:11 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SupportsVirtualFolders) {
|
2015-08-02 23:06:38 +03:00
|
|
|
this->CreateLinksToSubprojects(xml, this->HomeOutputDirectory);
|
2011-10-20 00:02:14 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
this->CreateLinksForTargets(xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // linkedResources
|
|
|
|
xml.EndElement(); // projectDescription
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 11:52:43 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::WriteGroups(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmSourceGroup> const& sourceGroups, std::string& linkName,
|
|
|
|
cmXMLWriter& xml)
|
2016-03-31 11:52:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceGroup>::const_iterator sgIt = sourceGroups.begin();
|
|
|
|
sgIt != sourceGroups.end(); ++sgIt) {
|
2016-03-31 11:52:43 +03:00
|
|
|
std::string linkName3 = linkName;
|
|
|
|
linkName3 += "/";
|
|
|
|
linkName3 += sgIt->GetFullName();
|
|
|
|
|
2016-05-25 00:06:56 +03:00
|
|
|
std::replace(linkName3.begin(), linkName3.end(), '\\', '/');
|
2016-03-31 11:52:43 +03:00
|
|
|
|
|
|
|
this->AppendLinkedResource(xml, linkName3, "virtual:/virtual",
|
|
|
|
VirtualFolder);
|
|
|
|
std::vector<cmSourceGroup> const& children = sgIt->GetGroupChildren();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!children.empty()) {
|
2016-03-31 11:52:43 +03:00
|
|
|
this->WriteGroups(children, linkName, xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-03-31 11:52:43 +03:00
|
|
|
std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<const cmSourceFile*>::const_iterator fileIt =
|
|
|
|
sFiles.begin();
|
|
|
|
fileIt != sFiles.end(); ++fileIt) {
|
2016-03-31 11:52:43 +03:00
|
|
|
std::string fullPath = (*fileIt)->GetFullPath();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(fullPath)) {
|
2016-03-31 11:52:43 +03:00
|
|
|
std::string linkName4 = linkName3;
|
|
|
|
linkName4 += "/";
|
|
|
|
linkName4 += cmSystemTools::GetFilenameName(fullPath);
|
|
|
|
this->AppendLinkedResource(xml, linkName4,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetEclipsePath(fullPath), LinkToFile);
|
2016-03-31 11:52:43 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-03-31 11:52:43 +03:00
|
|
|
}
|
2011-10-23 13:00:45 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
|
2011-10-23 14:22:20 +04:00
|
|
|
{
|
|
|
|
std::string linkName = "[Targets]";
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendLinkedResource(xml, linkName, "virtual:/virtual", VirtualFolder);
|
2011-10-23 14:22:20 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lgIt =
|
|
|
|
this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) {
|
2011-10-23 14:22:20 +04:00
|
|
|
cmMakefile* makefile = (*lgIt)->GetMakefile();
|
2015-10-18 18:06:14 +03:00
|
|
|
const std::vector<cmGeneratorTarget*> targets =
|
2016-05-16 17:34:04 +03:00
|
|
|
(*lgIt)->GetGeneratorTargets();
|
2011-10-23 14:22:20 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
|
|
|
|
ti != targets.end(); ++ti) {
|
2011-10-23 14:22:20 +04:00
|
|
|
std::string linkName2 = linkName;
|
|
|
|
linkName2 += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
switch ((*ti)->GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
case cmState::MODULE_LIBRARY:
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmState::OBJECT_LIBRARY: {
|
|
|
|
const char* prefix =
|
|
|
|
((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] ");
|
2011-10-23 14:22:20 +04:00
|
|
|
linkName2 += prefix;
|
2015-10-18 18:06:14 +03:00
|
|
|
linkName2 += (*ti)->GetName();
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendLinkedResource(xml, linkName2, "virtual:/virtual",
|
2011-10-23 14:22:20 +04:00
|
|
|
VirtualFolder);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GenerateLinkedResources) {
|
2012-10-18 01:45:02 +04:00
|
|
|
break; // skip generating the linked resources to the source files
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::vector<cmSourceGroup> sourceGroups =
|
|
|
|
makefile->GetSourceGroups();
|
2011-10-23 14:22:20 +04:00
|
|
|
// get the files from the source lists then add them to the groups
|
2015-10-18 18:06:14 +03:00
|
|
|
cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(*ti);
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> files;
|
2015-08-29 18:51:15 +03:00
|
|
|
gt->GetSourceFiles(files,
|
2016-05-16 17:34:04 +03:00
|
|
|
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
|
|
|
|
sfIt != files.end(); sfIt++) {
|
2011-10-23 14:22:20 +04:00
|
|
|
// Add the file to the list of sources.
|
|
|
|
std::string source = (*sfIt)->GetFullPath();
|
2014-01-21 19:43:47 +04:00
|
|
|
cmSourceGroup* sourceGroup =
|
2016-05-16 17:34:04 +03:00
|
|
|
makefile->FindSourceGroup(source.c_str(), sourceGroups);
|
2014-01-21 19:43:47 +04:00
|
|
|
sourceGroup->AssignSource(*sfIt);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-23 14:22:20 +04:00
|
|
|
|
2016-03-31 11:52:43 +03:00
|
|
|
this->WriteGroups(sourceGroups, linkName2, xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2011-10-23 14:22:20 +04:00
|
|
|
// ignore all others:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-23 14:22:20 +04:00
|
|
|
}
|
|
|
|
|
2011-10-23 13:00:45 +04:00
|
|
|
void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmXMLWriter& xml, const std::string& baseDir)
|
2011-10-23 13:00:45 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GenerateLinkedResources) {
|
2012-10-18 01:45:02 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-18 01:45:02 +04:00
|
|
|
|
2011-10-23 13:00:45 +04:00
|
|
|
// for each sub project create a linked resource to the source dir
|
|
|
|
// - only if it is an out-of-source build
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AppendLinkedResource(xml, "[Subprojects]", "virtual:/virtual",
|
|
|
|
VirtualFolder);
|
2011-10-23 13:00:45 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
|
2016-05-16 17:34:04 +03:00
|
|
|
it = this->GlobalGenerator->GetProjectMap().begin();
|
|
|
|
it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
|
|
|
|
std::string linkSourceDirectory =
|
|
|
|
this->GetEclipsePath(it->second[0]->GetCurrentSourceDirectory());
|
2011-10-23 13:00:45 +04:00
|
|
|
// a linked resource must not point to a parent directory of .project or
|
|
|
|
// .project itself
|
2011-11-19 14:01:03 +04:00
|
|
|
if ((baseDir != linkSourceDirectory) &&
|
2016-05-16 17:34:04 +03:00
|
|
|
!cmSystemTools::IsSubDirectory(baseDir, linkSourceDirectory)) {
|
2011-10-23 13:00:45 +04:00
|
|
|
std::string linkName = "[Subprojects]/";
|
|
|
|
linkName += it->first;
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendLinkedResource(xml, linkName,
|
2011-10-23 13:00:45 +04:00
|
|
|
this->GetEclipsePath(linkSourceDirectory),
|
2016-05-16 17:34:04 +03:00
|
|
|
LinkToFolder);
|
2012-10-24 00:38:33 +04:00
|
|
|
// Don't add it to the srcLinkedResources, because listing multiple
|
|
|
|
// directories confuses the Eclipse indexer (#13596).
|
2011-10-23 13:00:45 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-23 13:00:45 +04:00
|
|
|
}
|
|
|
|
|
2009-03-13 23:52:58 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
|
|
|
|
std::set<std::string>& emittedDirs)
|
2009-03-13 23:52:58 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator inc = includeDirs.begin();
|
|
|
|
inc != includeDirs.end(); ++inc) {
|
|
|
|
if (!inc->empty()) {
|
2014-10-15 16:54:05 +04:00
|
|
|
std::string dir = cmSystemTools::CollapseFullPath(*inc);
|
2012-08-10 23:45:03 +04:00
|
|
|
|
|
|
|
// handle framework include dirs on OSX, the remainder after the
|
|
|
|
// Frameworks/ part has to be stripped
|
|
|
|
// /System/Library/Frameworks/GLUT.framework/Headers
|
2012-08-17 01:37:15 +04:00
|
|
|
cmsys::RegularExpression frameworkRx("(.+/Frameworks)/.+\\.framework/");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (frameworkRx.find(dir.c_str())) {
|
2012-08-17 01:37:15 +04:00
|
|
|
dir = frameworkRx.match(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-10 23:45:03 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emittedDirs.find(dir) == emittedDirs.end()) {
|
2009-03-13 23:52:58 +03:00
|
|
|
emittedDirs.insert(dir);
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("include",
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExtraEclipseCDT4Generator::GetEclipsePath(dir));
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Attribute("kind", "inc");
|
|
|
|
xml.Attribute("path", "");
|
|
|
|
xml.Attribute("system", "true");
|
|
|
|
xml.EndElement();
|
2009-03-13 23:52:58 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-03-13 23:52:58 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-10-07 01:29:25 +03:00
|
|
|
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
|
|
|
|
const cmMakefile* mf = lg->GetMakefile();
|
2007-08-01 17:18:50 +04:00
|
|
|
|
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());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
2007-08-01 17:18:50 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
cmXMLWriter xml(fout);
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// add header
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartDocument("UTF-8");
|
|
|
|
xml.ProcessingInstruction("fileVersion", "4.0.0");
|
|
|
|
xml.StartElement("cproject");
|
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("cconfiguration");
|
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
// Configuration settings...
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("buildSystemId",
|
2016-05-16 17:34:04 +03:00
|
|
|
"org.eclipse.cdt.core.defaultConfigDataProvider");
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
|
|
|
|
xml.Attribute("name", "Configuration");
|
|
|
|
xml.Element("externalSettings");
|
|
|
|
xml.StartElement("extensions");
|
|
|
|
|
2007-08-17 18:05:39 +04:00
|
|
|
// TODO: refactor this out...
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string executableFormat =
|
|
|
|
mf->GetSafeDefinition("CMAKE_EXECUTABLE_FORMAT");
|
|
|
|
if (executableFormat == "ELF") {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("extension");
|
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.ELF");
|
|
|
|
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
|
|
|
|
xml.EndElement(); // extension
|
|
|
|
|
|
|
|
xml.StartElement("extension");
|
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.GNU_ELF");
|
|
|
|
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
|
|
|
|
AppendAttribute(xml, "addr2line");
|
|
|
|
AppendAttribute(xml, "c++filt");
|
|
|
|
xml.EndElement(); // extension
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-11-22 13:01:04 +03:00
|
|
|
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (systemName == "CYGWIN") {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("extension");
|
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.Cygwin_PE");
|
|
|
|
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
|
|
|
|
AppendAttribute(xml, "addr2line");
|
|
|
|
AppendAttribute(xml, "c++filt");
|
|
|
|
AppendAttribute(xml, "cygpath");
|
|
|
|
AppendAttribute(xml, "nm");
|
|
|
|
xml.EndElement(); // extension
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (systemName == "Windows") {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("extension");
|
|
|
|
xml.Attribute("id", "org.eclipse.cdt.core.PE");
|
|
|
|
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
|
|
|
|
xml.EndElement(); // extension
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (systemName == "Darwin") {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("extension");
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Attribute("id", this->SupportsMachO64Parser
|
|
|
|
? "org.eclipse.cdt.core.MachO64"
|
|
|
|
: "org.eclipse.cdt.core.MachO");
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
|
|
|
|
AppendAttribute(xml, "c++filt");
|
|
|
|
xml.EndElement(); // extension
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-08-01 17:18:50 +04:00
|
|
|
// *** Should never get here ***
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Element("error_toolchain_type");
|
2009-11-22 13:01:04 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-11-22 13:01:04 +03:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // extensions
|
|
|
|
xml.EndElement(); // storageModule
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// ???
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.core.language.mapping");
|
|
|
|
xml.Element("project-mappings");
|
|
|
|
xml.EndElement(); // storageModule
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
// ???
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.core.externalSettings");
|
|
|
|
xml.EndElement(); // storageModule
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
// set the path entries (includes, libs, source dirs, etc.)
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.core.pathentry");
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
/* I don't know what the pathentry kind="src" are good for, e.g.
|
|
|
|
* autocompletion
|
|
|
|
* works also without them. Done wrong, the indexer complains, see #12417
|
|
|
|
* and #12213.
|
|
|
|
* According to #13596, this entry at least limits the directories the
|
|
|
|
* indexer is searching for files. So now the "src" entry contains only
|
|
|
|
* the linked resource to CMAKE_SOURCE_DIR.
|
|
|
|
* The CDT documentation is very terse on that:
|
|
|
|
* "CDT_SOURCE: Entry kind constant describing a path entry identifying a
|
|
|
|
* folder containing source code to be compiled."
|
|
|
|
* Also on the cdt-dev list didn't bring any information:
|
|
|
|
* http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy
|
|
|
|
* Alex */
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator it =
|
|
|
|
this->SrcLinkedResources.begin();
|
|
|
|
it != this->SrcLinkedResources.end(); ++it) {
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("kind", "src");
|
|
|
|
xml.Attribute("path", *it);
|
|
|
|
xml.EndElement();
|
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(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string(this->HomeOutputDirectory + "/" + *it))) {
|
2015-08-02 23:06:38 +03:00
|
|
|
excludeFromOut += *it + "/|";
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-24 00:38:33 +04:00
|
|
|
|
2008-02-20 00:34:49 +03:00
|
|
|
excludeFromOut += "**/CMakeFiles/";
|
2015-08-02 23:06:38 +03:00
|
|
|
|
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("excluding", excludeFromOut);
|
|
|
|
xml.Attribute("kind", "out");
|
|
|
|
xml.Attribute("path", "");
|
|
|
|
xml.EndElement();
|
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();
|
2016-05-16 17:34:04 +03:00
|
|
|
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")) {
|
2008-02-08 00:26:00 +03:00
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
2014-02-10 02:44:21 +04:00
|
|
|
cmGeneratorExpression::Split(cdefs, defs);
|
2008-02-08 00:26:00 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator di = defs.begin();
|
|
|
|
di != defs.end(); ++di) {
|
|
|
|
if (cmGeneratorExpression::Find(*di) != std::string::npos) {
|
2014-02-10 02:44:21 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-10 02:44:21 +04:00
|
|
|
|
2008-02-08 00:26:00 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (equals != std::string::npos && equals < enddef) {
|
2008-02-08 00:26:00 +03:00
|
|
|
// we have -DFOO=BAR
|
|
|
|
def = di->substr(0, equals);
|
|
|
|
val = di->substr(equals + 1, enddef - equals + 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-02-08 00:26:00 +03:00
|
|
|
// we have -DFOO
|
|
|
|
def = *di;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2008-02-08 00:26:00 +03:00
|
|
|
// insert the definition if not already added.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emmited.find(def) == emmited.end()) {
|
2008-02-08 00:26:00 +03:00
|
|
|
emmited.insert(def);
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("kind", "mac");
|
|
|
|
xml.Attribute("name", def);
|
|
|
|
xml.Attribute("path", "");
|
|
|
|
xml.Attribute("value", val);
|
|
|
|
xml.EndElement();
|
2008-02-08 00:26:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-16 22:37:21 +04:00
|
|
|
// add system defined c macros
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cDefs =
|
|
|
|
mf->GetDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
|
|
|
|
if (this->CEnabled && cDefs) {
|
2009-09-16 22:37:21 +04:00
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cDefs, defs, true);
|
|
|
|
|
|
|
|
// the list must contain only definition-value pairs:
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((defs.size() % 2) == 0) {
|
2009-09-16 22:37:21 +04:00
|
|
|
std::vector<std::string>::const_iterator di = defs.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
while (di != defs.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
std::string def = *di;
|
|
|
|
++di;
|
|
|
|
std::string val;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (di != defs.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
val = *di;
|
|
|
|
++di;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-16 22:37:21 +04:00
|
|
|
|
|
|
|
// insert the definition if not already added.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emmited.find(def) == emmited.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
emmited.insert(def);
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("kind", "mac");
|
|
|
|
xml.Attribute("name", def);
|
|
|
|
xml.Attribute("path", "");
|
|
|
|
xml.Attribute("value", val);
|
|
|
|
xml.EndElement();
|
2009-09-16 22:37:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-16 22:37:21 +04:00
|
|
|
// add system defined c++ macros
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cxxDefs =
|
|
|
|
mf->GetDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
|
|
|
|
if (this->CXXEnabled && cxxDefs) {
|
2009-09-16 22:37:21 +04:00
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cxxDefs, defs, true);
|
|
|
|
|
|
|
|
// the list must contain only definition-value pairs:
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((defs.size() % 2) == 0) {
|
2009-09-16 22:37:21 +04:00
|
|
|
std::vector<std::string>::const_iterator di = defs.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
while (di != defs.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
std::string def = *di;
|
|
|
|
++di;
|
|
|
|
std::string val;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (di != defs.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
val = *di;
|
|
|
|
++di;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-16 22:37:21 +04:00
|
|
|
|
|
|
|
// insert the definition if not already added.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emmited.find(def) == emmited.end()) {
|
2009-09-16 22:37:21 +04:00
|
|
|
emmited.insert(def);
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("pathentry");
|
|
|
|
xml.Attribute("kind", "mac");
|
|
|
|
xml.Attribute("name", def);
|
|
|
|
xml.Attribute("path", "");
|
|
|
|
xml.Attribute("value", val);
|
|
|
|
xml.EndElement();
|
2009-09-16 22:37:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-08 00:26:00 +03:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// include dirs
|
|
|
|
emmited.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator it =
|
|
|
|
this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
|
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
l != targets.end(); ++l) {
|
2011-11-05 19:17:49 +04:00
|
|
|
std::vector<std::string> includeDirs;
|
2014-06-23 17:34:38 +04:00
|
|
|
std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2015-10-18 17:53:00 +03:00
|
|
|
(*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendIncludeDirectories(xml, includeDirs, emmited);
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03: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.
|
|
|
|
std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CEnabled && !compiler.empty()) {
|
|
|
|
std::string systemIncludeDirs =
|
|
|
|
mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
|
2009-03-13 23:52:58 +03:00
|
|
|
std::vector<std::string> dirs;
|
2014-03-11 03:04:11 +04:00
|
|
|
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendIncludeDirectories(xml, dirs, emmited);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-03-13 23:52:58 +03:00
|
|
|
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CXXEnabled && !compiler.empty()) {
|
|
|
|
std::string systemIncludeDirs =
|
|
|
|
mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
|
2009-03-13 23:52:58 +03:00
|
|
|
std::vector<std::string> dirs;
|
2014-03-11 03:04:11 +04:00
|
|
|
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendIncludeDirectories(xml, dirs, emmited);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-03-13 23:52:58 +03:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // storageModule
|
2007-08-01 17:18:50 +04:00
|
|
|
|
|
|
|
// add build targets
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets");
|
|
|
|
xml.StartElement("buildTargets");
|
2007-08-01 17:18:50 +04:00
|
|
|
emmited.clear();
|
2007-08-17 18:05:39 +04:00
|
|
|
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string makeArgs =
|
|
|
|
mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS");
|
2011-10-23 14:25:33 +04:00
|
|
|
|
2016-05-16 17:34:04 +03: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generator->GetAllTargetName()) {
|
2009-09-17 02:01:23 +04:00
|
|
|
allTarget = generator->GetAllTargetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (generator->GetCleanTargetName()) {
|
2009-09-17 02:01:23 +04:00
|
|
|
cleanTarget = generator->GetCleanTargetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator it =
|
|
|
|
this->GlobalGenerator->GetLocalGenerators().begin();
|
|
|
|
it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
|
2015-10-18 18:06:14 +03:00
|
|
|
const std::vector<cmGeneratorTarget*> targets =
|
2016-05-16 17:34:04 +03:00
|
|
|
(*it)->GetGeneratorTargets();
|
2016-08-27 14:44:56 +03:00
|
|
|
std::string subdir = (*it)->ConvertToRelativePath(
|
|
|
|
(*it)->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (subdir == ".") {
|
2009-09-17 02:01:23 +04:00
|
|
|
subdir = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-17 02:01:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
|
|
|
|
ti != targets.end(); ++ti) {
|
2015-10-18 18:06:14 +03:00
|
|
|
std::string targetName = (*ti)->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
switch ((*ti)->GetType()) {
|
|
|
|
case cmState::GLOBAL_TARGET: {
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (subdir.empty()) {
|
|
|
|
this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
|
2011-10-23 14:25:33 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
|
|
|
case cmState::UTILITY:
|
|
|
|
// Add all utility targets, except the Nightly/Continuous/
|
|
|
|
// Experimental-"sub"targets as e.g. NightlyStart
|
|
|
|
if (((targetName.find("Nightly") == 0) &&
|
|
|
|
(targetName != "Nightly")) ||
|
|
|
|
((targetName.find("Continuous") == 0) &&
|
|
|
|
(targetName != "Continuous")) ||
|
|
|
|
((targetName.find("Experimental") == 0) &&
|
|
|
|
(targetName != "Experimental"))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
|
|
|
|
break;
|
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
case cmState::MODULE_LIBRARY:
|
|
|
|
case cmState::OBJECT_LIBRARY: {
|
|
|
|
const char* prefix =
|
|
|
|
((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] ");
|
|
|
|
this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix);
|
|
|
|
std::string fastTarget = targetName;
|
|
|
|
fastTarget += "/fast";
|
|
|
|
this->AppendTarget(xml, fastTarget, make, makeArgs, subdir, prefix);
|
|
|
|
|
|
|
|
// Add Build and Clean targets in the virtual folder of targets:
|
|
|
|
if (this->SupportsVirtualFolders) {
|
|
|
|
std::string virtDir = "[Targets]/";
|
|
|
|
virtDir += prefix;
|
|
|
|
virtDir += targetName;
|
|
|
|
std::string buildArgs = "-C \"";
|
|
|
|
buildArgs += (*it)->GetBinaryDirectory();
|
|
|
|
buildArgs += "\" ";
|
|
|
|
buildArgs += makeArgs;
|
|
|
|
this->AppendTarget(xml, "Build", make, buildArgs, virtDir, "",
|
|
|
|
targetName.c_str());
|
|
|
|
|
|
|
|
std::string cleanArgs = "-E chdir \"";
|
|
|
|
cleanArgs += (*it)->GetCurrentBinaryDirectory();
|
|
|
|
cleanArgs += "\" \"";
|
|
|
|
cleanArgs += cmSystemTools::GetCMakeCommand();
|
|
|
|
cleanArgs += "\" -P \"";
|
|
|
|
cmGeneratorTarget* gt = *ti;
|
|
|
|
cleanArgs += (*it)->GetTargetDirectory(gt);
|
|
|
|
cleanArgs += "/cmake_clean.cmake\"";
|
|
|
|
this->AppendTarget(xml, "Clean", cmSystemTools::GetCMakeCommand(),
|
|
|
|
cleanArgs, virtDir, "", "");
|
|
|
|
}
|
|
|
|
} break;
|
2007-11-25 15:40:57 +03:00
|
|
|
default:
|
|
|
|
break;
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03: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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!allTarget.empty()) {
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendTarget(xml, allTarget, make, makeArgs, subdir, ": ");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cleanTarget.empty()) {
|
2015-08-02 23:06:38 +03:00
|
|
|
this->AppendTarget(xml, cleanTarget, make, makeArgs, subdir, ": ");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-17 02:01:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// insert rules for compiling, preprocessing and assembling individual
|
|
|
|
// files
|
2009-09-17 02:01:23 +04:00
|
|
|
std::vector<std::string> objectFileTargets;
|
2012-06-15 14:14:13 +04:00
|
|
|
(*it)->GetIndividualFileTargets(objectFileTargets);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fit =
|
|
|
|
objectFileTargets.begin();
|
|
|
|
fit != objectFileTargets.end(); ++fit) {
|
2009-09-17 02:01:23 +04:00
|
|
|
const char* prefix = "[obj] ";
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((*fit)[fit->length() - 1] == 's') {
|
2009-09-17 02:01:23 +04:00
|
|
|
prefix = "[to asm] ";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((*fit)[fit->length() - 1] == 'i') {
|
2009-09-17 02:01:23 +04:00
|
|
|
prefix = "[pre] ";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AppendTarget(xml, *fit, make, makeArgs, subdir, prefix);
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-17 02:01:23 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // buildTargets
|
|
|
|
xml.EndElement(); // storageModule
|
|
|
|
|
|
|
|
this->AppendStorageScanners(xml, *mf);
|
|
|
|
|
|
|
|
xml.EndElement(); // cconfiguration
|
|
|
|
xml.EndElement(); // storageModule
|
|
|
|
|
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "cdtBuildSystem");
|
|
|
|
xml.Attribute("version", "4.0.0");
|
|
|
|
|
|
|
|
xml.StartElement("project");
|
|
|
|
xml.Attribute("id", std::string(lg->GetProjectName()) + ".null.1");
|
|
|
|
xml.Attribute("name", lg->GetProjectName());
|
|
|
|
xml.EndElement(); // project
|
|
|
|
|
|
|
|
xml.EndElement(); // storageModule
|
|
|
|
xml.EndElement(); // cproject
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out, &out)) {
|
2007-08-01 17:18:50 +04:00
|
|
|
return path;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-08-01 17:18:50 +04:00
|
|
|
out.erase(out.find_last_of('\n'));
|
|
|
|
return out;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-01 17:18:50 +04:00
|
|
|
#else
|
|
|
|
return path;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmExtraEclipseCDT4Generator::GetPathBasename(
|
|
|
|
const std::string& path)
|
2007-08-17 18:05:39 +04:00
|
|
|
{
|
|
|
|
std::string outputBasename = path;
|
2015-01-15 02:06:11 +03:00
|
|
|
while (!outputBasename.empty() &&
|
2007-08-17 18:05:39 +04:00
|
|
|
(outputBasename[outputBasename.size() - 1] == '/' ||
|
2016-05-16 17:34:04 +03:00
|
|
|
outputBasename[outputBasename.size() - 1] == '\\')) {
|
2007-08-17 18:05:39 +04:00
|
|
|
outputBasename.resize(outputBasename.size() - 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-17 18:05:39 +04:00
|
|
|
std::string::size_type loc = outputBasename.find_last_of("/\\");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (loc != std::string::npos) {
|
2007-08-17 18:05:39 +04:00
|
|
|
outputBasename = outputBasename.substr(loc + 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-17 18:05:39 +04:00
|
|
|
|
|
|
|
return outputBasename;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmExtraEclipseCDT4Generator::GenerateProjectName(
|
|
|
|
const std::string& name, const std::string& type, const std::string& path)
|
2008-02-19 23:07:28 +03:00
|
|
|
{
|
2015-08-02 23:06:38 +03:00
|
|
|
return name + (type.empty() ? "" : "-") + type + "@" + path;
|
2009-01-09 02:09:50 +03:00
|
|
|
}
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
// Helper functions
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendStorageScanners(
|
|
|
|
cmXMLWriter& xml, 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");
|
2011-10-01 21:09:24 +04:00
|
|
|
std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (compiler.empty()) {
|
2009-01-10 02:58:21 +03:00
|
|
|
compiler = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER");
|
2011-10-01 21:09:24 +04:00
|
|
|
arg1 = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER_ARG1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (compiler.empty()) // Hmm, what to do now ?
|
|
|
|
{
|
2009-01-10 02:58:21 +03:00
|
|
|
compiler = "gcc";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-10 02:58:21 +03:00
|
|
|
|
|
|
|
// the following right now hardcodes gcc behaviour :-/
|
2011-10-01 21:09:24 +04:00
|
|
|
std::string compilerArgs =
|
2016-05-16 17:34:04 +03:00
|
|
|
"-E -P -v -dD ${plugin_state_location}/${specs_file}";
|
|
|
|
if (!arg1.empty()) {
|
2011-10-01 21:09:24 +04:00
|
|
|
arg1 += " ";
|
|
|
|
compilerArgs = arg1 + compilerArgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-01 21:09:24 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("storageModule");
|
|
|
|
xml.Attribute("moduleId", "scannerConfiguration");
|
|
|
|
|
|
|
|
xml.StartElement("autodiscovery");
|
|
|
|
xml.Attribute("enabled", "true");
|
|
|
|
xml.Attribute("problemReportingEnabled", "true");
|
|
|
|
xml.Attribute("selectedProfileId",
|
2016-05-16 17:34:04 +03:00
|
|
|
"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile");
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // autodiscovery
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(
|
|
|
|
xml, "org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile", true,
|
|
|
|
"", true, "specsFile", compilerArgs, compiler, true, true);
|
|
|
|
cmExtraEclipseCDT4Generator::AppendScannerProfile(
|
|
|
|
xml, "org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile", true, "",
|
|
|
|
true, "makefileGenerator", "-f ${project_name}_scd.mk", make, true, true);
|
2007-08-01 17:18:50 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.EndElement(); // storageModule
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendTarget(
|
|
|
|
cmXMLWriter& xml, const std::string& target, const std::string& make,
|
|
|
|
const std::string& makeArgs, const std::string& path, const char* prefix,
|
|
|
|
const char* makeTarget)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("target");
|
|
|
|
xml.Attribute("name", prefix + target);
|
|
|
|
xml.Attribute("path", path);
|
|
|
|
xml.Attribute("targetID", "org.eclipse.cdt.make.MakeTargetBuilder");
|
|
|
|
xml.Element("buildCommand",
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExtraEclipseCDT4Generator::GetEclipsePath(make));
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.Element("buildArguments", makeArgs);
|
|
|
|
xml.Element("buildTarget", makeTarget ? makeTarget : target.c_str());
|
|
|
|
xml.Element("stopOnError", "true");
|
|
|
|
xml.Element("useDefaultCommand", "false");
|
|
|
|
xml.EndElement();
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendScannerProfile(
|
|
|
|
cmXMLWriter& xml, 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, bool sipParserEnabled)
|
2007-08-01 17:18:50 +04:00
|
|
|
{
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("profile");
|
|
|
|
xml.Attribute("id", profileID);
|
|
|
|
|
|
|
|
xml.StartElement("buildOutputProvider");
|
|
|
|
xml.StartElement("openAction");
|
|
|
|
xml.Attribute("enabled", openActionEnabled ? "true" : "false");
|
|
|
|
xml.Attribute("filePath", openActionFilePath);
|
|
|
|
xml.EndElement(); // openAction
|
|
|
|
xml.StartElement("parser");
|
|
|
|
xml.Attribute("enabled", pParserEnabled ? "true" : "false");
|
|
|
|
xml.EndElement(); // parser
|
|
|
|
xml.EndElement(); // buildOutputProvider
|
|
|
|
|
|
|
|
xml.StartElement("scannerInfoProvider");
|
|
|
|
xml.Attribute("id", scannerInfoProviderID);
|
|
|
|
xml.StartElement("runAction");
|
|
|
|
xml.Attribute("arguments", runActionArguments);
|
|
|
|
xml.Attribute("command", runActionCommand);
|
|
|
|
xml.Attribute("useDefault", runActionUseDefault ? "true" : "false");
|
|
|
|
xml.EndElement(); // runAction
|
|
|
|
xml.StartElement("parser");
|
|
|
|
xml.Attribute("enabled", sipParserEnabled ? "true" : "false");
|
|
|
|
xml.EndElement(); // parser
|
|
|
|
xml.EndElement(); // scannerInfoProvider
|
|
|
|
|
|
|
|
xml.EndElement(); // profile
|
2007-08-01 17:18:50 +04:00
|
|
|
}
|
2008-02-20 00:27:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmExtraEclipseCDT4Generator::AppendLinkedResource(cmXMLWriter& xml,
|
|
|
|
const std::string& name,
|
|
|
|
const std::string& path,
|
|
|
|
LinkType linkType)
|
2008-02-20 00:27:03 +03:00
|
|
|
{
|
2011-05-07 00:44:45 +04:00
|
|
|
const char* locationTag = "location";
|
2015-08-02 23:06:38 +03:00
|
|
|
int typeTag = 2;
|
2011-10-20 00:02:14 +04:00
|
|
|
if (linkType == VirtualFolder) // ... and not a linked folder
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2011-05-07 00:44:45 +04:00
|
|
|
locationTag = "locationURI";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (linkType == LinkToFile) {
|
2015-08-02 23:06:38 +03:00
|
|
|
typeTag = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-05-07 00:44:45 +04:00
|
|
|
|
2015-08-02 23:06:38 +03:00
|
|
|
xml.StartElement("link");
|
|
|
|
xml.Element("name", name);
|
|
|
|
xml.Element("type", typeTag);
|
|
|
|
xml.Element(locationTag, path);
|
|
|
|
xml.EndElement();
|
2008-02-20 00:27:03 +03:00
|
|
|
}
|