首页 > 系统服务 > 详细

使用Qtcreator开发嵌入式linux程序

时间:2014-05-20 18:14:55      阅读:1079      评论:0      收藏:0      [点我收藏+]

http://qt-project.org/doc/qtcreator-3.0/creator-project-cmake.html


方法1: 使用 qmake编辑  工程文件 xxxx.pro添加


  1. equals (QT_ARCH, "arm")  {
  2.    target.path=/tmp/$${TARGET}/bin
  3.    INSTALLS += target
  4. }



CONFIG(debug, debug|release) {

   message(this is debug version)

} else {

  DEFINES += QT_NO_DEBUG_OUTPUT

message(disable debug , this is release version)

}


方法2: 使用CMakeList.txt

Deploying CMake Projects to Embedded Linux Devices

Qt Creator cannot extract files to be installed from a CMake project, and therefore, only executable targets are automatically added to deployment files. You must specify all other files in the QtCreatorDeployment.txt file that you create and place in the root directory of the CMake project.

Use the following syntax in the file:

<deployment/prefix>

<relative/source/file1>:<relative/destination/dir1>...

<relative/source/filen>:<relative/destination/dirn>

Where:

  • <deployment/prefix> is the (absolute) path prefix to where files are copied on the remote machine.

  • <relative/source/file> is the file path relative to the CMake project root. No directories or wildcards are allowed in this value.

  • <relative/destination/dir> is the destination directory path relative to deployment/prefix.

To automate the creation of QtCreatorDeployment.txt file:

  1. Define the following macros in the top level CMakeLists.txt file:

            file(WRITE "${CMAKE_SOURCE_DIR}/QtCreatorDeployment.txt""<deployment/prefix>\n")
    
            macro(add_deployment_file SRC DEST)
                file(RELATIVE_PATH path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
                file(APPEND "${CMAKE_SOURCE_DIR}/QtCreatorDeployment.txt""${path}/${SRC}:${DEST}\n")
            endmacro()
    
            macro(add_deployment_directory SRC DEST)
                file(GLOB_RECURSE files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}""${SRC}/*")
                foreach(filename ${files})
                    get_filename_component(path ${filename} PATH)
                    add_deployment_file("${filename}""${DEST}/${path}")
                endforeach(filename)
            endmacro()


  2. Use add_deployment_file(<file/name>) to add files and add_deployment_directory(<folder/name>) to add directories (including subdirectories) to the QtCreatorDeployment.txt file.

  3. Re-run cmake after you add or remove files using the macros.


本文出自 “枪炮与玫瑰的BLOG” 博客,请务必保留此出处http://axlrose.blog.51cto.com/434566/1413358

使用Qtcreator开发嵌入式linux程序,布布扣,bubuko.com

使用Qtcreator开发嵌入式linux程序

原文:http://axlrose.blog.51cto.com/434566/1413358

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!