Author Topic: New CMake generator using Code::Blocks' internal build system  (Read 20764 times)

Offline Benjamin Eikel

  • Multiple posting newcomer
  • *
  • Posts: 12
New CMake generator using Code::Blocks' internal build system
« on: September 23, 2012, 01:37:11 pm »
Dear Code::Blocks community,

I am working on a new generator for CMake that creates a native Code::Blocks project (see the discussion "Using the internal Code::Blocks builder" on cmake-developers). In CMake, there exists already a generator for Code::Blocks, but this generates a Makefile and a Code::Blocks project using that Makefile. My new generator is already able to generate project files for simple CMake projects and build them using the internal build system of Code::Blocks.
Currently, I have the problem that I cannot start Code::Blocks without a graphical user interface. Every time I invoke Code::Blocks with a build target, it opens a console window showing the build output. I have found no way to suppress the window. I also found an old thread stating that there is no possibility to disable the GUI. Maybe the situation has improved in the last years. Is there a command-line-only invocation possible now?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: New CMake generator using Code::Blocks' internal build system
« Reply #1 on: September 23, 2012, 02:48:23 pm »
I am working on a new generator for CMake that creates a native Code::Blocks project (see the discussion "Using the internal Code::Blocks builder"
I was in contact with the author of the other builder - nice to hear that you decide to go for it! Its way better than the Makefile based one (although it was working fine for me). [OT: Send greetings to Alex - I know him quite well... ;-)]

