Qt Creator 根据已有的CMakeList.txt创建CMake工程


本文根据已有的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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值