Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Code::Blocks project from the cmake file?

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...

like image 381
Karnivaurus Avatar asked Jun 03 '16 15:06

Karnivaurus


People also ask

Does CodeBlocks support CMake?

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.

How do I build a project using CMake?

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.


2 Answers

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.

like image 66
Vtik Avatar answered Sep 21 '22 14:09

Vtik


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 :)

like image 24
Sorann753 Avatar answered Sep 21 '22 14:09

Sorann753