Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake wont run build_command in ExternalProject_Add correctly

Tags:

cmake

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
                  )

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' 

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

What am I doing wrong?

like image 946
Tik0 Avatar asked Jul 01 '14 21:07

Tik0


1 Answers

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

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}
...
like image 59
Fraser Avatar answered Nov 08 '22 09:11

Fraser