From 117f2b8257d92328b32cb90ced3d85d88815130b Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 12:25:33 +0200 Subject: 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 --- Source/cmExtraEclipseCDT4Generator.cxx | 33 +++++++++++++++++++++++++++++++-- Source/cmExtraEclipseCDT4Generator.h | 3 ++- 2 files changed, 33 insertions(+), 3 deletions(-) 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(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 << "\n" "" << makeArgs << "\n" - "" << targetXml << "\n" + "" << makeTargetXml << "\n" "true\n" "false\n" "\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, -- cgit v0.12