Project management. Customize CMake project.

Lecture



taxis

CMake is an alternative to qmake for automating the generation of a Makefile. It controls the process of compiling an application using simple configuration files called CMakeLists.txt files. CMake generates makefiles and workspaces that can be used in the compiler environment of your choice.

Since Qt Creator 1.1, support for CMake projects is available. Qt Creator 1.3 supports the Microsoft toolkit if cmake version is at least 2.8.

Setting PATH for CMake

You can configure the path for the CMake executable in Tools > Options ...> Projects> CMake .

  Project management.  Customize CMake project.

Note: Before you open the CMake project, you must change the PATH environment variable so that it includes the bin mingw and Qt Creator directories in the SDK.

For example, if you have Qt Creator SDK installed on drive C, use the following command to set environment variables on the command line:

  set PATH = C: \ qtsdk \ mingw \ bin; C: \ qtsdk \ qt \ bin; 

Then, start Qt Creator by typing:

  C: \ qtsdk \ bin \ qtcreator.exe 

Opening CMake projects

To open a CMake project:

  1. Select File > Open File or Project ....
  2. Select the CMakeLists.txt file from your CMake project.

The wizard will guide you through the remaining steps of the process.

Note: If the CMake project does not have a place to build, Qt Creator will allow you to specify the directory in which the project will be built (shadow assembly).

  Project management.  Customize CMake project.

The screenshot below shows how you can specify command line arguments for CMake in your project.

  Project management.  Customize CMake project.

Usually there is no need to pass any arguments for the project that has already been collected, since CMake caches this information.

Building CMake projects

Qt Creator builds CMake projects by running make , mingw32-make or nmake depending on your platform. Bugs and assembly warnings are processed and displayed in the Assembly Output panel.

By default, Qt Creator collects all targets. You can specify which goals should be collected in the Projects mode in the Build Settings .

  Project management.  Customize CMake project.

Qt Creator supports multiple build settings. The build directory can be changed after the initial import.

Running CMake projects

Qt Creator automatically adds Launch Settings for all targets specified in the CMake project file.

Known issues for the current version can be found.

here.

Adding external libraries to a CMake project

Qt Creator can support code completion and syntax highlighting for external libraries as if they were part of a current project or Qt library.

Qt Creator defines external libraries using the FIND_PACKAGE () macro. Some libraries come with CMake. You can find them in the Modules subdirectory in the CMake installation directory.

Note: If you provide your own libraries, you also need to provide your own FindFoo.cmake file. See the CMake FAQ for more information.

Code completion and syntax highlighting will work as soon as your project is successfully assembled and linked to an external library.

will work as soon as your project is successfully assembled and linked to the external library.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Cross platform programming

Terms: Cross platform programming