I tried to download only part of repository as it is written here: https://stackoverflow.com/a/28039894/7042963, but I wanna do this in CMakeLists.txt
by using ExternalProject_Add
DOWNLOAD_COMMAND
.
However, there are some problems. I cannot write content to file sparse-checkout. File exists, but it is empty. This is my CMakeLists.txt file:
include(ExternalProject)
message("CMAKE_CURRENT_BINARY_DIR is set to ${CMAKE_CURRENT_BINARY_DIR}")
ExternalProject_Add(glm
DOWNLOAD_COMMAND git init
COMMAND git remote add origin https://github.com/g-truc/glm
COMMAND git config core.sparsecheckout true
COMMAND touch .git/info/sparse-checkout
COMMAND pwd
COMMAND echo "glm/*" >> .git/info/sparse-checkout
COMMAND git pull --depth=1 origin master
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# Disable configure, build and install steps
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
)
# Specify include dir
set(GLM_INCLUDE_DIRS ${PREFIX}/src PARENT_SCOPE)
Log from this commands execution:
Initialized empty Git repository in /path/to/project/build/modules/glm/src/.git/
/path/to/project/build/modules/glm/src
glm/* >> .git/info/sparse-checkout
When I look at log, I think that echo simply print next part of this command to output and this is problem.
I tried also replace echo command with this :
COMMAND FILE(WRITE .git/info/sparse-checkout "glm/*")
And it is error log from this:
CMake Error at glm-stamp/glm-download--impl.cmake:59 (message):
Command failed (No such file or directory):
'FILE' '(' 'WRITE' '.git/info/sparse-checkout' 'glm/*' ')'
Do you know what is the reason of this problem?