CMAKE_EXPORT_COMPILE_COMMANDS Parser doesn't recognize macros

135 views
Skip to first unread message

torsten...@googlemail.com

unread,
Nov 5, 2018, 8:43:16 AM11/5/18
to cmake4eclipse user mailing list
Hi,

I am using cmake4eclipse for all my cmake projects especially because of the "CMAKE_EXPORT_COMPILE_COMMANDS Parser" because it simplifies the management of includes and symbols in eclipse a lot.

Unfortunately I discovered that parsing of macros (e.g. add_definitions(-DFOO=1)) seems to be broken in version 1.12.2 while parsing of includes (-I and --system) works just fine. To make sure it's not a personal config failure I followed the "User Guide -> Getting Started" instructions closely but the plugin is still not recognizing any macro definitions even though they occur in the "compile_commands.json" file. I also tried the sample projects [1] but even their macros aren't parsed.

I checked the issues on Github but none of the open ones seems to address this problem. Issue #79[3] might be related but parsing of built in macros and includes by "CMAKE_EXPORT_COMPILE_COMMANDS Compiler Built-ins" works just fine while #84[2] sounds very similar but was closed/fixed in July and should be included in 1.12.2 already.

Is this a known problem or should I open a new Issue for this?

I used two different setups but the problem occurred on both of them:

Setup 1:
- Gentoo Linux 4.14.65 amd64
- Oracle JRE 1.8.0.192
- Eclipse 2018-09 (4.9.0)
- Eclipse CDT 9.5.3
- cmake4eclipse 1.12.2
- cmake 3.9.6

Setup 2:
- Windows 7
- MinGW-w64 x86_64-6.4.0
- Oracle JRE 1.8.0.151
- Eclipse Photon (4.8.0)
- cmake4eclipse 1.12.2
- cmake 3.12.1

I would be happy to provide any more information that is necessary to solve this problem.

Best
Torsten


[1] https://github.com/15knots/cmake4eclipse-sample-projects
[2] https://github.com/15knots/cmake4eclipse/issues/84
[3] https://github.com/15knots/cmake4eclipse/issues/79

Martin Weber

unread,
Nov 5, 2018, 3:07:47 PM11/5/18
to cmake4ecl...@googlegroups.com
Am Montag, 5. November 2018, 14:43:16 CET schrieb torstenwylegala via
cmake4eclipse user mailing list:
> Hi,
...
> Unfortunately I discovered that parsing of macros (e.g.
> add_definitions(-DFOO=1)) seems to be broken in version 1.12.2 while

I checked with one of my sample projects (C-inclpaths) here and it seems to
work (eclipse 2018-09/ CDT 9.5.3); at least the C-editor shows the expected
highlighting and macro-expansion hover.
Please note that the parser only runs if the CMakeCache.txt file has changed.
Does the problem still show up after you delete the CMakeCache.txt file (or
better the build directory) and re-run the build?


> parsing of includes (-I and --system) works just fine. To make sure it's

These could also come from the CTD GCC builtins detector. Could you try to
narrow the issue with just the CMAKE_EXPORT_COMPILE_COMMANDS Parser enabled?


> not a personal config failure I followed the "User Guide -> Getting
> Started" instructions closely but the plugin is still not recognizing any
> macro definitions even though they occur in the "compile_commands.json"
> file. I also tried the sample projects [1] but even their macros aren't
> parsed.

Hmmh, weird. I'm aware of the cmake support that was introduced in CDT 9.3 and
claims to be /good/. Could it be that this support kicks in and prevents the
CMAKE_EXPORT_COMPILE_COMMANDS Parser from being run?


...
> Is this a known problem or should I open a new Issue for this?

It is a new problem, but before opening an issue, culd you check your
workbench error log for any traces of the problem?


> I used two different setups but the problem occurred on both of them:
>
> Setup 1:
> - Gentoo Linux 4.14.65 amd64
...
> - cmake 3.9.6
>
> Setup 2:
> - Windows 7
...
> - cmake 3.12.1

My setup:
- openSUSE 42.3
- cmake 3.5.2

The compile_commands.json file from the C-inclpaths project contains the line

