如何使用Qtcreator通过忍者构建系统远程部署应用

时间:2019-09-30 12:32:40

标签: cmake qt-creator ninja

我想将我的qt应用程序部署到远程Linux设备。我使用 qtcreator cmake ninja 构建系统。但是,当我想通过ssh远程调试应用程序时,出现以下错误:

ninja: error: unknown target 'install'
15:56:22: The process "/usr/bin/cmake" exited with code 1.

1 个答案:

答案 0 :(得分:1)

阅读Deploying CMake Projects to Embedded Linux Devices。取决于您可以

  1. 在您的CMakeLists.txt中添加以下几行:

    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()
    
    add_deployment_file(${CMAKE_BINARY_DIR}/${PROJECT_NAME} /path/to/remote/app)
    
  2. QtCreator转到Projects/Run,只需删除Deployment中的Install into temporary host directory步骤。