[CMake] CDT generator help: path discovery and other items

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jun 3 15:44:57 EDT 2013


On Monday 03 June 2013, Dixon, Joel L. wrote:
> I'm new to CMake, and loving it.  I'm using version 2.8.11 and have a
> couple issues with the CDT generator.
> 
> 
> 
> First, there's really no definitive help (that I've found) for the CDT
> generator.  The HTML generator just simply mentions the generator, it
> doesn't mention any of the options that I've stumbled upon in mentions out
> on the open web, such as:
> 
>   CMAKE_ECLIPSE_MAKE_ARGUMENTS=<>
> 
>     You can use this to add things such as "-j4" to increase the number of
> parallel jobs during builds
> 
>   CMAKE_ECLIPSE_VERSION=<>
> 
>     Setting this to "3.7" for my CDT version made a difference.
> 
> 
> 
> Are there others?  Where are they documented?

They are cache variables. All variables related to the Eclipse generator start 
with "CMAKE_ECLIPSE_".
I recommend you use cmake-gui, then you see all CMAKE_ECLIPSE_* variables.
Putting the mouse cursor above the variable shows documentation for the 
variable in a tooltip. For the versions there is a combobox which provides 
only the supported versions.

Beside that, you are right that the variables are undocumented.
All of them are set in Modules/CMakeFindEclipseCDT4.cmake. You may have a look 
in that file.


> The only official help I've found was at
> http://www.cmake.org/Wiki/Eclipse_CDT4_Generator, and this seems to be
> quite out of date.
> 
> 
> 
> Secondly, path discovery wasn't nearly automatic.  Even after a build,
> opening a C++ file showed unresolved inclusions for every STL include
> (such as <iostream>)  It took me a while, but I finally found that going
> to the Project Properties, then "C/C++ project paths", "Path Containers",
> "Add..." and adding the "Discovered scanner configuration scanner" and
> doing a fresh build and Index rebuild that everything was fine.

This should work.
Can you try this with a "Hello world"-style project and send me the resulting 
.cproject file ?
Maybe also the CMakeCache.txt.

> Finally, doing any edits to the project from WITHIN Eclipse are lost
> whenever having to re-run cmake.  For example, adding project filters to
> hide "CMakeFiles", Qt4 files (such as *.moc, ui_*.h, etc), these filters
> are lost if you have to rerun cmake when adding a new source file to the
> project.

Yes, the .project and .cproject files are completely regenerated on each cmake 
run.
How do you want to hide CMakeFiles/, in which places is this hidden then ?
Can you again, create a "Hello World"-style project, manually add a filter for 
CMakeFiles/, and send me the .project and .cproject files ?
(this can be the same files as above).


Eclipse does have some issues, where cmake simply cannot help.
Some settings are stored neither in the .project nor in the .cproject files, 
but inside the workspace metedata, which cmake cannot touch (because it is 
somewhere else, it is binary, undocumented, etc.).

Also, Eclipse only open the version control plugins inside the project 
directory. Now with cmake out-of-source builds the project files for Eclipse 
are generated in the build tree, not in the source tree, and Eclipse doesn't 
see version control files there, so it never opens the version control 
plugins. I would naively assume that it shouldn't be too hard to add an entry 
SourceRootDir or something like that to the .project file, which, if set, 
would then be used instead of the directory of .project. Then cmake could 
simply write that tag into the .project file and Eclipse would be able to 
handle it. But for that it needs somebody deep in Eclipse to add support for 
that inside Eclipse.


Alex


More information about the CMake mailing list