cmake不会在ExternalProject_Add中正确运行build_command [英] cmake wont run build_command in ExternalProject_Add correctly

查看:2106
本文介绍了cmake不会在ExternalProject_Add中正确运行build_command的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想通过 cmake 下载一个git存储库,并将源文件夹复制到其他地方。这里有一个最小的工作示例:

I just want to download a git repository of via cmake, and copy the source folder to somewhere else. Here a minimal working example:

cmake_minimum_required (VERSION 2.8)
project ("myProject")
include(ExternalProject)

# Download and copy the repository
set(PROJECT_NAME_CHIBIOS "ChibiOS")
ExternalProject_Add(${PROJECT_NAME_CHIBIOS}
                    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_CHIBIOS}-Download
                    GIT_REPOSITORY https://github.com/ChibiOS/ChibiOS-RT.git
                    GIT_TAG b440caa10ced9532a467e4cbb96e1b3f0b99060a
                    CONFIGURE_COMMAND ""
                    BUILD_COMMAND "${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR> ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_CHIBIOS}"
                    UPDATE_COMMAND ""
                    INSTALL_COMMAND ""
                    LOG_DOWNLOAD 1
                    LOG_UPDATE 1
                    LOG_CONFIGURE 1
                    LOG_BUILD 1
                    LOG_TEST 1
                    LOG_INSTALL 1
                  )

BUILD_COMMAND 中的复制命令即开即用。 make 只是说:

Everything but the copy command in BUILD_COMMAND works out of the box. make just says:

Scanning dependencies of target ChibiOS
[ 12%] Creating directories for 'ChibiOS'
[ 25%] Performing download step (git clone) for 'ChibiOS'
-- ChibiOS download command succeeded.  See also /tmp/ChibiOS-Download/src/ChibiOS-stamp/ChibiOS-download-*.log

[ 37%] No patch step for 'ChibiOS'
[ 50%] No update step for 'ChibiOS'
[ 62%] No configure step for 'ChibiOS'
[ 75%] Performing build step for 'ChibiOS'
CMake Error at /tmp/ChibiOS-Download/src/ChibiOS-stamp/ChibiOS-build.cmake:16 (message):
  Command failed: No such file or directory

  '/usr/bin/cmake -E copy_directory /tmp/ChibiOS-Download/src/ChibiOS /tmp/ChibiOS' 

但如果我复制 / usr / bin / cmake -E copy_directory / tmp / ChibiOS-Download / src / ChibiOS / tmp / ChibiOS 进入shell,它会工作。

But if I copy /usr/bin/cmake -E copy_directory /tmp/ChibiOS-Download/src/ChibiOS /tmp/ChibiOS into the shell, it works afterwards.

我做错了什么?

推荐答案

对于您的 BUILD_COMMAND ,您已将整个命令,因此CMake将此视为单个参数。

For your BUILD_COMMAND, you have wrapped the entire command in quotes, so CMake is seeing this as a single argument.

您只需删除引号,允许CMake将此解析为具有4个参数的命令:

You just need to remove the quotes to allow CMake to resolve this as a command with 4 arguments:

...
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR> ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_CHIBIOS}
...

这篇关于cmake不会在ExternalProject_Add中正确运行build_command的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