Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer Problems when using eclipse CDT with Cmake
Indexer Problems when using eclipse CDT with Cmake [message #1792301] Sun, 15 July 2018 17:13 Go to next message
Kevin Thomas is currently offline Kevin ThomasFriend
Messages: 3
Registered: July 2018
Junior Member

down vote
favorite
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?
Re: Indexer Problems when using eclipse CDT with Cmake [message #1792340 is a reply to message #1792301] Mon, 16 July 2018 09:29 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Yes, it can be manually configured.
http://help.eclipse.org/photon/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_scanner_discovery.htm
https://help.eclipse.org/photon/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_scanner_discovery.htm?cp=13_4_7_0_4_6

System library headers are usually found by the builtins provider.
The BOP expects to be able to see the compiler calls in the build log to get include paths and compile line macros.
CMake sometimes hides these.

You can always add User entries.

The CMake plugin, assuming you are using one, may provide other methods.
Consult the appropriate documentation for it.

[Updated on: Mon, 16 July 2018 09:42]

Report message to a moderator

Re: Indexer Problems when using eclipse CDT with Cmake [message #1792358 is a reply to message #1792340] Mon, 16 July 2018 12:37 Go to previous messageGo to next message
Kevin Thomas is currently offline Kevin ThomasFriend
Messages: 3
Registered: July 2018
Junior Member
I'm not using a plugin, CMake functionalty is baked into eclipse CDT .
Also these are the only options provided by Eclipse when I create a CMake Project using the builtin template:

https://i.imgur.com/5crILq1.png
Re: Indexer Problems when using eclipse CDT with Cmake [message #1792373 is a reply to message #1792358] Mon, 16 July 2018 15:06 Go to previous messageGo to next message
Doug Schaefer is currently offline Doug SchaeferFriend
Messages: 135
Registered: July 2009
Senior Member
CDT gets all the compile commands and options from the compile_commands.json file in the build directory. If everything looks right there for you, please raise a bug and we can take a look.
Re: Indexer Problems when using eclipse CDT with Cmake [message #1792388 is a reply to message #1792373] Mon, 16 July 2018 18:42 Go to previous messageGo to next message
Kevin Thomas is currently offline Kevin ThomasFriend
Messages: 3
Registered: July 2018
Junior Member
No the compile is completely fine, I have issues with the autocomplete and autocorrect, which can't seam to find the headers from the cmake file. I'm looking for a way to configure the Indexer manually
Re: Indexer Problems when using eclipse CDT with Cmake [message #1792615 is a reply to message #1792301] Fri, 20 July 2018 09:13 Go to previous messageGo to next message
Carlos Posse is currently offline Carlos PosseFriend
Messages: 1
Registered: July 2018
Junior Member
I'm experiencing exactly the same issue. I can compile the project just fine with eclipse, using cmake and ninja. The compile_commands.json is created correctly, but I just can't find a way to configure the indexer to use the CMAKE_EXPORT_COMPILE_COMMANDS, or any other discovery setting. The menu just isn't there, and I can't find any workaround.
Re: Indexer Problems when using eclipse CDT with Cmake [message #1797861 is a reply to message #1792615] Wed, 07 November 2018 14:36 Go to previous messageGo to next message
Michael Fogle is currently offline Michael FogleFriend
Messages: 2
Registered: February 2018
Junior Member
I have similar problems with the indexer...it just can't find any of the system includes, e.g. <stdio.h>, <stdint.h>, etc. I never used to have any of these problems prior to the Luna version, then things started to go "sideways". I still am holding out that the problem is a cockpit error on my part.

I am using Eclipse CDT Oxygen on Ubuntu18.04, and generating my Eclipse project using "cmake -G"Eclipse CDT4 - Unix Makefiles" (version 3.10.2 of cmake), then in Eclipse "Import->General->Existing Projects into Workspace". (Also tried importing as a Makefile project - indexer actually ran, but still didn't find the system includes, and had other problems like losing all the build targets, etc.) The "C/C++ Include Paths and Symbols" list the proper system folders that contain the system includes. I even added the following to my top-level CMakeLists.txt file based on a forum post:
########################################################################
# Eclipse IDE (Oxygen) specific setup
########################################################################
set (CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT TRUE CACHE BOOL "For cmake CDT4 generator." FORCE)
set (CMAKE_C_COMPILER_ID "GNU")
set (CMAKE_CXX_COMPILER_ID "GNU")
set (CMAKE_C_PLATFORM_ID "Linux")
set (CMAKE_CXX_PLATFORM_ID "Linux")


...but to no avail. When doing "Import as existing project" (since the cmake generator made the project files), the Indexer doesn't even run when doing a "Rebuild".

I've looked through many, many forum posts (Eclipse, stackoverflow, others), but often they mention pulldown menus that don't even show up in my Eclipse Oxygen IDE (probably due to "Import as existing" vs "Import as Makefile". I imagine this has something to do with Discovery Providers, but have been unable to figure it out.
Re: Indexer Problems when using eclipse CDT with Cmake [message #1797891 is a reply to message #1797861] Thu, 08 November 2018 08:30 Go to previous messageGo to next message
Hannes Vogt is currently offline Hannes VogtFriend
Messages: 6
Registered: July 2018
Junior Member
As far as I know, 'cmake -G"Eclipse CDT4 - Unix Makefiles"' is very outdated and should not be used.

I think the best option for CMake, at the moment, is to use the cmake4eclipse plugin. The built-in CMake support is currently not at the level of this plugin.

- Create a new empty "C++ project" (not C/C++ project) pointing to your src directory (with the root CMakeLists.txt).
- Go to project Properties -> C/C++ build -> Tool chain editor: select "CMake builder (portable)" as current builder.
- Go to project Properties -> C/C++ general -> Preprocessor Include ... -> Providers: select "CMAKE_COMPILE_COMMANDS_JSON Parser" and "CMAKE_COMPILE_COMMANDS_JSON Compiler Built-Ins".
- Compile your project (check that your includes are properly listed in "Includes" (after the successful build).
Re: Indexer Problems when using eclipse CDT with Cmake [message #1854164 is a reply to message #1797891] Thu, 04 August 2022 06:22 Go to previous messageGo to next message
Peter Borisenko is currently offline Peter BorisenkoFriend
Messages: 2
Registered: August 2022
Junior Member
cmake4eclipse seems to be abandoned since 2021.
The cmake embedded in eclipse still works unwell.
My solution is to open cmake project as makefile project with existing code and create a bunch of build targets. It's is stupid solution. But it works.
Re: Indexer Problems when using eclipse CDT with Cmake [message #1854520 is a reply to message #1792301] Tue, 23 August 2022 15:57 Go to previous messageGo to next message
ervin jason is currently offline ervin jasonFriend
Messages: 1
Registered: August 2022
Junior Member
Kevin Thomas wrote on Sun, 15 July 2018 17:13

down vote
favorite
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?

CDT gets all the compile commands and options from the compile_commands.json file in the build directory. If everything looks right there for you, please raise a bug and we can take a look.

[Updated on: Sat, 29 October 2022 22:21]

Report message to a moderator

Re: Indexer Problems when using eclipse CDT with Cmake [message #1854903 is a reply to message #1854164] Sat, 17 September 2022 00:41 Go to previous message
juanito perez is currently offline juanito perezFriend
Messages: 6
Registered: July 2021
Junior Member
Peter Borisenko wrote on Thu, 04 August 2022 06:22
cmake4eclipse seems to be abandoned since 2021.
The cmake embedded in eclipse still works unwell.
My solution is to open cmake project as makefile project with existing code and create a bunch of build targets. It's is stupid solution. But it works.


cmake4eclipse, https://github.com/15knots/cmake4eclipse, seems active to me, last modification is 10 hours ago.

Btw, I am also having indexer issues but I am using the aforementioned plugin.
Previous Topic: "make" is not found in PATH hello
Next Topic:Unresolved inclusion <iostream> when using cmake.
Goto Forum:
  


Current Time: Tue Apr 23 07:28:23 GMT 2024

Powered by FUDForum. Page generated in 0.07547 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top