[CMake] ExternalProject_Add() setting build command to run external project's makefile

David Starkweather starkd88 at gmail.com
Fri May 31 10:41:58 EDT 2019


Hello
First off, much thanks to all the contributors of cmake. A truly invaluable
build utility. Your efforts
are greatly appreciated.

I've been successfully using cmake to build an external project (the client
library for redis, hiredis)
that has already been downloaded. I was able to do this with
BUILD_IN_SOURCE set to true, like so:

ExternalProject_Add(hiredis
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/hiredis
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hiredis
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND echo configure
BUILD_COMMAND make static
INSTALL_COMMAND echo install)

However, now i'd like to automatically download the source from github.
So, I switch to
the following:

set(HIREDIS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hiredis)
set(HIREDIS_INCLUDE_DIRS ${HIREDIS_DIR}/include)
ExternalProject_Add(hiredis
  URL https://github.com/redis/hiredis/archive/v0.9.0.tar.gz
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/hiredis
  SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/hiredis
  DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hiredis
  BUILD_IN_SOURCE 1
  CONFIGURE_COMMAND ""
  BUILD_COMMAND make static
  INSTALL_COMMAND "")

*And I get the following error:*

[  3%] Creating directories for 'hiredis'
[  6%] Performing download step (download, verify and extract) for 'hiredis'
-- Downloading...
   dst='/home/david/projects/clipseekr/hiredis/v0.9.0.tar.gz'
   timeout='none'
-- Using src='https://github.com/redis/hiredis/archive/v0.9.0.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/david/projects/clipseekr/hiredis/v0.9.0.tar.gz'
     dst='/home/david/projects/clipseekr/hiredis'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
make[2]: *** [CMakeFiles/hiredis.dir/build.make:93:
hiredis/src/hiredis-stamp/hiredis-download] Error 1
make[1]: *** [CMakeFiles/Makefile2:147: CMakeFiles/hiredis.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

It seems cmake is trying to invoke its internal cmake make files, rather
than just run the "make static"
build command.  How do I just run the the "make static" command directly?

Once again, thanks.
starkdg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190531/786dac59/attachment.html>


More information about the CMake mailing list