Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using cmake-gui with Qt Creator

I started trying to convert a project to use CMake so that I could import the project into QtCreator to make use of the QtCreator IDE for this straight C code. This worked pretty nicely as far as giving me auto completions, code diving, etc etc.

I have had a bit of a time getting CMake to build the code as I expected, mostly because it was the first time I have been using it. I recently discovered that there is a cmake-gui that you can point at your source and it will show you the CMake variables and such. What is the proper way to actually use cmake-gui within QtCreator? When I just manually made my CMakelists.txt files within my project, it was enough to get the project in there. Should I just run Cmake-gui using locator and point it to those files? Should I keep the same build directory in cmake-gui that was created from QtCreator? Any tutorial links or guidance apprecaited - didnt find a whole lot googling.

like image 695
Derek Avatar asked Sep 12 '26 04:09

Derek


1 Answers

The way I use cmake-gui with QtCreator is this:

  1. Create a build directory and configure it with cmake-gui, like:

    cmake/project$ mkdir build
    cmake/project$ cd build
    cmake/project/build$ cmake-gui ..
    
  2. Open the CMakeLists.txt file in QtCreator, and set the build path to where you did the configuration:

    QtCreator with CMake-GUI

  3. Let QtCreator run the configuration by clicking "Run CMake", it will use the values you configured with cmake-gui in step 1:

    QtCreator with CMake-GUI step 2

  4. You are done :)

  5. When you need to reconfigure the CMake build, just fire up the command line, navigate to the build directory and re-run cmake-gui.

like image 116
Michal Kottman Avatar answered Sep 14 '26 19:09

Michal Kottman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!