我只想下载via 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中,它会在之后运行。
我做错了什么?
答案 0 :(得分:6)
对于BUILD_COMMAND
,您已将整个命令包装在引号中,因此CMake将此视为单个参数。
您只需要删除引号以允许CMake将其解析为具有4个参数的命令:
...
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR> ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_CHIBIOS}
...