"command": "/usr/bin/cc -DMACRO_FROM_COMMANDLINE=2 -I/home/me/devel/my/
cmake4eclipse-sample-projects/C-inclpaths/build/Debug -I/home/me/devel/my/
cmake4eclipse-sample-projects/C-inclpaths/../../../INCLUDE -I/home/me/devel/
my/cmake4eclipse-sample-projects/C-inclpaths/build/Debug/src -fmessage-
length=0 -g -o CMakeFiles/main.dir/main.c.o -c /home/me/devel/my/
cmake4eclipse-sample-projects/C-inclpaths/src/main.c",

Could you check the same file with your setup? Maybe newer cmake now produces
output that is not recognize by the parser.

Martin

--
Cd wrttn wtht vwls s mch trsr.


Torsten Wylegala

unread,
Nov 5, 2018, 5:05:23 PM11/5/18
to cmake4ecl...@googlegroups.com
On 11/05/2018 09:07 PM, Martin Weber wrote:
> Am Montag, 5. November 2018, 14:43:16 CET schrieb torstenwylegala via
> cmake4eclipse user mailing list:
>> Hi,
> ...
>> Unfortunately I discovered that parsing of macros (e.g.
>> add_definitions(-DFOO=1)) seems to be broken in version 1.12.2 while
> I checked with one of my sample projects (C-inclpaths) here and it seems to
> work (eclipse 2018-09/ CDT 9.5.3); at least the C-editor shows the expected
> highlighting and macro-expansion hover.
Well that's interesting. You mentioning "highlighting" and
"macro-expansion-hover" made me check again if this might work in my
C-Editor and indeed it works.
I started to question the macro parsing at a point where it definitely
didn't work (properly because of some unrelated self made problems) and
from that point on I kept checking the "Project Properties -> C/C++
General -> Preprocessor Include Paths, Macros etc. -> Entries ->Setting
Entries -> CMAKE_EXPORT_COMPILE_COMMANDS Parser -> Dropout-Menu" for my
macros to appear there. I took it as evidence that the macro parser
didn't work properly because they didn't and still don't appear there.
Obviously the parser is working and the original problem is thereby
solved but the missing macro entries in the Dropout-Menu remain.
Therefore my new question is if they are even supposed to appear there
in the first place or if this wasn't implemented (Includes are shown
correctly in the list)?
> Please note that the parser only runs if the CMakeCache.txt file has changed.
> Does the problem still show up after you delete the CMakeCache.txt file (or
> better the build directory) and re-run the build?
>
>
>> parsing of includes (-I and --system) works just fine. To make sure it's
> These could also come from the CTD GCC builtins detector. Could you try to
> narrow the issue with just the CMAKE_EXPORT_COMPILE_COMMANDS Parser enabled?
>
>
>> not a personal config failure I followed the "User Guide -> Getting
>> Started" instructions closely but the plugin is still not recognizing any
>> macro definitions even though they occur in the "compile_commands.json"
>> file. I also tried the sample projects [1] but even their macros aren't
>> parsed.
> Hmmh, weird. I'm aware of the cmake support that was introduced in CDT 9.3 and
> claims to be /good/. Could it be that this support kicks in and prevents the
> CMAKE_EXPORT_COMPILE_COMMANDS Parser from being run?
>
I saw you mentioning the "native" cmake support in CDT 9.3 in another
thread but I can't find a whole lot about it. Only one reference on the
release review of CDT 9.3.0 [1] and two references at an eclipse list
[2]. Do you know where I could find more information about that or could
you explain briefly how their approach differs from yours?
Btw thank you for taking the time with your detailed answer.

Best
Torsten

[1]
https://projects.eclipse.org/projects/tools.cdt/reviews/9.3.0-release-review
[2] https://www.eclipse.org/lists/cdt-dev/msg32065.html

Martin Weber

unread,
Nov 6, 2018, 3:02:58 PM11/6/18
to cmake4ecl...@googlegroups.com
Am Montag, 5. November 2018, 23:05:23 CET schrieb 'Torsten Wylegala' via
The parser does only run
- at the first build after launching eclipse
- if the timestamp of the json file is newer than the timestamp of the internal
cache.

