Using cmake4eclipse with deal.II

192 views
Skip to first unread message

Michał Wichrowski

unread,
Sep 28, 2021, 1:09:44 PM9/28/21
to cmake4eclipse user mailing list
Dear cmake4eclipse developers,

I am working on numerical simulations, the great majority of my programs are based on deal.II library ( https://dealii.org/ ). Eclipse is one of the recommended IDE for that, but unfortunately, setting it up properly is a painful process.
I managed to almost set it up using cmake4eclipse, but I had some issues on the way and build still does not work as it should. I have described the best way to do it in the deal.II wiki: https://github.com/dealii/dealii/wiki/Eclipse#setting-up-a-workspace-in-eclipse-using-cmake4eclipse
With those settings, the indexer works nicely, but I was not able to get a working build target, when I press build the problem appears: "CMakeCache.txt does not exist, unable to build project" Thus I had to manually add build targets from the build directory.

The other issues:
- Somehow STD headers have to be added manually to the project, otherwise, they won't be indexed. This one is a bigger problem, because indexing deal.II takes hours. After adding STD headers location the whole process has to be redone.
- I had some issues with GTest (my own project is using it),  I also had to the location of headers manually.

I would appreciate any advice on how the project should be set up properly and hopefully update the deal.II wiki.

Best,
Michał

Martin Weber

unread,
Sep 28, 2021, 3:12:51 PM9/28/21
to cmake4ecl...@googlegroups.com
On Dienstag, 28. September 2021 19:09:44 CEST Michał Wichrowski wrote:
> Dear cmake4eclipse developers,

Hi Michael,

>
> I am working on numerical simulations, the great majority of my programs
> are based on deal.II library ( https://dealii.org/ ). Eclipse is one of the
> recommended IDE for that, but unfortunately, setting it up properly is a
> painful process.
> I managed to almost set it up using cmake4eclipse, but I had some issues on
> the way and build still does not work as it should. I have described the
> best way to do it in the deal.II
> wiki:
> https://github.com/dealii/dealii/wiki/Eclipse#setting-up-a-workspace-in-ecl
> ipse-using-cmake4eclipse With those settings, the indexer works nicely, but

The wiki tells to create an Eclipse Makefile project. cmake4eclipse is for
Eclipse managed projects.
So you should either create a C++ project or C project first. (Do NOT create a
C/C++ project, since that takes you down the core-build road!)
After that, adjust the projects settings to use the 'CMake driven' toolchain.
To get proper indexing, enable the CMAKE_EXPORT* providers on the Preprocessor
Include Paths tab.

Martin

--
Cd wrttn wtht vwls s mch trsr.




Martin Weber

unread,
Sep 28, 2021, 3:50:30 PM9/28/21
to cmake4ecl...@googlegroups.com
On Dienstag, 28. September 2021 19:09:44 CEST Michał Wichrowski wrote:
> Dear cmake4eclipse developers,
>
> I am working on numerical simulations, the great majority of my programs
> are based on deal.II library ( https://dealii.org/ ). Eclipse is one of the

Just cloned deal.II and created the attached Eclipse project files.
Builds like a charm!
.cproject
.project

Michał Wichrowski

unread,
Sep 29, 2021, 1:06:37 PM9/29/21
to cmake4eclipse user mailing list

Martin,
Thank you for your answer,  I tried following your instructions

The wiki tells to create an Eclipse Makefile project. cmake4eclipse is for
Eclipse managed projects.
So you should either create a C++ project or C project first. (Do NOT create a
C/C++ project, since that takes you down the core-build road!)

For deal.II itself I tried: 

`File`-> `New` -> `Project...` 
From `C/C++` section choose `C++ project`, click Next.  
Set a meaningful project name, uncheck `Use default location`  and specify the location of deal.II source directory. In `Project  type` select `CMake driven` ->`Empty project` and in `Toolchain` menu select  `CMake Driven`. Click `Next`.
Assuming you previously compiled deal.II inside subdirectory `build` and you want to use existing configuration:
Click `Advanced Settings`, agree to override existing project settings, go to  `C/C++ Build`-> `cmake4eclipse`, set the configuration you want to modify. Inside `Build Output Location` frame, set `Folder` to "build/" (or whenever you built deal.II).
In frame `Pre-populate CMake cache entries from file`  set "build/CMakeCache.txt". Click `Apply and Close` and `Finish`

1)  Build works! Unfortunately, it first runs "make clean" destroying preexisting compilation. Can I somehow disable that behaviour?
2) #include <iostream> and other STD headers are unresolved, as a consequence all SDT functions are not indexed and marked as errors. I guess adding headers location manually would resolve that, but shouldn't it be managed by cmake4eclipse?


After that, adjust the projects settings to use the 'CMake driven' toolchain.
To get proper indexing, enable the CMAKE_EXPORT* providers on the Preprocessor
Include Paths tab.

That is enabled by default, I double-checked that after configuring the project. Despite that, the SDT headers were not found by the indexer.

Best,
Michał
 

Martin Weber

unread,
Sep 29, 2021, 3:24:22 PM9/29/21
to cmake4ecl...@googlegroups.com
On Mittwoch, 29. September 2021 19:06:37 CEST Michał Wichrowski wrote:
> Martin,
> Thank you for your answer, I tried following your instructions
...
> For deal.II itself I tried:
>
> `File`-> `New` -> `Project...`
> From `C/C++` section choose `C++ project`, click Next.
> Set a meaningful project name, uncheck `Use default location` and specify
> the location of deal.II source directory. In `Project type` select `CMake
> driven` ->`Empty project` and in `Toolchain` menu select `CMake Driven`.
> Click `Next`.
> Assuming you previously compiled deal.II inside subdirectory `build` and
> you want to use existing configuration:
> Click `Advanced Settings`, agree to override existing project settings, go
> to `C/C++ Build`-> `cmake4eclipse`, set the configuration you want to
> modify. Inside `Build Output Location` frame, set `Folder` to "build/" (or
> whenever you built deal.II).

So far, so good.
> In frame `Pre-populate CMake cache entries from file` set
> "build/CMakeCache.txt". Click `Apply and Close` and `Finish`

Don't do that! You are effectively telling cmake to load file "build/
CMakeCache.txt" which is going to be *generated* by cmake and hence does not
exist.
Simple leave the `Pre-populate CMake cache' field emty.

>
> 1) Build works! Unfortunately, it first runs "make clean" destroying
> preexisting compilation. Can I somehow disable that behaviour?

"make clean" is run by CDT itself. No idea, why and when.

> 2) #include <iostream> and other STD headers are unresolved, as a
> consequence all SDT functions are not indexed and marked as errors. I guess
> adding headers location manually would resolve that, but shouldn't it be
> managed by cmake4eclipse?

Have a look at the compile_commands.json file in the build directory. It show
the include path that cmake did detect.

You could also open a C-source file in the editor and open menu Project | C/C+
+ Index | Create Parse Log file.

Michał Wichrowski

unread,
Sep 30, 2021, 11:09:40 AM9/30/21
to cmake4eclipse user mailing list


So far, so good.
> In frame `Pre-populate CMake cache entries from file` set
> "build/CMakeCache.txt". Click `Apply and Close` and `Finish`

Don't do that! You are effectively telling cmake to load file "build/
CMakeCache.txt" which is going to be *generated* by cmake and hence does not
exist.
Simple leave the `Pre-populate CMake cache' field emty.
 
I've forgotten to add that I have already configured and built deal.ii in subdirectory `build`, so I had CMakeCache.txt generated already. There are a lot of dependencies I need for deal.ii, thus I wanted to avoid setting it up again. Anyway, I have set the project again without it, no change.

"make clean" is run by CDT itself. No idea, why and when.
Ok, thanks, I will look inside CTD settings then. 
 
Have a look at the compile_commands.json file in the build directory. It show
the include path that cmake did detect.
 
The file compile_commands.json does not exist anywhere in the project subdirectory. 
I suppose that is the problem.
I ran the compilation from Eclipse before checking.

You could also open a C-source file in the editor and open menu Project | C/C+
+ Index | Create Parse Log file.
 
I did so for examples/step-1/step-1.cc
The log is in the attachment. 

Best,
Michał


step-1-parser.log

Martin Weber

unread,
Sep 30, 2021, 5:06:24 PM9/30/21
to cmake4ecl...@googlegroups.com
On Donnerstag, 30. September 2021 17:09:40 CEST Michał Wichrowski wrote:
> > So far, so good.
...
> > Have a look at the compile_commands.json file in the build directory. It
> > show
> > the include path that cmake did detect.
>
> The file compile_commands.json does not exist anywhere in the project
> subdirectory.
> I suppose that is the problem.
> I ran the compilation from Eclipse before checking.

With the eclipse project files I posted in a different message (which are from
a freshly created project created through the CMake Driven path; I just
changed the build parallelism from 'unlimited' to 'optimal'), it builds fine
OOTB.
After 25 min, I get the screenshot as attached.
The file compile_commands.json IS there.
Maybe you would use the posted project files as a start?
deal.II-cmake4eclipse.png

Michał Wichrowski

unread,
Oct 4, 2021, 1:07:25 PM10/4/21
to cmake4eclipse user mailing list
Sorry, I have forgotten to write that in my emails, it was the first thing I tried. I used the attached project files, the result was the same.

I have managed to force manually CMake to generate compile_commands.json, it turns out for some weird reason sometimes it ignores the option CMAKE_EXPORT_COMPILE_COMMANDS.
Unfortunately, it did not fix the problem, still, STL  is not indexed.

This time I have cleaned up everything (also removed eclipse workspace dir),  cloned deal.II again, copied your project files into the main source directory, imported the project, built it, forced the indexer to rebuild. 
compile_commands.json has been generated (it is in exactly the same place as on your screenshot), it looks OK to me but the problem persists: all STL files are underlined in Eclipse.
I double-checked that in `Preprocessor Include patchs` to make sure that the CMAKE_EXPORT_COMPILE_COMMANDS* providers are enabled. 
I think the fact that `CMAKE_EXPORT_COMPILE_COMMANDS Compiler Built-ins` is empty while  `CMAKE_EXPORT_COMPILE_COMMANDS Parser` provides a lot of include directories is suspicious. 
compile_commands.json
includeSTd.png
providers.png

Michał Wichrowski

unread,
Oct 4, 2021, 2:31:10 PM10/4/21
to cmake4eclipse user mailing list
Ugh. I think I finally have some progress! The problem might not be in cmake4eclipse but in Eclipse itself.
I tried different providers, since `CDT GCC Built-in Compiler Settings` should provide standard GCC patches. Since I noticed that it provides nothing, I tried checking what `Allocate console in the Console View` would output and it looks like 
${COMMAND}  was set to <unnamed>, thus the command:  ${COMMAND}  ${FLAGS} -E -P -v -dD "${INPUTS}"  failed. I hardcoded g++ instead of ${COMMAND}  and ran it again, this time the console output looked promising, and, indeed, a lot of includes have been listed under `CDT GCC Built-in Compiler Settings`. 

The solution seems to be: `Project`->`Properties`->`C/C++ Build` -> `Settings` and set the command to  g++ (it was <unused> in my case), and the enable `CDT GCC Built-in Compiler Settings`  provider. 
I have no idea how to change it for all projects. 
`CMAKE_EXPORT_COMPILE_COMMANDS Compiler Built-ins` still does not provide anything, but at least STL headers have been found by CDT.
Reply all
Reply to author
Forward
0 new messages