Author Topic: C::B Workspace/project to cmake or premake?  (Read 3518 times)

Offline cacb

  • Regular
  • ***
  • Posts: 484
C::B Workspace/project to cmake or premake?
« on: November 14, 2020, 10:20:05 am »
Hi, this may be a naive question, but anyway....

I have lots of Code::Blocks workspaces with several projects dependent on each other. I find this way of working quite excellent so that is fine and I want to keep it that way. My projects use C::B global variables a lot.

Now someone approached me and said they want to build my stuff using CMake . But I don't find it tempting to use CMake as a build system during development (even within C::B), but I can see it would be nice to offer as a "deployment build system". 

Therefore: Have anyone considered automatic generation of CMake files (CMakeLists.txt) or similar for premake from Code::Blocks workspace and project files? I know cbp2make exists for plain make files, so what I am asking for would be kind of similar, but targeting CMake /Premake.

A C::B plugin that allowed export of a C::B workspace to CMake or Premake would bee nice...

Thoughts?


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #1 on: November 14, 2020, 12:12:04 pm »
I doubt it would be possible or it would work well.
Fitting the C::B model of projects to CMakes might not match 1:1 and then there would be problems.
Also CMake requires the build system to be out-of-tree and most CB projects are in-tree.

CMake is meant to be used the other way - you write the cmake files by hand and it generates the ide projects/build system.
(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 cacb

  • Regular
  • ***
  • Posts: 484
Re: C::B Workspace/project to cmake or premake?
« Reply #2 on: November 14, 2020, 12:43:45 pm »
I doubt it would be possible or it would work well.
I guess that is a "no" to my question if anyone have given it a thought for C::B, but I have seen discussions elsewhere of the same idea. But of course, the fact that I have not found such a tool could mean you are right. But I am not convinced.

CMake is meant to be used the other way - you write the cmake files by hand and it generates the ide projects/build system.
Of course I know that, but I disagree with this way of thinking, as maintaining the CMakeLists.txt (or premake equivalent) file would be a nightmare + several other arguments that I will not go into here. C::B projects are well defined in .cbp files, so I can't see why they can not be transformed into CMake or Premake input. If there is an argument about "out-of-tree", well then put the generated CMakeLists.txt (or premake equivalent)  file elsewhere.

In any case, it looks like my main question is answered: No such plugin or external tool exists. So if it becomes a real need, I probably have to create it myself.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #3 on: November 14, 2020, 12:54:57 pm »
If you cannot find it with a simple search in your favourite search engine or github, then probably it doesn't exists.

BTW: CMake is a lot more powerful than our own build system would ever be and it is slow and stupid, but that is how life work not-perfect solutions win at the end.
BTW2: The current integration of cmake is not ideal, it should be the other way round CB should parse cmakefiles and generate the projects somehow. Someday if I get to do the other build system (meson) I'll see if there is a better way. :)
(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 alexchen

  • Multiple posting newcomer
  • *
  • Posts: 78
Re: C::B Workspace/project to cmake or premake?
« Reply #4 on: December 18, 2020, 07:37:49 pm »
How about generating just simple Make files from CB?  This is our challenge:  we need to build the same source on multiple platforms, Windows, macOS and Linux. Both Windows and macOS's IDE, VS/Xcdoe, can launch the build with command line interface.  CB also has the capability to build from command line but it still needs to pop up a GUI window. If fails with requirement of GTK if I try to launch the command line build from a TTY console.  And we also encounter occasional CB crash in wxGTK library.  We would like to use CB for development build and be able to run Makefile in production builds. 
I remember seeing older version of CB that offers an option to export the project to Makefile.  Do I remember it wrong?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #5 on: December 18, 2020, 08:33:10 pm »
Search for cb2make.
(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 stahta01

  • Lives here!
  • ****
  • Posts: 7178
    • My Best Post
Re: C::B Workspace/project to cmake or premake?
« Reply #6 on: December 19, 2020, 12:10:34 am »
Search for cb2make.

cbp2make if I recall correctly
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #7 on: December 19, 2020, 08:57:41 am »
Yes, my mistake.
(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 cacb

  • Regular
  • ***
  • Posts: 484
Re: C::B Workspace/project to cmake or premake?
« Reply #8 on: December 20, 2020, 06:46:50 pm »
I remember seeing older version of CB that offers an option to export the project to Makefile.  Do I remember it wrong?
cbp2make should be available in your current installation, at least it is in mine. It may do what you want, but I never quite figured it out 100%

If I get the required time and inspiration I may try to prototype C::B to CMake or premake and see what happens. In my mind the C::B build system serves a different purpose (developer build system) compared to CMake or premake (deployment build system), so to me it makes sense to try. Even if it didn't work for all projects it might be useful.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #9 on: December 21, 2020, 01:14:13 pm »
@cacb:
CMake already supports Code::Blocks. With cmake it is the other way round - you write the build system and you get the project files. Generating cmake files from cbp files doesn't make too much sense. Also given the specifics of cmake it might be really hard task to do (cmake has some policies, which a cbp workspace might not follow and then it would be really hard to do the mapping).

There is a thing called cmake-server, but it seems deprecated O_O...
So now there is this https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html#manual:cmake-file-api(7)
Probably support for it might be more useful.

Meson is another build system which works similarly to cmake. And there the idea is to do an introspection of it (there is an api).

p.s. I plan in the distant future to make a ninja-build generator...
(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 cacb

  • Regular
  • ***
  • Posts: 484
Re: C::B Workspace/project to cmake or premake?
« Reply #10 on: December 22, 2020, 05:58:57 pm »
CMake already supports Code::Blocks. With cmake it is the other way round - you write the build system and you get the project files. Generating cmake files from cbp files doesn't make too much sense. Also given the specifics of cmake it might be really hard task to do (cmake has some policies, which a cbp workspace might not follow and then it would be really hard to do the mapping).
I know this is the conventional thinking, but I am turning it around anyway. To me, Code::Blocks is the natural development environment during lots of code changing, source files coming and going. For this I am using C::B project files, and I am not willing to give that up and somehow use CMake instead during development.

With released code the situation is different, with stable source files and end user building the software. In that scenario, something like CMake, Premake (or Meson as you mentioned) makes more sense. So to me it does make sense to derive e.g. CMakeLists.txt from Code::Blocks project files. Now, you are probably right to say this is not possible in all cases and I get that. But if I am able to do it for my projects given some rules of how I set up project files, and maybe some user input when generating CMake files I can live with that just fine.


I have almost zero experience with creating CMakeLists.txt, but when I tried yesterday it appeared you have to list all the source files explicitly, so that alone is a motivation for deriving from a Code::blocks project file. Then there are other things you can extract, such as target type, compiler options and dependencies. I will think more about it and experiment.


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: C::B Workspace/project to cmake or premake?
« Reply #11 on: December 22, 2020, 06:26:56 pm »
It seems that you have experience only with going the project way.
You have to gain some native cmake experience before you could make good decisions what is best or usable.
(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!]