本文根据已有的CMakeList.txt工程利用Qt Creator创建CMake工程。
参考文献: http://blog.csdn.net/frestone2010/article/details/6690854   (用cmake构建Qt工程(对比qmake进行学习))

如果需要设置cmakelists所写工程能调试,则需设置:
1、
在工程目录下的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、
cmake或者cmake-gui 时将变量CMAKE_BUILD_TYPE设置为Debug。


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.

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: 
Image


Choose build location

Image


Run CMake

Image


此处可能点击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: 
Image 
Choose build_directory/dist/bin/OgreApp as executable and build_directory/dist/bin as working directory.

Rejoice

Image

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.

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