compatibility with the new docker build functionality in the CDT ?

472 views
Skip to first unread message

ker...@gmail.com

unread,
Jan 10, 2018, 4:52:38 PM1/10/18
to cmake4eclipse user mailing list
Hello,

i'd like to build the cmake eclipse project in a container using the newly released container functionality, so i set up a cmake4eclipse project, i enabled container building in the build->settings.

the building works fine, eclipse launches docker and builds the executable just fine, but the indexer doesn't take into account headers (i use the point cloud library so headers are in /usr/include/pcl-1.8 inside my docker image).

I see that eclipse copies the headers from the docker image to the host system (i find them somewhere as cached headers under my workspace), however, when i look in "preprocessor macros and includes" there is no reference to /usr/include/pcl-1.8.

Is this supposed to work at all ? I understand that in order to find include paths, CMAKE_EXPORT_COMPILE_COMMANDS is used, but is the cmake ran inside the docker container here ? And are the paths translated from docker image to the cached headers on the host ?

Thanks...

Frank

Martin Weber

unread,
Jan 11, 2018, 3:01:49 PM1/11/18
to cmake4ecl...@googlegroups.com
Am Mittwoch, 10. Januar 2018, 13:52:38 CET schrieb ker...@gmail.com:
> Hello,
>
> i'd like to build the cmake eclipse project in a container using the newly
> released container functionality, so i set up a cmake4eclipse project, i
> enabled container building in the build->settings.

This is the first time I hear about the container functionality in CDT.

>
> the building works fine, eclipse launches docker and builds the executable
> just fine, but the indexer doesn't take into account headers (i use the
> point cloud library so headers are in /usr/include/pcl-1.8 inside my docker
> image).
>
> I see that eclipse copies the headers from the docker image to the host
> system (i find them somewhere as cached headers under my workspace),
> however, when i look in "preprocessor macros and includes" there is no
> reference to /usr/include/pcl-1.8.
>
> Is this supposed to work at all ? I understand that in order to find include
> paths, CMAKE_EXPORT_COMPILE_COMMANDS is used, but is the cmake ran inside

Yes, if CMAKE_EXPORT_COMPILE_COMMANDS is passed to cmake, it will generate a
compile_commands.json file in the build directory, which is parsed by the
CMAKE_EXPORT_COMPILE_COMMANDS Parser.

> the docker container here ? And are the paths translated from docker image
> to the cached headers on the host ?

