Setting Up a CMake ProjectCMake is an alternative to qmake for automating the generation of build configurations. It controls the software compilation process by using simple configuration files, called CMakeLists.txt files. CMake generates native build configurations and workspaces that you can use in the compiler environment of your choice. Since Qt Creator 1.1, CMake configuration files are supported. Qt Creator 1.3 supports the Microsoft tool chain if the CMake version is at least 2.8. Setting the Path for CMakeYou can set the path for the CMake executable in Tools > Options... > Projects > CMake. Note: Before you open a CMake project it is necessary to modify the PATH environment variable to include the bin folders of mingw and Qt Creator in the SDK. For instance, if you have the Qt SDK installed in your C drive, use the following command to set the environment variables in the command line prompt: set PATH=C:\qtsdk\mingw\bin;C:\qtsdk\qt\bin;
Then start Qt Creator by typing: C:\qtsdk\bin\qtcreator.exe
Opening CMake ProjectsTo open a CMake project:
A wizard guides you through the rest of the process. Note: If the CMake project does not have an in-place build, Qt Creator lets you specify the directory in which the project is built (shadow build). The screenshot below shows how you can specify command line arguments to CMake for your project. Normally, there is no need to pass any command line arguments for projects that are already built, as CMake caches that information. Building CMake ProjectsQt Creator builds CMake projects by running make, mingw32-make, or nmake depending on your platform. The build errors and warnings are parsed and displayed in the Build Issues output pane. By default, Qt Creator builds the all target. You can specify which targets to build in Project mode, under Build Settings. Qt Creator supports multiple build configurations. The build directory can also be modified after the initial import. Running CMake ProjectsQt Creator automatically adds Run Configurations for all targets specified in the CMake project file. Known issues for the current version can be found here. Adding External Libraries to CMake ProjectsThrough external libraries Qt Creator can support code completion and syntax highlighting as if they were part of the current project or the Qt library. Qt Creator detects the external libraries using the FIND_PACKAGE() macro. Some libraries come with the CMake installation. You can find those in the Modules directory of your CMake installation. Note: If you provide your own libraries, you also need to provide your own FindFoo.cmake file. For more information, see CMake FAQ. Syntax completion and highlighting work once your project successfully builds and links against the external library. [Previous: Adding New Custom Wizards] [Next: Setting Up a Generic Project] © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. X
|