One reason why the macros do not show up in the Dropout-Menu is that they are
attached to a file, whereas the drop-down box presumably shows only entries
attached to the project.
Include path show up in the Dropout, because the plugin also attaches these at
the project level, to make the Include-Folder in the project explorer work
(which has its own issues with updating:-(

...
> I saw you mentioning the "native" cmake support in CDT 9.3 in another
> thread but I can't find a whole lot about it. Only one reference on the

CDT`s cmake support is a separate feature which has to be installed manually.
I tried it about a year ago and was disappointed. I had to press a button that
launches cmake-gui to generate the makefiles. No auto-generation of the
makefiles, no cross-platform support... (Of course, I am biased here)

> release review of CDT 9.3.0 [1] and two references at an eclipse list
> [2]. Do you know where I could find more information about that or could
> you explain briefly how their approach differs from yours?

- cmake4eclipse started in Nov. 2013, I think it is mature now.
- cmake4eclipse design goal: See Why cmake4eclipse? in the project`s
Readme.md.
- CMAKE_EXPORT_COMPILE_COMMANDS Parser recognizes a wide range of C/C++
compilers: gcc, clang, their cross-compiler variants; MSs cl, Intels icl. The
CUDA languages with NVida`s nvcc is also supported.
- Compiler built-in detection is supported for gcc, clang, their cross-
compiler variants and nvcc.
- cmake4eclipse is aimed to make your eclipse project files usable cross-
platform.

- Concerning CTD`S support, I found this <https://www.eclipse.org/forums/
index.php/t/1086492/>, <https://bugs.eclipse.org/bugs/show_bug.cgi?id=174176>
- CDT`S first cmake support was released in 2017.

Hannes Vogt

unread,
Nov 6, 2018, 3:46:31 PM11/6/18
to cmake4ecl...@googlegroups.com
Hi Martin,

as a daily user of your plugin, I can confirm that it is indeed very
mature. It works nicely. I was wondering if you have any plans of
contributing (parts of) cmake4eclipse to CDT. I remember an old
discussion in the cdt mailing list where this was discussed. It would be
very nice if more people could benefit from the plugin directly,
especially the compile_commands.json parser and the CMake editor.

The CMake support in CDT (it is officially part of the 2018-06 CDT
release) is really very basic...

Concerning the other dicussion in this thread: I think the parser is
only run on a successful build in recent releases? Did this change? One
of my projects has a compile time of 20 minutes, therefore I sometimes
don't want to rebuild, but still refresh the includes. Would it be
possible to run the parser also after an interrupted build (if the
compile_commands.json timestamp changed). In older releases I could
force the parsing by clicking apply on the "Providers" properties page
of the project. This doesn't work anymore.

Cheers,
Hannes

Martin Weber

unread,
Nov 7, 2018, 1:47:14 PM11/7/18
to cmake4ecl...@googlegroups.com
Am Dienstag, 6. November 2018, 21:46:28 CET schrieb Hannes Vogt:
> Hi Martin,
>
> as a daily user of your plugin, I can confirm that it is indeed very
> mature. It works nicely. I was wondering if you have any plans of
> contributing (parts of) cmake4eclipse to CDT. I remember an old
> discussion in the cdt mailing list where this was discussed. It would be
> very nice if more people could benefit from the plugin directly,
> especially the compile_commands.json parser and the CMake editor.

Concerning CMakeEd, I already offered to have it under the Eclipse umbrella on
the CDT mailing list.
For cmake4eclipse I have no plans to add it to CDT.

...

> Concerning the other dicussion in this thread: I think the parser is
> only run on a successful build in recent releases? Did this change? One

If that behavior changed, it was a change in CDT. The parser implements the
BuildOutputScanner interface to integrate with CDT. So its up to CDT to run it
or not.

> of my projects has a compile time of 20 minutes, therefore I sometimes
> don't want to rebuild, but still refresh the includes. Would it be
> possible to run the parser also after an interrupted build (if the
> compile_commands.json timestamp changed). In older releases I could

As already said, that is entirely controlled by CDT. If CDT decides to NOT run
its BuildOutputScanner if the build is aborted, there could nothing be done to
help here.

> force the parsing by clicking apply on the "Providers" properties page
> of the project. This doesn't work anymore.

This did never trigger (re-)parsing of the compile_commands.json, it only
fetches the (internally cached) macros and include dirs from the providers.
The Providers tab does not seem to be aware of Provider implementations (like
mine) that need a build to run to detect the macros and include dirs. This
might explain why the apply button does not work sometimes.

/Martin

barret...@gmail.com

unread,
Mar 22, 2019, 1:19:31 PM3/22/19
to cmake4eclipse user mailing list
Interesting - So I have opened the example project and defining a macro in the cmakelists.txt is working fine. Switch to my project (in the same workspace) and the variable isn't indexed in my project. The compile_commands.json file is correct but the parser doesn't seem to pick up on my macros (hover expansion not working and syntax highlighting not correct).

Obviously this feature is working correctly but I'm just not implementing it right. Anyone have an idea I could try?

Martin Weber

unread,
Mar 22, 2019, 4:21:31 PM3/22/19
to cmake4ecl...@googlegroups.com
Is the macro showing up in the project properties at
C/C++ General | Preprocessor Include Path etc | Entries tab?

If so, CMAKE_EXPORT_COMPILE_COMMANDS Parser does recognize the macro, but the
syntax highlighting code in CDT does not pick it up (or does takes time to
pick it up).

barret...@gmail.com

unread,
Mar 25, 2019, 9:32:30 AM3/25/19
to cmake4eclipse user mailing list
No the macro doesn't show up under the provider entries. However in the example project (inclpaths) it doesn't show up either. Based off previous conversations in this thread, I thought that it was normal behavior to NOT show up there? Am I mistaken?

Martin Weber

unread,
Mar 26, 2019, 5:31:31 PM3/26/19
to cmake4ecl...@googlegroups.com
Am Montag, 25. März 2019, 14:32:30 CET schrieb barret...@gmail.com:
> On Friday, March 22, 2019 at 3:21:31 PM UTC-5, fifteenknots505 wrote:
> > Am Freitag, 22. März 2019, 18:19:31 CET schrieb barret...@gmail.com:
> > > Interesting - So I have opened the example project and defining a macro
> > > in
> > > the cmakelists.txt is working fine. Switch to my project (in the same
> > > workspace) and the variable isn't indexed in my project. The
> > > compile_commands.json file is correct but the parser doesn't seem to
> > > pick
> > > up on my macros (hover expansion not working and syntax highlighting not
> > > correct).
> > >
> > > Obviously this feature is working correctly but I'm just not
> > > implementing it right. Anyone have an idea I could try?
> >
> > Is the macro showing up in the project properties at
> > C/C++ General | Preprocessor Include Path etc | Entries tab?
> >
> > If so, CMAKE_EXPORT_COMPILE_COMMANDS Parser does recognize the macro, but
> > the syntax highlighting code in CDT does not pick it up (or does takes
> > time to pick it up).
>
> No the macro doesn't show up under the provider entries. However in the
> example project (inclpaths) it doesn't show up either. Based off previous

Weird, at least the macro should show up under the provider entries. But can't
reproduce here with CDT 9.5.5.
What is your CDT version?

barret...@gmail.com

unread,
Mar 28, 2019, 2:43:34 PM3/28/19
to cmake4eclipse user mailing list
Same.
I'm on Windows 10 (yuck). But I'm not sure if that could be the problem here or not... Looks like the projects are linux-centered but I didn't have to do anything fancy to get it to build successfully so - I'm not sure. What else should I look for?

15 knots

unread,
Mar 29, 2019, 8:32:13 AM3/29/19
to cmake4eclipse user mailing list
The OS should not matter.
What is your CDT version?

And NO, the example projects are NOT linux-centric.
> --
> 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.
> Visit this group at https://groups.google.com/group/cmake4eclipse-users.
> For more options, visit https://groups.google.com/d/optout.

barret...@gmail.com

unread,
Apr 2, 2019, 3:15:46 PM4/2/19
to cmake4eclipse user mailing list
Same version of CDT that you are using. 9.5.5

Martin Weber

unread,
Apr 2, 2019, 3:39:06 PM4/2/19
to cmake4ecl...@googlegroups.com
Am Dienstag, 2. April 2019, 21:15:45 CEST schrieb barret...@gmail.com:
> > Am Do., 28. März 2019 um 19:43 Uhr schrieb <barret...@gmail.com>:
> > > On Tuesday, March 26, 2019 at 4:31:31 PM UTC-5, fifteenknots505 wrote:
> > > > Am Montag, 25. März 2019, 14:32:30 CET schrieb barret...@gmail.com:
> > > > > On Friday, March 22, 2019 at 3:21:31 PM UTC-5, fifteenknots505
wrote:
> > > > > > Am Freitag, 22. März 2019, 18:19:31 CET schrieb
barret...@gmail.com:
> > > > > > > Interesting - So I have opened the example project and defining
> > > > > > > a macro
> > > > > > > in
> > > > > > > the cmakelists.txt is working fine. Switch to my project (in the
> > > > > > > same
> > > > > > > workspace) and the variable isn't indexed in my project. The
> > > > > > > compile_commands.json file is correct but the parser doesn't
> > > > > > > seem to
[...]
> > > > > No the macro doesn't show up under the provider entries. However in
> > > > > the
> > > > > example project (inclpaths) it doesn't show up either. Based off
> > > > > previous
> > > >
> > > > Weird, at least the macro should show up under the provider entries.
> > > > But can't reproduce here with CDT 9.5.5.
> > > > What is your CDT version?
> > > >
> > > > --
> > > > Cd wrttn wtht vwls s mch trsr.
> > >
> > > Same.
> > > I'm on Windows 10 (yuck). But I'm not sure if that could be the problem
> > > here or not... Looks like the projects are linux-centered but I didn't
> > > have to do anything fancy to get it to build successfully so - I'm not

Sorry, I#m a little confused. This thread`s topic is about picking up macros
for the indexer, but you say _to get it to build successfully_?

Have a look at the console view to check whether the project builds. There is
a CDT global build console which will show the build log (cmake and make).

barret...@gmail.com

unread,
Apr 4, 2019, 10:25:33 PM4/4/19
to cmake4eclipse user mailing list
Sorry for the confusion. I'm not having any issues building. That part works fine. It's just the indexer and syntax highlighting that isn't right.

Martin Weber

unread,
Apr 5, 2019, 3:39:09 PM4/5/19
to cmake4ecl...@googlegroups.com
Am Freitag, 5. April 2019, 04:25:33 CEST schrieb barret...@gmail.com:
> On Tuesday, April 2, 2019 at 2:39:06 PM UTC-5, fifteenknots505 wrote:
> > Am Dienstag, 2. April 2019, 21:15:45 CEST schrieb barret...@gmail.com:
> > > > Am Do., 28. März 2019 um 19:43 Uhr schrieb <barret...@gmail.com>:
> > > > > On Tuesday, March 26, 2019 at 4:31:31 PM UTC-5, fifteenknots505
wrote:
> > > > > > Am Montag, 25. März 2019, 14:32:30 CET schrieb
barret...@gmail.com:
> > > > > > > On Friday, March 22, 2019 at 3:21:31 PM UTC-5, fifteenknots505
> >
> > wrote:
> > > > > > > > Am Freitag, 22. März 2019, 18:19:31 CET schrieb
> >
> > barret...@gmail.com:
> > > > > > > > > Interesting - So I have opened the example project and
> > > > > > > > > defining
> > > > > > > > > a macro
> > > > > > > > > in
> > > > > > > > > the cmakelists.txt is working fine. Switch to my project (in
> > > > > > > > > the
> > > > > > > > > same
> > > > > > > > > workspace) and the variable isn't indexed in my project. The
> > > > > > > > > compile_commands.json file is correct but the parser doesn't
> > > > > > > > > seem to

Maybe the json file is not found. If so, some info messages get written to the
problem view.
You will have to enable info messages to see them.
Reply all
Reply to author
Forward
0 new messages