Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: fruitCode on November 15, 2019, 04:13:20 pm

Title: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on November 15, 2019, 04:13:20 pm
Hello,

I have a project that is set-up for cmake. Cmake offers the possibility to generate a project file for codeBlocks.
When I generate a project file and open it I see my project files in the Projects workspace tree.
I can also trigger a project compilation by hitting CTRL-F9, it works like a charm.
I get some build errors in the "Build log" window in the bottom of the screen but I cannot click them. I expect that I can click them and that codeBlocks will open that specific file at the line where the error is reported.
I tried this using ninja and make as a build tool, both result in errors not being clickable.
An error looks like this:
"D:\Sources\git-repos\g0046-acu-mh_firmware_acm_2\03_Modules\01_CU_PlatForm\03_Implementation\include\ghdr\Compiler.h",27  Error[Pe020]:
          identifier "__huge" is undefined
  extern __huge U8BIT *CUBaseAddress;


I've used codeBlocks quite a lot in the past and I remembered this was working. Am I wrong? Are there any settings involved that can screw this up?

I tried using codeBlocks 17.12 and 13.12, both the portable version.

thanks

My question is: is
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on November 15, 2019, 05:45:05 pm
I see my post was cut-off somehow..
So my question is: should it work? (clickable errors) and are there any settings related that can influence this behavior? (incorrect settings screwing this up)
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: stahta01 on November 15, 2019, 07:51:34 pm
Are you using a normal CB project or a custom makefile cb project?

I believe that feature is not supported with custom makefile cb projects.

Tim S.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: osdt on November 15, 2019, 08:33:17 pm
AFAIK this feature was never implemented for the "Build log". Use the "Build messages" tab to have CB show the file/line in question.

Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: oBFusCATed on November 16, 2019, 10:55:54 am
What is the compiler which you're using? The errors/warnings are detected using regular expressions. Most probably none of the regexs matches the line you've posted.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on November 18, 2019, 10:47:21 am
Are you using a normal CB project or a custom makefile cb project?

I believe that feature is not supported with custom makefile cb projects.

Tim S.

I use a CB project file that is generated by the cmake utility so I guess its a custom one. I use cmake because I build for different targets (PC host for unit and integration tests and a simulator application) and an embedded target running on an ARM processor. Cmake is a great utility to assist in these kind of setups besides that it offers out of source building.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on November 18, 2019, 10:48:51 am
AFAIK this feature was never implemented for the "Build log". Use the "Build messages" tab to have CB show the file/line in question.

In doesn't work in that tab either
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on November 18, 2019, 10:54:49 am
What is the compiler which you're using? The errors/warnings are detected using regular expressions. Most probably none of the regexs matches the line you've posted.

I am porting code from V850 to ARM, I use an IAR compiler but as an alternative path I also use the GCC ARM compiler (as cmake makes it really easy to have these different setups with fi different compilers for same project - yes I am a fan of it)
Your comment made me think so I tried with the GCC ARM compiler and yes, there it works like a charm. Thanks for hinting!

My conclusion is that the regex don't seem to match the IAR syntax
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: oBFusCATed on November 18, 2019, 07:44:36 pm
You can add a IAR compiler and then you can tell cmake to use it as the compiler for your project. See https://cmake.org/cmake/help/v3.16/variable/CMAKE_CODEBLOCKS_COMPILER_ID.html

If you make a IAR setup we'll be happy to review and accept a patch. :)
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on December 16, 2019, 05:39:06 pm
Any hints where to find info on how to make an IAR setup? Glad to make one.. Checked the help of C::B but there I could'nt find it, or I overlooked..?

To be clear, I want C::B to build my project still to be build using the makefile/ninja file (generated via cmake) as my project also runs on a jenkins build server.
When fixing some errors, doing changes I want to use C::B IDE (locally)
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: stahta01 on December 16, 2019, 09:21:00 pm
To be clear, I want C::B to build my project still to be build using the makefile/ninja file (generated via cmake) as my project also runs on a jenkins build server.
When fixing some errors, doing changes I want to use C::B IDE (locally)

Do you expect the errors to be clickable and go to code line with error?

Edit: Remove part of the quote because it might mislead.

Tim S.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: oBFusCATed on December 17, 2019, 09:20:31 am
Any hints where to find info on how to make an IAR setup? Glad to make one.. Checked the help of C::B but there I could'nt find it, or I overlooked..?
Probably start with these files:

