使用Qtcreator開發嵌入式linux程式

來源:互聯網
上載者:User

標籤:linux   qt   嵌入式   

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.