diff options
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 76 | ||||
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.h | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 26 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 10 |
4 files changed, 102 insertions, 14 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index b7daab6..89aa725 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -689,15 +689,16 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); cmGlobalGenerator* generator = const_cast<cmGlobalGenerator*>(this->GlobalGenerator); + + std::string allTarget; + std::string cleanTarget; if (generator->GetAllTargetName()) { - emmited.insert(generator->GetAllTargetName()); - this->AppendTarget(fout, generator->GetAllTargetName(), make); + allTarget = generator->GetAllTargetName(); } if (generator->GetCleanTargetName()) { - emmited.insert(generator->GetCleanTargetName()); - this->AppendTarget(fout, generator->GetCleanTargetName(), make); + cleanTarget = generator->GetCleanTargetName(); } // add all executable and library targets and some of the GLOBAL @@ -709,6 +710,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); cmMakefile* makefile=(*it)->GetMakefile(); + std::string subdir = (*it)->Convert(makefile->GetCurrentOutputDirectory(), + cmLocalGenerator::HOME_OUTPUT); + if (subdir == ".") + { + subdir = ""; + } + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) { switch(ti->second.GetType()) @@ -718,8 +726,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (strcmp(makefile->GetStartOutputDirectory(), - makefile->GetHomeOutputDirectory())==0) + if (subdir.empty()) { insertTarget = true; // only add the "edit_cache" target if it's not ccmake, because @@ -735,7 +742,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } if (insertTarget) { - this->AppendTarget(fout, ti->first, make); + this->AppendTarget(fout, ti->first, make, subdir, ": "); } } break; @@ -750,17 +757,19 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const break; } - this->AppendTarget(fout, ti->first, make); + this->AppendTarget(fout, ti->first, make, subdir, ": "); break; case cmTarget::EXECUTABLE: case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: { - this->AppendTarget(fout, ti->first, make); + const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + "[exe] " : "[lib] "); + this->AppendTarget(fout, ti->first, make, subdir, prefix); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget, make); + this->AppendTarget(fout, fastTarget, make, subdir, prefix); } break; // ignore these: @@ -771,7 +780,38 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const break; } } + + // insert the all and clean targets in every subdir + if (!allTarget.empty()) + { + this->AppendTarget(fout, allTarget, make, subdir, ": "); + } + if (!cleanTarget.empty()) + { + this->AppendTarget(fout, cleanTarget, make, subdir, ": "); + } + + //insert rules for compiling, preprocessing and assembling individual files + cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it; + std::vector<std::string> objectFileTargets; + lumg->GetIndividualFileTargets(objectFileTargets); + for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); + fit != objectFileTargets.end(); + ++fit) + { + const char* prefix = "[obj] "; + if ((*fit)[fit->length()-1] == 's') + { + prefix = "[to asm] "; + } + else if ((*fit)[fit->length()-1] == 'i') + { + prefix = "[pre] "; + } + this->AppendTarget(fout, *fit, make, subdir, prefix); + } } + fout << "</buildTargets>\n" "</storageModule>\n" ; @@ -924,13 +964,23 @@ void cmExtraEclipseCDT4Generator fout << "</storageModule>\n"; } +// 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 +// object files "[obj]", then for preprocessing only "[pre] " and +// finally the assembly files "[to asm] ". Note the "to" in "to asm", +// without it, "asm" would be the first targets in the list, with the "to" +// they are the last targets, which makes more sense. void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout, const std::string& target, - const std::string& make) + const std::string& make, + const std::string& path, + const char* prefix) { fout << - "<target name=\"" << target << "\"" - " path=\"\"" + "<target name=\"" << prefix << target << "\"" + " path=\"" << path.c_str() << "\"" " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n" "<buildCommand>" << cmExtraEclipseCDT4Generator::GetEclipsePath(make) diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index cb4226e..5004ca7 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -91,7 +91,9 @@ private: const cmMakefile& makefile); static void AppendTarget (cmGeneratedFileStream& fout, const std::string& target, - const std::string& make); + const std::string& make, + const std::string& path, + const char* prefix = ""); static void AppendScannerProfile (cmGeneratedFileStream& fout, const std::string& profileID, bool openActionEnabled, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2c365ed..eb77284 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -152,6 +152,30 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets + (std::vector<std::string>& targets) +{ + for (std::map<cmStdString, LocalObjectInfo>::iterator lo = + this->LocalObjectFiles.begin(); + lo != this->LocalObjectFiles.end(); ++lo) + { + targets.push_back(lo->first); + + std::string::size_type dot_pos = lo->first.rfind("."); + std::string base = lo->first.substr(0, dot_pos); + if(lo->second.HasPreprocessRule) + { + targets.push_back(base + ".i"); + } + + if(lo->second.HasAssembleRule) + { + targets.push_back(base + ".s"); + } + } +} + +//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() { // generate the includes @@ -228,12 +252,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() this->WriteObjectConvenienceRule( ruleFileStream, "target to preprocess a source file", (base + ".i").c_str(), lo->second); + lo->second.HasPreprocessRule = true; } if(do_assembly_rules) { this->WriteObjectConvenienceRule( ruleFileStream, "target to generate assembly for a file", (base + ".s").c_str(), lo->second); + lo->second.HasAssembleRule = true; } } } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 0bb0314..ce6b45f 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -246,6 +246,10 @@ public: struct LocalObjectInfo: public std::vector<LocalObjectEntry> { bool HasSourceExtension; + bool HasPreprocessRule; + bool HasAssembleRule; + LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), + HasAssembleRule(false) {} }; std::map<cmStdString, LocalObjectInfo> const& GetLocalObjectFiles() { return this->LocalObjectFiles;} @@ -266,6 +270,12 @@ public: // Get the directories into which the .o files will go for this target void GetTargetObjectFileDirectories(cmTarget* target, std::vector<std::string>& dirs); + + // Fill the vector with the target names for the object files, + // preprocessed files and assembly files. Currently only used by the + // Eclipse generator. + void GetIndividualFileTargets(std::vector<std::string>& targets); + protected: void WriteLocalMakefile(); |