http://qt-project.org/doc/qtcreator-3.0/creator-project-cmake.html
方法1: 使用 qmake编辑 工程文件 xxxx.pro添加
- equals (QT_ARCH, "arm") {
- target.path=/tmp/$${TARGET}/bin
- INSTALLS += target
- }
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:
- 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()
- 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.
- Re-run cmake after you add or remove files using the macros.
使用Qtcreator开发嵌入式linux程序,布布扣,bubuko.com