The plugin is not aware of the docker functionality, so it does not not
translate any paths found in compile_commands.json, sorry.
I am wondering how this actually works with docker. If
CMAKE_EXPORT_COMPILE_COMMANDS Parser does not find the compile_commands.json
file, there should be a message saying "File '.../compile_commands.json' was
not created in the build." in the problems view. But if CDT translates the
path to the build directory in the docker root, the parser will find the
compile_commands.json.
Could you provide the (relevant) output of CDT`s global build console?

/Martin

--
Cd wrttn wtht vwls s mch trsr.


Frank Dekervel

unread,
Jan 11, 2018, 4:32:10 PM1/11/18
to cmake4ecl...@googlegroups.com
Hello Martin,

Thanks for your reply (sorry, i hit the wrong reply button and sent it to your email address instead of the mailing list).

I just ran the build again, and i think i understand the problem better now:

* it creates a container and mounts the source directory on the host in the same path in the container (so the paths for project source files are the same in the container and on the host, and no translation is needed)
* it just runs cmake inside the container, and from what i see the json file is generated (in the container). Off course, for external include dirs, there are now container paths and not host paths as these libraries are not even available on the host. cmake4eclipse also parses the json file correctly (i can see the includes and preprocessor symbols appear under preprocessor paths / macros / --> CMAKE_EXPORT_COMPILE_COMMANDS Parser)

The only thing missing is the translation to the cached header files. If i look at the "built in compiler settings" provider, path names are translated and look like this:
/home/kervel/eclipse-workspace/.metadata/.plugins/org.eclipse.cdt.docker.launcher/HEADERS/unix_var_run_docker_sock/docker_pcl_latest/usr/include/c++/6

But for cmake4eclipse they are not. Btw, the documentation for the new docker functionality is rather scarce, this is what i found so far:
* the bug report that tracks the feature: https://bugs.eclipse.org/bugs/show_bug.cgi?id=513589

greetings,
Frank

--
You received this message because you are subscribed to a topic in the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cmake4eclipse-users/fzetPJO8HK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cmake4eclipse-users+unsub...@googlegroups.com.
To post to this group, send email to cmake4eclipse-users@googlegroups.com.
Visit this group at https://groups.google.com/group/cmake4eclipse-users.
For more options, visit https://groups.google.com/d/optout.

bernd...@googlemail.com

unread,
Jan 25, 2018, 6:10:08 AM1/25/18
to cmake4eclipse user mailing list
Dear all,

I also trying to use cmake4eclipse with CDT docker build. I am bothered now with the error:

[Running in image <bernddoser/docker-devel-cpp:ubuntu-16.04-cmake-3.10-clang-6>]
/usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -G "Unix Makefiles" /home/eclipse/git/cpp-settings
CMake Error: Could not create named generator Unix

As I understand the docker cmake command has lost the quotation marks. Inspecting the docker container, I see:

"Path": "/usr/bin/cmake",
"Args": [
"-DCMAKE_BUILD_TYPE:STRING=Debug",
"-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON",
"-G",
"Unix",
"Makefiles",
"/home/eclipse/git/cpp-settings"
],

Is it possible to mask the quotation marks?

Best regards,
Bernd

Martin Weber

unread,
Jan 25, 2018, 3:15:29 PM1/25/18
to cmake4ecl...@googlegroups.com
Am Donnerstag, 11. Januar 2018, 22:32:08 CET schrieb Frank Dekervel:
> Hello Martin,
>
> Thanks for your reply (sorry, i hit the wrong reply button and sent it to
> your email address instead of the mailing list).
>
> I just ran the build again, and i think i understand the problem better now:
>
> * it creates a container and mounts the source directory on the host in the
> same path in the container (so the paths for project source files are the
> same in the container and on the host, and no translation is needed)
> * it just runs cmake inside the container, and from what i see the json
> file is generated (in the container). Off course, for external include
> dirs, there are now container paths and not host paths as these libraries
> are not even available on the host. cmake4eclipse also parses the json file
> correctly (i can see the includes and preprocessor symbols appear under
> preprocessor paths / macros / --> CMAKE_EXPORT_COMPILE_COMMANDS Parser)
>
> The only thing missing is the translation to the cached header files. If i
> look at the "built in compiler settings" provider, path names are
> translated and look like this:
> /home/kervel/eclipse-workspace/.metadata/.plugins/org.eclipse.cdt.docker.
> launcher/HEADERS/unix_var_run_docker_sock/docker_pcl_latest/
> usr/include/c++/6

To make the translation work, cmake4eclipse must detect whether the build runs
inside of docker, and then use some docker plugin API to get the mapping root
'home/k.../docker_pcl_latest/'. Not an easy task, concerning the overwhelming
amount of javadoc in the CDT code.
To implement that, I would need support by the community: Example projects,
including container setups, testing and more.

But feel free to file an enhancement request at the plugins github site.

Martin

fifteenknots505

unread,
Apr 6, 2018, 4:16:10 PM4/6/18
to cmake4eclipse user mailing list
Frank,
I am still looking at this.
Can you share an example project on github? (Something simple like in <https://github.com/15knots/cmake4eclipse-sample-projects/tree/master/C-inclpaths>).

fifteenknots505

unread,
Apr 6, 2018, 4:20:06 PM4/6/18
to cmake4eclipse user mailing list


On Thursday, January 25, 2018 at 12:10:08 PM UTC+1, Bernd Doser wrote:
Dear all,

I also trying to use cmake4eclipse with CDT docker build. I am bothered now with the error:

 
...

docker container, I see:

"Path": "/usr/bin/cmake",
"Args": [
    "-DCMAKE_BUILD_TYPE:STRING=Debug",
    "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON",
    "-G",
    "Unix",
    "Makefiles",
    "/home/eclipse/git/cpp-settings"
],

Is it possible to mask the quotation marks?


 Sorry, whatever file that code comes from, it is not generated by cmake4eclipse.

Martin

fifteenknots505

unread,
Apr 24, 2018, 3:13:40 PM4/24/18
to cmake4eclipse user mailing list
Hi Frank and Jerroyd,

since I am still struggling with my docker setup for CDT on Linux, could you please try my locally build inofficial version here:
<jar:https://googledrive.com/host/0B-QU1Qnto3huZUZ0QUdxM01pR0U/cmake4eclipsecdt-1.0.0.zip!/>

Just add the above URL as an update site and update.

Please report here whether the include paths are translated/copied as expected.

/Martin

fifteenknots505

unread,
Apr 30, 2018, 2:14:05 PM4/30/18
to cmake4eclipse user mailing list
I step thought the caals and found that org.eclipse.cdt.docker.launcher.ContainerCommandLauncher#execute() does not properly construct the command line. It gets an array of String as the command arguments but does not quote arguments containing spaces, when it constructs a command-line string.
After that, it (indirectly) invokes ContainerLauncher#getCmdList() which converts the command-line String back to List<String> (why???), splitting arguments at each space.

The old local launcher in org.eclipse.cdt.core.CommandLauncher.execute() behaves as expected.

So I think this is a bug in the newly integrated Docker Launching of CDT and should be reporsted on their issue tracker.

mads.an...@gmail.com

unread,
Jun 16, 2018, 5:36:27 AM6/16/18
to cmake4eclipse user mailing list
Was this reported to CDT?

Curious - as I am running into this as well.

-Mads

Martin Weber

unread,
Jun 16, 2018, 7:56:04 AM6/16/18
to cmake4ecl...@googlegroups.com
Am Samstag, 16. Juni 2018, 11:36:27 CEST schrieb mads.an...@gmail.com:
> Was this reported to CDT?

Maybe. You will have to look at CDT.

Mads Andreasen

unread,
Jun 17, 2018, 5:23:28 AM6/17/18
to cmake4eclipse user mailing list
Tried this with the latest RC for the Eclipse Photon release - and it works.

Martin Weber

unread,
Jun 17, 2018, 8:03:30 AM6/17/18
to cmake4ecl...@googlegroups.com
Am Sonntag, 17. Juni 2018, 11:23:28 CEST schrieb Mads Andreasen:
> Tried this with the latest RC for the Eclipse Photon release - and it works.

Great to hear that!

Do you know whether the GCC-builtin-Settings detector does work when building
in a container? That is: it should set the macros and incl path of the gcc
which is in the container.
I'm currently working to support compiler built-ins detection for (mostly) any
compiler supported by by cmake.

Martin

Mads Andreasen

unread,
Jun 17, 2018, 2:34:16 PM6/17/18
to fifteen...@gmail.com, cmake4ecl...@googlegroups.com
It does change the GCC built in settings to reflect new incl paths etc. 
The include paths point to cached entries from the container.
The CMAKE_EXPORT_COMPILE_COMMANDS_PARSER also works.

However there are something fiddly when adding and removing include paths in the project. It looks like everything is ok, but it is not. It looks like the container doesn't get updated with the new source files and builds the old ones. So It seems like a CDT docker issue.

Venlig hilsen
Mads


--
You received this message because you are subscribed to the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cmake4eclipse-u...@googlegroups.com.
To post to this group, send email to cmake4ecl...@googlegroups.com.

Frank Dekervel

unread,
Sep 28, 2018, 5:40:28 AM9/28/18
to cmake4ecl...@googlegroups.com
Hello,

i tried again to get it working now using ninja generator and actually i only have 2 issues left:
  • inside the container i use ROS2 which requires me to source a bash script containing environment variables before running cmake. i worked around this by creating a script ros_env_cmake that first sources the setup script and then launches cmake. then i could set this as cmake command in the "host overrides" section of the cmake settings, works perfectly!
  • the ros includes are in /opt/ros.
    • eclipse only copies /usr/include from the container to the host for indexing. but even if it also copied /opt/ros, it would still not work because ...
    • the CMAKE_EXPORT_COMPILE_COMMANDS parser does not translate the paths from the container to paths on the host (for me it was something like /home/kervel/eclipse-workspace/.metadata/.plugins/org.eclipse.cdt.docker.launcher/HEADERS/unix_var_run_docker_sock/ros2base_latest/usr/include/... )
  • ugly workaround: i copied /opt/ros from the container to the host like this: cd / ; docker run  --rm ros2base tar -zc /opt/ros | tar -zx

with these 2 workarounds i have a perfect environment (i get code completion from the new openCV library in my container and not from the outdated one on my host, ...)

thanks!

Frank


You received this message because you are subscribed to a topic in the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cmake4eclipse-users/fzetPJO8HK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cmake4eclipse-u...@googlegroups.com.

Martin Weber

unread,
Sep 28, 2018, 11:55:53 AM9/28/18
to cmake4ecl...@googlegroups.com
Am Freitag, 28. September 2018, 11:40:16 CEST schrieb Frank Dekervel:
> Hello,

Hi,

>
> i tried again to get it working now using ninja generator and actually i
> only have 2 issues left:
>
> - inside the container i use ROS2 which requires me to source a bash
> script containing environment variables before running cmake. i worked
> around this by creating a script ros_env_cmake that first sources the
> setup script and then launches cmake. then i could set this as cmake
> command in the "host overrides" section of the cmake settings, works
> perfectly!
>
>
> - the ros includes are in /opt/ros.
> - eclipse only copies /usr/include from the container to the host for
> indexing. but even if it also copied /opt/ros, it would still not work
> because ...

Here [1] is a description of how the docker builds work.
Unfortunately, when the CMAKE_EXPORT_COMPILE_COMMANDS parser runs, the
container already has been shut down. So there is no chance for the parser to
tell CDT to also copy /opt/ros. May it helps to add /opt/ros in the project
settings (C/C++ Build > Settings > Tool Settings GCC C Compiler) to make CDT
copy that directory (the settings there do no affect cmake4eclipse).

> - the CMAKE_EXPORT_COMPILE_COMMANDS parser does not translate the
> paths from the container to paths on the host (for me it was
> something like

I fear, there`s not much what the plugin can do to help here. It completely
relies on the container build feature from CDT. AFAICT from the CDT code
(actually the patches), there is not even a way to determine the path on the
host in order to do the translation.

>
> /home/kervel/eclipse-workspace/.metadata/.plugins/org.eclipse.cdt.docker.la
> uncher/HEADERS/unix_var_run_docker_sock/ros2base_latest/usr/include/... )
> - ugly workaround: i copied /opt/ros from the container to the host like
> this: cd / ; docker run --rm ros2base tar -zc /opt/ros | tar -zx
>
>
> with these 2 workarounds i have a perfect environment (i get code
> completion from the new openCV library in my container and not from the
> outdated one on my host, ...)

Martin

[1] http://eclipse.1072660.n5.nabble.com/Docker-Container-support-for-Core-Build-td195695.html
Reply all
Reply to author
Forward
0 new messages