Author Topic: New Project Wizard - integrating with CMake  (Read 768 times)

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
New Project Wizard - integrating with CMake
« on: May 19, 2020, 11:49:56 am »
Hi all,

We have a build system that is entirely Cmake based. I'm trying to figure out a way of integrating that with the c::b project wizard so someone can create a project in c::b that uses the existing build system. I was originally intending to create the entire project natively in the wizard (my prototypes work fine so I have some experience of writing the wizard code), but its been requested to use the underlying cmake system.

So, CMake has an option to create C::B project files. So what I was considering:

Run Project Wizard.
Create a build folder in the project
Wizard then creates a CMakeList.txt for the new project
Runs CMake -G"CodeBlocks - Unix Makefiles" ..   which create a .cbp file from our existing Cmake structure (we have a tree of code outside the C::B project) - this .cbp will end up in the build folder.
Add any extra information to the project (e.g. debugger, compiler etc)


My current reading of the situation makes we wonder whether this is possible-  the wizard create its own project, it cannot load one that has just been created by an external script. Anyone have any hints and tips? I'm happy to make changes to base C::B code if necessary to make this all work. Or is there a better may to integrate our CMake and C::B?

Thanks

Jimbo



Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - integrating with CMake
« Reply #1 on: May 19, 2020, 12:36:47 pm »
I am wondering whether one option is to add a new function in wiz.ccp that specifically handles my project wizard, and instead of creating a project, runs the CMake scripts on the generated CMakeList.txt file and then loads the resulting project.

It would be better to do it all in the plugin, but I suspect that isn't possible, and I already have changes to the C::B code base for other stuff anyway, so customising code is not an issue.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12695
    • Travis build status
Re: New Project Wizard - integrating with CMake
« Reply #2 on: May 19, 2020, 07:02:36 pm »
Why do you need a project wizard for this in the first place?
The idea is that cmake would create the project not vice versa.
Currently the cbp file and the root CMakeLists.txt file are at totally different locations.
One is next to the source code (CMakeList.txt) and the other (cbp file) is next to the build files.

Also actual project files become irrelevant once you start using cmake.
The whole project UI is useless.
Adding/removing/renaming files won't work because the CMakeLists.txt must be adjusted. Running cmake on adjusted CMakeLists.txt would regenerate the project.
Build options don't make sense. The executable paths don't make sense.

QtCreator and CLion have cmake integration, but I've never used them, so I don't know how well they've implemented this.
There is something called cmake server which is meant to allow IDEs to integrate with cmake, but I've not researched it yet.

I'm not sure how to handle this correctly, but I'm pretty sure that a wizard is a bad idea.
(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 jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - integrating with CMake
« Reply #3 on: May 20, 2020, 12:39:36 pm »
Why do you need a project wizard for this in the first place?
The idea is that cmake would create the project not vice versa.
Currently the cbp file and the root CMakeLists.txt file are at totally different locations.
One is next to the source code (CMakeList.txt) and the other (cbp file) is next to the build files.

Also actual project files become irrelevant once you start using cmake.
The whole project UI is useless.
Adding/removing/renaming files won't work because the CMakeLists.txt must be adjusted. Running cmake on adjusted CMakeLists.txt would regenerate the project.
Build options don't make sense. The executable paths don't make sense.

QtCreator and CLion have cmake integration, but I've never used them, so I don't know how well they've implemented this.
There is something called cmake server which is meant to allow IDEs to integrate with cmake, but I've not researched it yet.

I'm not sure how to handle this correctly, but I'm pretty sure that a wizard is a bad idea.

Starting to get that impression.

We have a build system that uses Cmake. But it's difficult for first time users to comprehend, so looking at using C::B to give them an easy in. Sticking a project wizard in was my original plan (this was before a load of Cmake stuff was generated elsewhere), but now the Cmake stuff is there, my original wizard isn't really what is needed.  What we want is the minimum number of clicks between starting the IDE and getting hello_world out the other end. I suppose the closest example (although not that close) would be something like the Arduino IDE, it's really easy to get from first install to getting results. Having to set up projects, debuggers etc is all done for you. Hence trying to do something similar with C::B's using wizards.

I've started hacking the C::B code (as well as the wizard scripts) to do something like what I described above so will see what is possible. It may be we will have to drop C:B completely and take a different approach, which would be a shame.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12695
    • Travis build status
Re: New Project Wizard - integrating with CMake
« Reply #4 on: May 20, 2020, 06:57:45 pm »
The minimal number of clicks is:
1. ctrl-shift-n for new files
2. save in your project folder as CMakeLists.txt
3. type some basic cmake stuff
4. run cmake to generate the cbp file
5. open the cbp file.

I guess all these steps would require a cmake-wizard kind of plugin, but it probably could be made with a squirrel script.

What is your final goal? What do you use C::B for?
(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 jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: New Project Wizard - integrating with CMake
« Reply #5 on: May 20, 2020, 07:18:24 pm »
The minimal number of clicks is:
1. ctrl-shift-n for new files
2. save in your project folder as CMakeLists.txt
3. type some basic cmake stuff
4. run cmake to generate the cbp file
5. open the cbp file.

I guess all these steps would require a cmake-wizard kind of plugin, but it probably could be made with a squirrel script.

What is your final goal? What do you use C::B for?

Cannot say much at the moment I am afraid! Usage is as an all in IDE, should be very easy to go from install to first program, with a decent debugger interface.