0

I wonder if there is a possibility of download from Github only one directory from one repo using ExternalProject_Add?

I need to use glm library in my project and I wonder if it is good idea, because it takes around 70MB. The directory that I need has 11MB, so it is big difference in memory and downloading time.

Here is link for glm github repo: https://github.com/g-truc/glm, but I don't think it is important here.

I want download only glm directory from that repo.

Do you have any ideas?

Here is my CMakeLists.txt that I add to main project:

include(ExternalProject)

ExternalProject_Add(glm
  GIT_REPOSITORY https://github.com/g-truc/glm
  PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
  # Disable configure, build and install steps
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
  INSTALL_COMMAND ""
  LOG_DOWNLOAD ON
)

# Specify include dir
ExternalProject_Get_Property(glm source_dir)
set(GLM_INCLUDE_DIRS ${source_dir}/ PARENT_SCOPE)

I tried to change url to https://github.com/g-truc/glm/tree/master/glm, but it doesn't work.

BartekPL
  • 1,968
  • 12
  • 32
  • 1
    When process `ExternalProject_Add`, CMake just executes its *DOWNLOAD_COMMAND* for obtain files. With *GIT_REPOSITORY* option download command is created automatically, but for specific cases you may write *DOWNLOAD_COMMAND* by yourself. Choose any way from the question http://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository, and write appropriate *DOWNLOAD_COMMAND*. Note, that you may specify several commands for the step by delimiting them with *COMMAND* keyword. – Tsyvarev Mar 15 '17 at 22:40
  • @Tsyvarev Thanks, I'll check it today after work – BartekPL Mar 16 '17 at 07:08
  • By the way, it works ;) – BartekPL Mar 14 '18 at 10:55

1 Answers1

0

I resolve this problem by combine DOWNLOAD_COMMAND mechanism with git sparse checkout.

I apply it in my Github project.

DOWNLOAD_COMMAND part and git sparse checkout mechanism part.

BartekPL
  • 1,968
  • 12
  • 32