How to import CMake project in Qt Creator

Importing a CMake project into Qt Creator is easier than it is with Eclipse (which is described here). The problem is that you cannot do this properly by using the Import option. Counter-intuitively, you need to Open Project to import a CMake project and make a Qt Creator project from it. After this operation, the project will be available in Qt Creator always, with auto-complete (thanks to indexing) and building (thanks to make).

To do this:

  • Do Open file or project and open the CMakeLists.txt file.
  • Choose the Build directory properly. Qt Creator will create a .cbp file here with the name of the CMake project.
  • Qt Creator will ask you to run cmake once, so that it can learn the include, library and build directories.
  • You are now in the project Qt Creator has created for you. It will index the files perfectly, so you get excellent auto-complete (better than Eclipse).
  • Click the Projects button in left column and you will be able to set the command options to build and the environment variables for build.

Tried with: Qt Creator 3.5.0 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s