FetchContent: Populate fails when SOURCE_DIR is specified
cmake version 3.15.4 on Ubuntu 18.04 somepath/foo/CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(foo
URL https://foo.com/foo.tar.bz2
)
FetchContent_Populate(foo
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
)
My goal is to still let FetchContent_Populate fetch the source but in a non-default location specified in SOURCE_DIR. FetchContent_Populate however assumes that I want to specify an already populated source directory and fails with the following error message:
Make Error at /usr/share/cmake-3.15/Modules/ExternalProject.cmake:2611 (message):
No download info given for 'foo-populate' and its source directory:
somepath/foo/src
is not an existing non-empty directory. Please specify one of:
* SOURCE_DIR with an existing non-empty directory
* DOWNLOAD_COMMAND
* URL
* GIT_REPOSITORY
* SVN_REPOSITORY
* HG_REPOSITORY
* CVS_REPOSITORY and CVS_MODULE
Call Stack (most recent call first):
/usr/share/cmake-3.15/Modules/ExternalProject.cmake:3204 (_ep_add_download_command)
CMakeLists.txt:13 (ExternalProject_Add)
From the documentation, my understand is that a pre-populated source directory is specified by defining FETCHCONTENT_SOURCE_DIR_ucName; specifying SOURCE_DIR in FetchContent_Populate should only override the default source location.
If my understanding is incorrect, what is the recommended way to accomplish my goal?