I would like to use the Code::Blocks IDE to build a C++ project based on a CMakeLists.txt
file. Previously, I was using Qt Creator, where I could open a CMakeLists.txt
file directly, which would create a project. I could then define the build commands, eg. cmake ../src
followed by make -j8
. This would run cmake
on the CMakeLists.txt
file, and then run make
on the makefile
.
How can I do something similar in Code::Blocks? If I try to create a new project, it gives me the option of creating an empty project, but then I am stuck as to where to go next...
Generates CodeBlocks project files. Project files for CodeBlocks will be created in the top directory and in every subdirectory which features a CMakeLists. txt file containing a project() call.
Run the cmake executable or the cmake-gui to configure the project and then build it with your chosen build tool. Run the install step by using the install option of the cmake command (introduced in 3.15, older versions of CMake must use make install ) from the command line, or build the INSTALL target from an IDE.
It's similar but you have to specify the compiler, supposing that you have a folder project/build and project/src and your CMakeLists.txt is under /project. Then your commands should be something as the following :
$ cd build/
$ cmake .. -G"CodeBlocks - Unix Makefiles"
you will have your CodeBlocks project created on the /build.
Code::Blocks, has its own .cbp files which do the same things as Makefile automatically.
Therefore Code::blocks canot generate a Makefile, but you can build your project from an alredy existing Makefile, i've found a very good explaination of it on the code::blocks wiki. I do hope this will help you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With