2

I have problems with the Index responsible for autocomplete and live code correction in eclipse CDT. When I setup an Eclipse project using the in eclipse CMAKE tools (New Project=>CMake Project) the indexer simply doesn't work and can't find any files outside the source directory (It can't find library headers, even the ones on /usr/).
It does sometimes kinda work if the inlcude_directory is set directly without usage of a variable, but its pretty random:

# this sometimes works
include_directories("/home/user/lib/test")
# this never does
set(PATH /home/marvin/Documents/trash)
include_directories(${PATH})

so is there a way to configure eclipses Index manually? So I can just add resource paths or something for the Indexer directly, so I can have code completion?

user2741831
  • 2,120
  • 2
  • 22
  • 43
  • Yes, you can add include paths manually via `Project Properties | C/C++ General | Preprocessor Include Paths, Macros etc. | CDT User Settings Entries`. Be sure to add them under the correct language. That said, you may want to try something like [cmake4eclipse](https://marketplace.eclipse.org/content/cmake4eclipse) first to see if it can do it for you automatically. – HighCommander4 Jul 15 '18 at 17:04
  • this isn't available when using the CMake Tool. this is wehat it looks like: https://i.imgur.com/5crILq1.png. And indexer isnt very helpful either – user2741831 Jul 15 '18 at 17:10
  • and I tried cmake4eclipse already, and it simply doesn't seam to work. – user2741831 Jul 15 '18 at 17:10
  • About the preference page not being available, perhaps [this answer](https://stackoverflow.com/questions/50792865/preprocessor-include-paths-macros-etc-entry-not-available/50900083#50900083) helps. – HighCommander4 Jul 15 '18 at 21:07
  • this option isn't available either – user2741831 Jul 16 '18 at 05:37
  • Did your cmake generate a `compile_commands.json` file in the build directory? cmake4eclipse works very nicely for me. – havogt Jul 18 '18 at 15:40
  • yes, but Eclipses Indexer doesn't seam to pick anything up from it for some reason – user2741831 Jul 20 '18 at 15:15

1 Answers1

0

Things that may help:

  • Completely clean out your CMake generated files (cache, project files, makefiles, etc.) and regenerate from scratch. I've had CMake mess up the Eclipse project when trying to generate one in a build tree that already had just generated Makefiles.
  • Reset the C/C++ indexer to default settings.
  • Add individual header files to your library/binary target(s) alongside your source files.
HunterZ
  • 181
  • 14