分享

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

 guitarhua 2016-04-11
本文根据已有的CMakeList.txt工程利用Qt Creator创建CMake工程。
参考文献:http://www./tikiwiki/tiki-index.php?page=Setting+Up+An+Application+-+QtCreator+-+Linux
参考文献:http://blog.csdn.net/frestone2010/article/details/6690854   (用cmake构建Qt工程(对比qmake进行学习))
其中CMakeLists.txt范例:http://pan.baidu.com/s/1i3qz9cT    http://download.csdn.net/detail/deng_sai/8786231
简单版:http://download.csdn.net/detail/deng_sai/9041861    
如果需要设置cmakelists所写工程能调试,则需设置:
1、
  1. 在工程目录下的CMakeLists.txt中加入如下两行代码:  
  2. SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")   
  3. SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")   
  4. 如例子:  
  5. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)  
  6. SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")#就是这两行东东  
  7. 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.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多