使用Qtcreator开发嵌入式linux程序

时间:2014-05-20 18:15:36   收藏:0   阅读:478

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:

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!