[Cmake-commits] CMake branch, next, updated. v2.8.6-1623-gc7c561d
Alexander Neundorf
neundorf at kde.org
Sun Oct 23 09:04:07 EDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via c7c561db73327d16293ecfc9620bee28c43640c1 (commit)
via 66bd543b9b0b09d38697f2c321dda7e4aeb6916d (commit)
via 70de8bd5ae95936b8187e1af707e2d0111c74329 (commit)
via 117f2b8257d92328b32cb90ced3d85d88815130b (commit)
via c3f30bdd63682b4ba7166e23b3b3dc38548aab07 (commit)
via cef6bd94d76a24c5948fea0224a78217f34c0b23 (commit)
via b6d4de7911c5d54c087d5616660ee7e4050da834 (commit)
from f973e10b58af9e6820c852477fc1d4423023c8b9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7c561db73327d16293ecfc9620bee28c43640c1
commit c7c561db73327d16293ecfc9620bee28c43640c1
Merge: f973e10 66bd543
Author: Alexander Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 09:03:54 2011 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Oct 23 09:03:54 2011 -0400
Merge topic 'SourceGroupsForEclipse' into next
66bd543 Eclipse: fix #12417, don't create wrong src pathentries
70de8bd Eclipse: detect number of CPUs, set CMAKE_ECLIPSE_MAKE_ARGUMENTS accordigly
117f2b8 Eclipse: add Build and Clean targets to targets
c3f30bd Eclipse: move code for generating links to targets into separate function
cef6bd9 Eclipse: move code for generating links to projects into separate function
b6d4de7 Eclipse: add virtual folder for each target
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=66bd543b9b0b09d38697f2c321dda7e4aeb6916d
commit 66bd543b9b0b09d38697f2c321dda7e4aeb6916d
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 14:58:52 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Oct 23 14:58:52 2011 +0200
Eclipse: fix #12417, don't create wrong src pathentries
Actually the Eclipse generator now does not create any CDT_SOURCE
pathentries anymore, since I was not able to find out what they are
good for, not even by asking on the cdt-dev mailing list.
So, at least the warning from eclipse about bad pathentries are gone
this way, and I didn't see anything which was not working anymore.
Let's see whether we can find out what they are good for.
Alex
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index a847666..785e85a 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -695,6 +695,18 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// - make it type 'src'
// - and exclude it from type 'out'
std::string excludeFromOut;
+/* 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.
+ * 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
+ * So I'm disabling them for now, hoping that somebody will report if something
+ * is not workging anymore.
+ * Alex */
+#ifdef DO_CREATE_SRC_PATH_ENTRIES
for (std::vector<std::string>::const_iterator
it = this->SrcLinkedResources.begin();
it != this->SrcLinkedResources.end();
@@ -711,6 +723,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
excludeFromOut += this->EscapeForXML(*it) + "/|";
}
}
+#endif
excludeFromOut += "**/CMakeFiles/";
fout << "<pathentry excluding=\"" << excludeFromOut
<< "\" kind=\"out\" path=\"\"/>\n";
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=70de8bd5ae95936b8187e1af707e2d0111c74329
commit 70de8bd5ae95936b8187e1af707e2d0111c74329
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 14:33:25 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Oct 23 14:33:25 2011 +0200
Eclipse: detect number of CPUs, set CMAKE_ECLIPSE_MAKE_ARGUMENTS accordigly
Using the new module ProcessorCount.cmake now the number of CPUs is
detected, and if it is bigger than 1, make -jX is set accordingly.
Alex
diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake
index cf0984e..f7a6e29 100644
--- a/Modules/CMakeFindEclipseCDT4.cmake
+++ b/Modules/CMakeFindEclipseCDT4.cmake
@@ -54,8 +54,20 @@ ENDFUNCTION()
_FIND_ECLIPSE_VERSION()
+# Try to find out how many CPUs we have and set the -j argument for make accordingly
+SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "")
+
+INCLUDE(ProcessorCount)
+PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT)
+
+# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name
+# (we may also get here in the future e.g. for ninja)
+IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make)
+ SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}")
+ENDIF()
+
# This variable is used by the Eclipse generator and appended to the make invocation commands.
-SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds")
+SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds")
# This variable is used by the Eclipse generator in out-of-source builds only.
SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=117f2b8257d92328b32cb90ced3d85d88815130b
commit 117f2b8257d92328b32cb90ced3d85d88815130b
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 12:25:33 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Oct 23 12:25:33 2011 +0200
Eclipse: add Build and Clean targets to targets
With this commit the virtual folder for the targets now
have "Build" and "Clean" targets associated to them, so you can
build and clean per-target now in the project explorer.
Alex
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 9fc9e16..a847666 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -888,6 +888,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_ECLIPSE_MAKE_ARGUMENTS");
+ const std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND");
+
cmGlobalGenerator* generator
= const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
@@ -976,6 +978,25 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::string fastTarget = ti->first;
fastTarget += "/fast";
this->AppendTarget(fout, 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 += ti->first;
+ this->AppendTarget(fout, "Build", make, makeArgs, virtDir, "",
+ ti->first.c_str());
+
+ std::string cleanArgs = "-E chdir \"";
+ cleanArgs += makefile->GetCurrentOutputDirectory();
+ cleanArgs += "\" \"";
+ cleanArgs += cmake;
+ cleanArgs += "\" -P \"";
+ cleanArgs += (*it)->GetTargetDirectory(ti->second);
+ cleanArgs += "/cmake_clean.cmake\"";
+ this->AppendTarget(fout, "Clean", cmake, cleanArgs, virtDir, "", "");
+ }
}
break;
// ignore these:
@@ -1160,9 +1181,17 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
const std::string& make,
const std::string& makeArgs,
const std::string& path,
- const char* prefix)
+ const char* prefix,
+ const char* makeTarget
+ )
{
std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target);
+ std::string makeTargetXml = targetXml;
+ if (makeTarget != NULL)
+ {
+ makeTargetXml = cmExtraEclipseCDT4Generator::EscapeForXML(makeTarget);
+ }
+ cmExtraEclipseCDT4Generator::EscapeForXML(target);
std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
fout <<
"<target name=\"" << prefix << targetXml << "\""
@@ -1172,7 +1201,7 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
<< cmExtraEclipseCDT4Generator::GetEclipsePath(make)
<< "</buildCommand>\n"
"<buildArguments>" << makeArgs << "</buildArguments>\n"
- "<buildTarget>" << targetXml << "</buildTarget>\n"
+ "<buildTarget>" << makeTargetXml << "</buildTarget>\n"
"<stopOnError>true</stopOnError>\n"
"<useDefaultCommand>false</useDefaultCommand>\n"
"</target>\n"
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index ac2de16..61302e7 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -75,7 +75,8 @@ private:
const std::string& make,
const std::string& makeArguments,
const std::string& path,
- const char* prefix = "");
+ const char* prefix = "",
+ const char* makeTarget = NULL);
static void AppendScannerProfile (cmGeneratedFileStream& fout,
const std::string& profileID,
bool openActionEnabled,
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3f30bdd63682b4ba7166e23b3b3dc38548aab07
commit c3f30bdd63682b4ba7166e23b3b3dc38548aab07
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 12:22:20 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Oct 23 12:22:20 2011 +0200
Eclipse: move code for generating links to targets into separate function
Alex
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index c1a810b..9fc9e16 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -426,85 +426,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
{
this->CreateLinksToSubprojects(fout);
- std::string linkName = "[Targets]";
- this->AppendLinkedResource(fout, linkName, "virtual:/virtual",
- VirtualFolder);
-
-
- for (std::vector<cmLocalGenerator*>::const_iterator
- lgIt = this->GlobalGenerator->GetLocalGenerators().begin();
- lgIt != this->GlobalGenerator->GetLocalGenerators().end();
- ++lgIt)
- {
- cmMakefile* makefile = (*lgIt)->GetMakefile();
- const cmTargets& targets = makefile->GetTargets();
-
- for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti)
- {
- std::string linkName2 = linkName;
- linkName2 += "/";
- switch(ti->second.GetType())
- {
- case cmTarget::EXECUTABLE:
- case cmTarget::STATIC_LIBRARY:
- case cmTarget::SHARED_LIBRARY:
- case cmTarget::MODULE_LIBRARY:
- {
- const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ?
- "[exe] " : "[lib] ");
- linkName2 += prefix;
- linkName2 += ti->first;
- this->AppendLinkedResource(fout, linkName2, "virtual:/virtual",
- VirtualFolder);
- std::vector<cmSourceGroup> sourceGroups =
- makefile->GetSourceGroups();
- // get the files from the source lists then add them to the groups
- cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
- std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles();
- for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
- sfIt != files.end();
- sfIt++)
- {
- // Add the file to the list of sources.
- std::string source = (*sfIt)->GetFullPath();
- cmSourceGroup& sourceGroup =
- makefile->FindSourceGroup(source.c_str(), sourceGroups);
- sourceGroup.AssignSource(*sfIt);
- }
-
-
- for(std::vector<cmSourceGroup>::iterator sgIt=sourceGroups.begin();
- sgIt != sourceGroups.end();
- ++sgIt)
- {
- std::string linkName3 = linkName2;
- linkName3 += "/";
- linkName3 += sgIt->GetFullName();
- this->AppendLinkedResource(fout, linkName3, "virtual:/virtual",
- VirtualFolder);
-
- std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
- for(std::vector<const cmSourceFile*>::const_iterator fileIt =
- sFiles.begin();
- fileIt != sFiles.end();
- ++fileIt)
- {
- std::string linkName4 = linkName3;
- linkName4 += "/";
- linkName4 +=
- cmSystemTools::GetFilenameName((*fileIt)->GetFullPath());
- this->AppendLinkedResource(fout, linkName4,
- (*fileIt)->GetFullPath(), LinkToFile);
- }
- }
- }
- break;
- // ignore all others:
- default:
- break;
- }
- }
- }
+ this->CreateLinksForTargets(fout);
}
// I'm not sure this makes too much sense. There can be different
@@ -526,6 +448,88 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
//----------------------------------------------------------------------------
+void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
+ cmGeneratedFileStream& fout)
+{
+ std::string linkName = "[Targets]";
+ this->AppendLinkedResource(fout, linkName, "virtual:/virtual",VirtualFolder);
+
+ for (std::vector<cmLocalGenerator*>::const_iterator
+ lgIt = this->GlobalGenerator->GetLocalGenerators().begin();
+ lgIt != this->GlobalGenerator->GetLocalGenerators().end();
+ ++lgIt)
+ {
+ cmMakefile* makefile = (*lgIt)->GetMakefile();
+ const cmTargets& targets = makefile->GetTargets();
+
+ for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti)
+ {
+ std::string linkName2 = linkName;
+ linkName2 += "/";
+ switch(ti->second.GetType())
+ {
+ case cmTarget::EXECUTABLE:
+ case cmTarget::STATIC_LIBRARY:
+ case cmTarget::SHARED_LIBRARY:
+ case cmTarget::MODULE_LIBRARY:
+ {
+ const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ?
+ "[exe] " : "[lib] ");
+ linkName2 += prefix;
+ linkName2 += ti->first;
+ this->AppendLinkedResource(fout, linkName2, "virtual:/virtual",
+ VirtualFolder);
+ std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups();
+ // get the files from the source lists then add them to the groups
+ cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
+ std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles();
+ for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
+ sfIt != files.end();
+ sfIt++)
+ {
+ // Add the file to the list of sources.
+ std::string source = (*sfIt)->GetFullPath();
+ cmSourceGroup& sourceGroup =
+ makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ sourceGroup.AssignSource(*sfIt);
+ }
+
+ for(std::vector<cmSourceGroup>::iterator sgIt = sourceGroups.begin();
+ sgIt != sourceGroups.end();
+ ++sgIt)
+ {
+ std::string linkName3 = linkName2;
+ linkName3 += "/";
+ linkName3 += sgIt->GetFullName();
+ this->AppendLinkedResource(fout, linkName3, "virtual:/virtual",
+ VirtualFolder);
+
+ std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
+ for(std::vector<const cmSourceFile*>::const_iterator fileIt =
+ sFiles.begin();
+ fileIt != sFiles.end();
+ ++fileIt)
+ {
+ std::string linkName4 = linkName3;
+ linkName4 += "/";
+ linkName4 +=
+ cmSystemTools::GetFilenameName((*fileIt)->GetFullPath());
+ this->AppendLinkedResource(fout, linkName4,
+ (*fileIt)->GetFullPath(), LinkToFile);
+ }
+ }
+ }
+ break;
+ // ignore all others:
+ default:
+ break;
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
cmGeneratedFileStream& fout)
{
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index 5a1a453..ac2de16 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -104,7 +104,7 @@ private:
cmMakefile* mf);
void CreateLinksToSubprojects(cmGeneratedFileStream& fout);
-
+ void CreateLinksForTargets(cmGeneratedFileStream& fout);
std::vector<std::string> SrcLinkedResources;
std::vector<std::string> OutLinkedResources;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cef6bd94d76a24c5948fea0224a78217f34c0b23
commit cef6bd94d76a24c5948fea0224a78217f34c0b23
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Oct 23 11:00:45 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Oct 23 11:00:45 2011 +0200
Eclipse: move code for generating links to projects into separate function
Alex
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 3f63646..c1a810b 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -424,33 +424,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
if (this->SupportsVirtualFolders)
{
- // 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]",
- "virtual:/virtual", VirtualFolder);
-
- 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),
- LinkToFolder
- );
- this->SrcLinkedResources.push_back(it->first);
- }
- }
+ this->CreateLinksToSubprojects(fout);
std::string linkName = "[Targets]";
this->AppendLinkedResource(fout, linkName, "virtual:/virtual",
@@ -550,6 +524,41 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
fout << "</projectDescription>\n";
}
+
+//----------------------------------------------------------------------------
+void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
+ cmGeneratedFileStream& fout)
+{
+ // 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]",
+ "virtual:/virtual", VirtualFolder);
+
+ 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),
+ LinkToFolder
+ );
+ this->SrcLinkedResources.push_back(it->first);
+ }
+ }
+}
+
+
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
cmGeneratedFileStream& fout,
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index 2c7aa43..5a1a453 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -103,6 +103,9 @@ private:
static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
cmMakefile* mf);
+ void CreateLinksToSubprojects(cmGeneratedFileStream& fout);
+
+
std::vector<std::string> SrcLinkedResources;
std::vector<std::string> OutLinkedResources;
std::string HomeDirectory;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b6d4de7911c5d54c087d5616660ee7e4050da834
commit b6d4de7911c5d54c087d5616660ee7e4050da834
Author: Alex Neundorf <neundorf at kde.org>
AuthorDate: Wed Oct 19 22:02:14 2011 +0200
Commit: Alex Neundorf <neundorf at kde.org>
CommitDate: Wed Oct 19 22:02:14 2011 +0200
Eclipse: add virtual folder for each target
For each target a virtual folder is created, which contains
one virtual folder for each sourcegroup, which contain
links to the actual source files (#12294, #12223)
Alex
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index f303f16..3f63646 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -17,6 +17,7 @@
#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmTarget.h"
+#include "cmSourceFile.h"
#include "cmSystemTools.h"
#include <stdlib.h>
@@ -414,7 +415,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
linkSourceDirectory.c_str()))
{
this->AppendLinkedResource(fout, sourceLinkedResourceName,
- this->GetEclipsePath(linkSourceDirectory));
+ this->GetEclipsePath(linkSourceDirectory),
+ LinkToFolder);
this->SrcLinkedResources.push_back(sourceLinkedResourceName);
}
@@ -425,7 +427,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
// 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]",
- "virtual:/virtual", true);
+ "virtual:/virtual", VirtualFolder);
for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
@@ -443,10 +445,92 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
std::string linkName = "[Subprojects]/";
linkName += it->first;
this->AppendLinkedResource(fout, linkName,
- this->GetEclipsePath(linkSourceDirectory));
+ this->GetEclipsePath(linkSourceDirectory),
+ LinkToFolder
+ );
this->SrcLinkedResources.push_back(it->first);
}
}
+
+ std::string linkName = "[Targets]";
+ this->AppendLinkedResource(fout, linkName, "virtual:/virtual",
+ VirtualFolder);
+
+
+ for (std::vector<cmLocalGenerator*>::const_iterator
+ lgIt = this->GlobalGenerator->GetLocalGenerators().begin();
+ lgIt != this->GlobalGenerator->GetLocalGenerators().end();
+ ++lgIt)
+ {
+ cmMakefile* makefile = (*lgIt)->GetMakefile();
+ const cmTargets& targets = makefile->GetTargets();
+
+ for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti)
+ {
+ std::string linkName2 = linkName;
+ linkName2 += "/";
+ switch(ti->second.GetType())
+ {
+ case cmTarget::EXECUTABLE:
+ case cmTarget::STATIC_LIBRARY:
+ case cmTarget::SHARED_LIBRARY:
+ case cmTarget::MODULE_LIBRARY:
+ {
+ const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ?
+ "[exe] " : "[lib] ");
+ linkName2 += prefix;
+ linkName2 += ti->first;
+ this->AppendLinkedResource(fout, linkName2, "virtual:/virtual",
+ VirtualFolder);
+ std::vector<cmSourceGroup> sourceGroups =
+ makefile->GetSourceGroups();
+ // get the files from the source lists then add them to the groups
+ cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
+ std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles();
+ for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
+ sfIt != files.end();
+ sfIt++)
+ {
+ // Add the file to the list of sources.
+ std::string source = (*sfIt)->GetFullPath();
+ cmSourceGroup& sourceGroup =
+ makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ sourceGroup.AssignSource(*sfIt);
+ }
+
+
+ for(std::vector<cmSourceGroup>::iterator sgIt=sourceGroups.begin();
+ sgIt != sourceGroups.end();
+ ++sgIt)
+ {
+ std::string linkName3 = linkName2;
+ linkName3 += "/";
+ linkName3 += sgIt->GetFullName();
+ this->AppendLinkedResource(fout, linkName3, "virtual:/virtual",
+ VirtualFolder);
+
+ std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
+ for(std::vector<const cmSourceFile*>::const_iterator fileIt =
+ sFiles.begin();
+ fileIt != sFiles.end();
+ ++fileIt)
+ {
+ std::string linkName4 = linkName3;
+ linkName4 += "/";
+ linkName4 +=
+ cmSystemTools::GetFilenameName((*fileIt)->GetFullPath());
+ this->AppendLinkedResource(fout, linkName4,
+ (*fileIt)->GetFullPath(), LinkToFile);
+ }
+ }
+ }
+ break;
+ // ignore all others:
+ default:
+ break;
+ }
+ }
+ }
}
// I'm not sure this makes too much sense. There can be different
@@ -1115,20 +1199,25 @@ void cmExtraEclipseCDT4Generator
::AppendLinkedResource (cmGeneratedFileStream& fout,
const std::string& name,
const std::string& path,
- bool isVirtualFolder)
+ LinkType linkType)
{
const char* locationTag = "location";
- if (isVirtualFolder) // ... and not a linked folder
+ const char* typeTag = "2";
+ if (linkType == VirtualFolder) // ... and not a linked folder
{
locationTag = "locationURI";
}
+ if (linkType == LinkToFile)
+ {
+ typeTag = "1";
+ }
fout <<
"\t\t<link>\n"
"\t\t\t<name>"
<< cmExtraEclipseCDT4Generator::EscapeForXML(name)
<< "</name>\n"
- "\t\t\t<type>2</type>\n"
+ "\t\t\t<type>" << typeTag << "</type>\n"
"\t\t\t<" << locationTag << ">"
<< cmExtraEclipseCDT4Generator::EscapeForXML(path)
<< "</" << locationTag << ">\n"
@@ -1177,7 +1266,7 @@ bool cmExtraEclipseCDT4Generator
else
{
this->AppendLinkedResource(fout, name,
- this->GetEclipsePath(outputPath));
+ this->GetEclipsePath(outputPath), LinkToFolder);
this->OutLinkedResources.push_back(name);
return true;
}
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index b866619..2c7aa43 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -25,6 +25,8 @@ class cmGeneratedFileStream;
class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator
{
public:
+ enum LinkType {VirtualFolder, LinkToFolder, LinkToFile };
+
cmExtraEclipseCDT4Generator();
static cmExternalMakefileProjectGenerator* New() {
@@ -88,7 +90,7 @@ private:
static void AppendLinkedResource (cmGeneratedFileStream& fout,
const std::string& name,
const std::string& path,
- bool isVirtualFolder = false);
+ LinkType linkType);
bool AppendOutLinkedResource(cmGeneratedFileStream& fout,
const std::string& defname,
-----------------------------------------------------------------------
Summary of changes:
Modules/CMakeFindEclipseCDT4.cmake | 14 ++-
Source/cmExtraEclipseCDT4Generator.cxx | 208 +++++++++++++++++++++++++++-----
Source/cmExtraEclipseCDT4Generator.h | 10 ++-
3 files changed, 197 insertions(+), 35 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list