I also found an old thread stating that there is no possibility to disable the GUI. Maybe the situation has improved in the last years. Is there a command-line-only invocation possible now?
We do have a batch build option, which uses minimal UI (see here: http://svn.berlios.de/wsvn/codeblocks/trunk/src/batch_build_core for an example how to use it). However, even the tiny batch windows uses UI.

We have plans for a non-UI version of the builder and there is a working branch of Code::Blocks w/o UI here: http://svn.berlios.de/wsvn/codeblocks/branches/codeblocks_console
It is sync'd with trunk from time to time, but its not something many people use. But as I said: It works, but is not something "ready" yet.

however, this should be of no concern for the project builder, because the project file won't be affected by whether the IDE uses UI or not.

Why are you asking? Why do you need a non-UI builder?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: New CMake generator using Code::Blocks' internal build system
« Reply #2 on: September 23, 2012, 02:52:34 pm »
...edit: I just read the thread you posted - I guess I know why you are asking, because of this:
> This is more or less necessary so cmake can run its test suite to verify
> the generator works correctly.

Right?

Well, the batch window closes automatically at end (which is actually an option) and returns an error code which you can use for verification of a successful build. So if the need is just to run a C::B build process externally with feedback, this is possible. If you insist it shall not have any UI (i.e. for console build server) - only with the branch. But for my understanding for cmake the first one applies...

Maybe Alex can make a statement here... AFAIK he is even member of this forum... or was at least...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Benjamin Eikel

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: New CMake generator using Code::Blocks' internal build system
« Reply #3 on: September 23, 2012, 03:30:24 pm »
...edit: I just read the thread you posted - I guess I know why you are asking, because of this:
> This is more or less necessary so cmake can run its test suite to verify
> the generator works correctly.

Right?
Right, this is one reason. For example, on the testing server you will not have any possibility to run applications that need a GUI.

Furthermore, CMake runs many tests in its configurations phase (e.g. checking if the compiler works correctly). Projects can add further tests (e.g. checking if a library contains a given symbol, if a header can be used for compilation). Most of these tests generate a project using the current generator (in my case the new Code::Blocks generator). Then the project is build to execute the test (in my case, a Code::Blocks window pops up and closes after a short while). This makes the whole process quite slow and annoying.

Maybe I will check out the console-only branch you mentioned.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: New CMake generator using Code::Blocks' internal build system
« Reply #4 on: September 23, 2012, 05:02:09 pm »
Furthermore, CMake runs many tests in its configurations phase (e.g. checking if the compiler works correctly). Projects can add further tests (e.g. checking if a library contains a given symbol, if a header can be used for compilation). Most of these tests generate a project using the current generator (in my case the new Code::Blocks generator). Then the project is build to execute the test (in my case, a Code::Blocks window pops up and closes after a short while). This makes the whole process quite slow and annoying.
OK - but this sounds like an IDE is required to have a non-UI build process to make it into Cmake?! That would be new to me. I understand having a non-UI build its a "nice to have" thing, but it shouldn't be a requirement. I think there are plenty of IDE's around that do not support that. How do you handle the very common and famous Eclipse IDE for example? (I know Cmake supports it, too.) And was it really different at the time you did the C::B Makefile based generator?

So... Do you need this feature only temporarily for developing the generator and drive your (Cmake) tests, or is this really a hard requirement on the IDE? For the first case, the mentioned branch should be just fine (maybe Jens can do another merge before), but for the latter... ???
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Benjamin Eikel

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: New CMake generator using Code::Blocks' internal build system
« Reply #5 on: September 23, 2012, 05:31:49 pm »
OK - but this sounds like an IDE is required to have a non-UI build process to make it into Cmake?! That would be new to me. I understand having a non-UI build its a "nice to have" thing, but it shouldn't be a requirement. I think there are plenty of IDE's around that do not support that. How do you handle the very common and famous Eclipse IDE for example? (I know Cmake supports it, too.) And was it really different at the time you did the C::B Makefile based generator?
The old C::B Makefile generator as well as the Eclipse generator use the Makefiles to do the build. Therefore, you can call "make" instead of using the IDE. The generated project files are more or less an extra on top of the Makefile. Because I want to get rid of the Makefile, I cannot use this approach.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: New CMake generator using Code::Blocks' internal build system
« Reply #6 on: September 23, 2012, 06:40:40 pm »
[...]
the mentioned branch should be just fine (maybe Jens can do another merge before)
[...]

I will see what I can do.
Merging is not as easy as it would like it to be (too many other merges [debugger-branch and trunk]).

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: New CMake generator using Code::Blocks' internal build system
« Reply #7 on: September 24, 2012, 03:42:41 pm »
[...]
the mentioned branch should be just fine (maybe Jens can do another merge before)
[...]

I will see what I can do.
Merging is not as easy as it would like it to be (too many other merges [debugger-branch and trunk]).

Merging the branches was imposiible, nuch too much merge conflicts.

I created a new (local) branch and recreated the console-branch which is now (at the moment) a real child of trunk (might break again if xml-branch is merged).
I will try to do the merges more often, so it will not divert as much as it was.

@MortenMacFly and other devs:
should I create a complete new branch on the server (e.g. cb_headless) or should I delete the old one and recreate it (with the same name) from my new local branch ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: New CMake generator using Code::Blocks' internal build system
« Reply #8 on: September 24, 2012, 10:21:03 pm »
should I delete the old one and recreate it (with the same name) from my new local branch ?
Go for that, even deleted branches are still accessible afterwards.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: New CMake generator using Code::Blocks' internal build system
« Reply #9 on: September 25, 2012, 01:27:24 am »
The recreated console-branch should work with wx2.8 and wx2.9, using project-files or automake-system.

The changes are (as before) linux only.

Offline Benjamin Eikel

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: New CMake generator using Code::Blocks' internal build system
« Reply #10 on: September 25, 2012, 09:32:09 am »
Thank you for your efforts. I will try out the "codeblocks_console" branch as soon as possible and report back.

Offline Benjamin Eikel

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: New CMake generator using Code::Blocks' internal build system
« Reply #11 on: September 25, 2012, 08:29:11 pm »
I was able to retrieve and build Code::Blocks from the codeblocks_console branch. I have a problem now. When running codeblocks_con to build the project, I get the following error message:
Code: [Select]
codeblocks_con --build --target=Debug MyProject.cbp
Scanning for plugins in /home/benjamin/.codeblocks/share/codeblocks/plugins
Loaded 0 plugins
Scanning for plugins in /usr/lib/codeblocks/plugins
Loaded 0 plugins

Error:
Deactivating the compiler plugin is most unwise.
When using codeblocks instead, it works. How do I activate the compiler plugin?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12124
    • Travis build status
Re: New CMake generator using Code::Blocks' internal build system
« Reply #12 on: September 25, 2012, 08:38:45 pm »
How many versions of C::B do you have installed?
Generally when testing things it is a good idea to use the --prefix option of the configure script.
Personally I do this for all software I don't install using a package manager (--prefix=/home/myname/software/softname).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: New CMake generator using Code::Blocks' internal build system
« Reply #13 on: September 25, 2012, 09:25:43 pm »
What exact steps did you do for compiling ?
Where is libcon_compiler.so located ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: New CMake generator using Code::Blocks' internal build system
« Reply #14 on: September 25, 2012, 09:32:00 pm »
The recreated console-branch should work with wx2.8 and wx2.9, using project-files or automake-system.
Great work, Jens.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