Author Topic: CMakeLists.txt and Code::Blocks  (Read 2814 times)

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
CMakeLists.txt and Code::Blocks
« on: April 26, 2025, 08:24:06 pm »
Some C++ project are using CMakeLists.txt, to be honest I am not a fan of it, but how to compile such project with Code::Blocks?
I tried cmake-gui and was able to get as far, as this:



But what next?

Offline gd_on

  • Lives here!
  • ****
  • Posts: 823
Re: CMakeLists.txt and Code::Blocks
« Reply #1 on: April 27, 2025, 05:46:14 pm »
If you click on Finish, you obtain an other Window where you can click on Configure. To avoid some errors, it may be useful to adjust the version in the first line of the main CMakeLists.txt.
In the configure Window (in red to show you that some adjustments may be required), many fields are automatically filled but you can have to adjust manually a few ones as CMAKE_BUILD_TYPE, CMAKE_CODEBLOCKS_EXECUTABLE and eventually Compile and link options.
When you click on Generate button, a codeblocks .cbp file is generated. Here too, you can rework it manually.
« Last Edit: April 27, 2025, 06:49:07 pm by gd_on »
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #2 on: April 28, 2025, 02:37:48 pm »
If you click on Finish, you obtain an other Window where you can click on Configure. To avoid some errors, it may be useful to adjust the version in the first line of the main CMakeLists.txt.
In the configure Window (in red to show you that some adjustments may be required), many fields are automatically filled but you can have to adjust manually a few ones as CMAKE_BUILD_TYPE, CMAKE_CODEBLOCKS_EXECUTABLE and eventually Compile and link options.
When you click on Generate button, a codeblocks .cbp file is generated. Here too, you can rework it manually.
Have already clicked on Configure to get there, so gues have to select one of the options there.
When I select "Specify native compilers" and click "Next" geting to:



But no idea what to selct here.

When I select "Specify toolchain file for cross-compiling" and click "Next" geting to:



And when I select "Specify options for cross-compiling" and click "Next" geting to:


Offline gd_on

  • Lives here!
  • ****
  • Posts: 823
Re: CMakeLists.txt and Code::Blocks
« Reply #3 on: April 28, 2025, 06:05:45 pm »
I use the first option "Use default native compilers", so nothing to fill manually and almost everything is correctly set.
For cross compiling, I suppose you have to set manually a few things, but sorry, as I don't do that, I can't help you more.
Better have a look on a cmake forum if it exists.
« Last Edit: April 28, 2025, 06:08:05 pm by gd_on »
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #4 on: April 29, 2025, 01:10:06 pm »
I use the first option "Use default native compilers", so nothing to fill manually and almost everything is correctly set.
For cross compiling, I suppose you have to set manually a few things, but sorry, as I don't do that, I can't help you more.
Better have a look on a cmake forum if it exists.
Don't have native compilers, since I am using codeblocks-25.03mingw-nosetup. Gues have to use that "Specify native compilers" option, but have no idea what to select there.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 823
Re: CMakeLists.txt and Code::Blocks
« Reply #5 on: April 29, 2025, 02:07:11 pm »
As you have installed a C::B version with mingw, you have somewhere a C compiler (gcc), a C++ compiler (g++) and a fortran compiler (gfortran). So, what is the problem ? You have all you need.
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #6 on: April 29, 2025, 02:40:53 pm »
As you have installed a C::B version with mingw, you have somewhere a C compiler (gcc), a C++ compiler (g++) and a fortran compiler (gfortran). So, what is the problem ? You have all you need.
But which files and from which directory I have to select? Do I really need to select that fortran thing?

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 153
Re: CMakeLists.txt and Code::Blocks
« Reply #7 on: May 02, 2025, 02:57:06 am »
@gd_on:

CMake deprecated (disabled) c::b generators since release 3.27. While those generators are still listed for backwards capacity, the company says not to use them.

@gtafan:

Why are you trying to use CMake? C::B can create its' own project files. Do you have C::B installed yet? I noticed that you just downloaded it.

Regards.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 823
Re: CMakeLists.txt and Code::Blocks
« Reply #8 on: May 02, 2025, 10:21:57 am »
Quote
CMake deprecated (disabled) c::b generators since release 3.27
May be.
For me, I have only one or two old Cmake projects, and there was no C::B project given with those projects. So my experience with that is quite poor. Nevertheless, I verified a few days ago and the cbp generation with cmake-gui still work quasi automatically, with just a few manuals adjustments to the generated cbp file. My cmake/cmake-gui has been updated recently (version 4.01). May be those projects are quite simple to translate, so it's why it still works.
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #9 on: May 02, 2025, 03:23:49 pm »
After specifiing the compilers still got this error:

Quote
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
Configuring incomplete, errors occurred!

Without specifiing compilers there are some more errors.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CMakeLists.txt and Code::Blocks
« Reply #10 on: May 02, 2025, 03:26:34 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #11 on: May 02, 2025, 03:27:45 pm »

Why are you trying to use CMake? C::B can create its' own project files. Do you have C::B installed yet? I noticed that you just downloaded it.

Regards.
Have you read my first post? Defently don't want go generate cmake from C::B. Have an existing project using cmake, but would like to compile it with C::B. As you can read in some other my post, using nosetup version of C::B.

Offline gtafan

  • Almost regular
  • **
  • Posts: 147
Re: CMakeLists.txt and Code::Blocks
« Reply #12 on: May 02, 2025, 03:28:58 pm »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CMakeLists.txt and Code::Blocks
« Reply #13 on: May 02, 2025, 03:42:30 pm »
I use the first option "Use default native compilers", so nothing to fill manually and almost everything is correctly set.
For cross compiling, I suppose you have to set manually a few things, but sorry, as I don't do that, I can't help you more.
Better have a look on a cmake forum if it exists.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org