diff options
Diffstat (limited to 'Source/cmExtraEclipseCDT4Generator.cxx')
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 131 |
1 files changed, 47 insertions, 84 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 65077b3..97ab086 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -34,9 +34,11 @@ cmExtraEclipseCDT4Generator this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); #endif + this->SupportedGlobalGenerators.push_back("Ninja"); this->SupportedGlobalGenerators.push_back("Unix Makefiles"); this->SupportsVirtualFolders = true; + this->GenerateLinkedResources = true; } //---------------------------------------------------------------------------- @@ -82,6 +84,9 @@ void cmExtraEclipseCDT4Generator::Generate() this->HomeDirectory = mf->GetHomeDirectory(); this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); + this->GenerateLinkedResources = mf->IsOn( + "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES"); + this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory); this->GenerateSourceProject = (this->IsOutOfSourceBuild && @@ -286,6 +291,9 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set the make command std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_ECLIPSE_MAKE_ARGUMENTS"); + fout << "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>\n" @@ -293,7 +301,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.command</key>\n" - "\t\t\t\t\t<value>" + this->GetEclipsePath(make) + "</value>\n" + "\t\t\t\t\t<value>" << this->GetEclipsePath(make) << "</value>\n" "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.contents</key>\n" @@ -305,7 +313,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.arguments</key>\n" - "\t\t\t\t\t<value></value>\n" + "\t\t\t\t\t<value>" << makeArgs << "</value>\n" "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildLocation</key>\n" @@ -458,18 +466,6 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() this->CreateLinksForTargets(fout); } - // I'm not sure this makes too much sense. There can be different - // output directories in different subdirs, so we would need more of them. - - // for EXECUTABLE_OUTPUT_PATH when not in binary dir - this->AppendOutLinkedResource(fout, - mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"), - mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH")); - // for LIBRARY_OUTPUT_PATH when not in binary dir - this->AppendOutLinkedResource(fout, - mf->GetSafeDefinition("CMAKE_LIBRARY_OUTPUT_DIRECTORY"), - mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH")); - fout << "\t</linkedResources>\n"; fout << "</projectDescription>\n"; @@ -509,6 +505,10 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( linkName2 += ti->first; this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", VirtualFolder); + if (!this->GenerateLinkedResources) + { + break; // skip generating the linked resources to the source files + } 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); @@ -563,6 +563,11 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( cmGeneratedFileStream& fout, const std::string& baseDir) { + if (!this->GenerateLinkedResources) + { + return; + } + // 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]", @@ -587,7 +592,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( this->GetEclipsePath(linkSourceDirectory), LinkToFolder ); - this->SrcLinkedResources.push_back(it->first); + // Don't add it to the srcLinkedResources, because listing multiple + // directories confuses the Eclipse indexer (#13596). } } } @@ -606,6 +612,16 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories( if (!inc->empty()) { std::string dir = cmSystemTools::CollapseFullPath(inc->c_str()); + + // handle framework include dirs on OSX, the remainder after the + // Frameworks/ part has to be stripped + // /System/Library/Frameworks/GLUT.framework/Headers + cmsys::RegularExpression frameworkRx("(.+/Frameworks)/.+\\.framework/"); + if(frameworkRx.find(dir.c_str())) + { + dir = frameworkRx.match(1); + } + if(emittedDirs.find(dir) == emittedDirs.end()) { emittedDirs.insert(dir); @@ -728,15 +744,16 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const /* 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 - * 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(); @@ -753,22 +770,10 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const excludeFromOut += this->EscapeForXML(*it) + "/|"; } } -#endif + excludeFromOut += "**/CMakeFiles/"; fout << "<pathentry excluding=\"" << excludeFromOut << "\" kind=\"out\" path=\"\"/>\n"; - // add output entry for EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH - // - if it is a subdir of homeOutputDirectory, there is no need to add it - // - if it is not then create a linked resource and add the linked name - // but check it doesn't conflict with other linked resources names - for (std::vector<std::string>::const_iterator - it = this->OutLinkedResources.begin(); - it != this->OutLinkedResources.end(); - ++it) - { - fout << "<pathentry kind=\"out\" path=\"" << this->EscapeForXML(*it) - << "\"/>\n"; - } // add pre-processor definitions to allow eclipse to gray out sections emmited.clear(); @@ -894,11 +899,18 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - cmTargets & targets = (*it)->GetMakefile()->GetTargets(); - for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) + cmGeneratorTargetsType targets = (*it)->GetMakefile() + ->GetGeneratorTargets(); + for (cmGeneratorTargetsType::iterator l = targets.begin(); + l != targets.end(); ++l) { + if (l->first->IsImported()) + { + continue; + } std::vector<std::string> includeDirs; - (*it)->GetIncludeDirectories(includeDirs, &l->second); + const char *config = mf->GetDefinition("CMAKE_BUILD_TYPE"); + (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); this->AppendIncludeDirectories(fout, includeDirs, emmited); } } @@ -1067,9 +1079,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } //insert rules for compiling, preprocessing and assembling individual files - cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it; std::vector<std::string> objectFileTargets; - lumg->GetIndividualFileTargets(objectFileTargets); + (*it)->GetIndividualFileTargets(objectFileTargets); for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); fit != objectFileTargets.end(); ++fit) @@ -1314,51 +1325,3 @@ void cmExtraEclipseCDT4Generator "\t\t</link>\n" ; } - -bool cmExtraEclipseCDT4Generator -::AppendOutLinkedResource(cmGeneratedFileStream& fout, - const std::string& defname, - const std::string& altdefname) -{ - if (defname.empty() && altdefname.empty()) - { - return false; - } - - std::string outputPath = (defname.empty() ? altdefname : defname); - - if (!cmSystemTools::FileIsFullPath(outputPath.c_str())) - { - outputPath = this->HomeOutputDirectory + "/" + outputPath; - } - if (cmSystemTools::IsSubDirectory(outputPath.c_str(), - this->HomeOutputDirectory.c_str())) - { - return false; - } - - std::string name = this->GetPathBasename(outputPath); - - // make sure linked resource name is unique - while (this->GlobalGenerator->GetProjectMap().find(name) - != this->GlobalGenerator->GetProjectMap().end()) - { - name += "_"; - } - - if (std::find(this->OutLinkedResources.begin(), - this->OutLinkedResources.end(), - name) - != this->OutLinkedResources.end()) - { - return false; - } - else - { - this->AppendLinkedResource(fout, name, - this->GetEclipsePath(outputPath), LinkToFolder); - this->OutLinkedResources.push_back(name); - return true; - } -} - |