share/codeblocks/compilers/options_common_re-iar.xml
share/codeblocks/compilers/options_iar8051.xml
share/codeblocks/compilers/options_iararm.xml
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: stahta01 on December 18, 2019, 05:22:36 am
To be clear, I want C::B to build my project still to be build using the makefile/ninja file (generated via cmake) as my project also runs on a jenkins build server.
When fixing some errors, doing changes I want to use C::B IDE (locally)

Do you expect the errors to be clickable and go to code line with error?

Edit: Remove part of the quote because it might mislead.

Tim S.

I just tried building wxWidgets samples using the wxWidgets makefiles and it worked after I added the files
to the CB project. Did you try that?

It worked means the errors were clickable and opened the files.

Edit2: I am using the native makefile.gcc not ones made by cmake.

Tim S.
 
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: stahta01 on December 18, 2019, 05:46:52 am
And, the clickable error/warning requires a valid filename and line number in the first two columns of the "build messages".

Edit: The file path if relative likely needs to be relative to the CB project file location.
If not relative, needs to be in the CB project and likely needs to be the only one with that filename.

Tim S.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on December 19, 2019, 05:27:31 pm
@oBFusCATed Thanks for hinting me about those xml files. Then I noticed there is already the IAR ARM compiler defined, just what I need..

Q1: Where to find the ID number for that compiler setting to be used for CMAKE_CODEBLOCKS_COMPILER_ID ?

When is set this compiler for my project it still didn't work.
Then I went to menu Settings->Compiler
Selected "IAR ARM Compiler" as the selected compiler
Went to the tab "Other settings" and click button "advanced options..."
Click tab "Output parsing"
Then I adjusted the regular expression for "Compiler error" to "(.*)",([0-9]+)[ \t]+Error\[(.*)\]:.*" and then it works
I don't know what regex was there by default but it makes no sense to me...?

Q2: How to parse multi line error messages? The messages are spanned over 3 lines, first line contains file name and line number, second line contains the actual error message and the thirdth line contains the source line where the error is about. I need to match the second line to get the error message.. Tried to use \n in the regex but that didn't work. is it capable of processing multiple lines?

Thanks so far! it really helped me forward.
<rant> Tried the bloated eclipse in the meantime but that was a bad adventure.. Huge download, slow performance and it didn't work either.. (that is error clickable) despite I installed the error parsers provided by IAR. Found some hints on eclipse forums but the interface was totally changed so they were unusable <\rant>
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: oBFusCATed on December 19, 2019, 08:39:29 pm
Is it capable of processing multiple lines?
I don't think this is possible. The compiler output is processed line by line. Generally GCC and Clang also have moved to multiline error message, so we'll have to tackle this problem sooner or later.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on December 20, 2019, 09:37:06 am
Allright, no multi-line processing yet.

To complete this post for later reference; I could not find references for CMAKE_CODEBLOCKS_COMPILER_ID in the manual. But they are just sequence numbers from the compiler list that you see in codeBlocks when selecting a compiler for your project. In my case "IAR ARM Compiler" is the 29th entry in the list so I added the following line to my CMakeLists,txt and that works like a charm!

SET(CMAKE_CODEBLOCKS_COMPILER_ID 28)

(Note: entry number is 28 because list count starts at 0)
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: oBFusCATed on December 20, 2019, 09:41:39 am
Hm, this is bad. It should be the short string as stored in the project file.
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on January 02, 2020, 11:13:20 am
You are right, I was mistaken.
What you have to add to your cmake file is:

SET(CMAKE_CODEBLOCKS_COMPILER_ID "iararm" CACHE STRING "Preferred codeblocks compiler ID")

This will generate a codeblocks project file where the compiler is set as IAR ARM
Title: Re: errors not clickable for cmake generated project using ninja or make
Post by: fruitCode on January 02, 2020, 11:18:52 am
Another update here for future reference. I had a look at the sources of codeblocks, it seems that error regex parsing is done per line. So to my opinion its not a quick fix to have multi-line regex processing as it takes quite some edits..

In the meantime I found a work-around, the IAR ARM compiler (iccarm) has an option --no_wrap_diagnostics that forces the error messages to be one line. The corresponding regex is then:
"(.*)",([0-9]+)[ \t]+Error\[(.*)\]:[ \t]*(.*)

Where the sub-expression indices are:
Message: 3
Additional message: 4
Filename: 1
Line: 2

Hope this helps others while configuring for IAR ARM