简单版: http://download.csdn.net/detail/deng_sai/9041861
在工程目录下的CMakeLists.txt中加入如下两行代码:
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
如例子:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")#就是这两行东东
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")#
2、
Introduction
This set of instructions will walk you through setting up a QtCreator C++ project from scratch.
When you have finished this tutorial you will be able to compile a working Ogre Application and you will be ready to start the Basic Tutorials.
Table of contents
Prerequisites
Follow the instruction at Building Your Projects With CMake to setup a CMake project.
Do not generate the project using the CMake GUI - you don't need to as QtCreator will handle the rest.
Setting up an Ogre project in QtCreator
Open project
QtCreator - File - Open File or Project:
Choose build location
Run CMake
此处可能点击Run CMake后Qt Creator 没反应。可能是Qt Creator的CMake的执行命令的路径没指定。
Projects->Manage Kits...->Build & Run -> CMake(可以指定为cmake,也可直接指定cmake-gui。不过假如首先指定的是cmake-gui,run cmake后可能无法显示导入的工程文件,需要再次指定为cmake后再一次run cmake)
click Finish
Make in console
You need to find the qtcreator-build(/home/deng_sai/myQtCreator/fast_qt/openPOWERLINK-V1.08.4/Build) directory and run this in a console:
make && make install
The reason is that it's a bit involved to set up an INSTALL build configuration in QtCreator, and it only needs to be done once.
Setup executable for project run
Now, click the green arrow in the sidebar to build and run the project.
Since we haven't set up any run configuration, we are prompted to do that in the following dialogue:
Choose build_directory/dist/bin/OgreApp as executable and build_directory/dist/bin as working directory.
Rejoice
Conclusion
As you can see, it's rather easy to setup a project in QtCreator if you use a CMake script.
QtCreator doesn't touch your source directory, except one file: CMakeLists.txt.user.