gpt4 book ai didi

cmake 不会在 ExternalProject_Add 中正确运行 build_command

转载 作者:行者123 更新时间:2023-12-04 18:41:45 26 4
gpt4 key购买 nike

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

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只是说:
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 ,然后它就可以工作了。

我究竟做错了什么?

最佳答案

为您 BUILD_COMMAND ,您已将整个命令用引号括起来,因此 CMake 将其视为单个参数。

您只需要删除引号以允许 CMake 将其解析为带有 4 个参数的命令:

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

关于cmake 不会在 ExternalProject_Add 中正确运行 build_command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24519499/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com