Hi,
I’m rather new to cmake and am trying to add a step to an existing cmake project to download 2 ancillary files available on Google Drive using wget. The format for the download command line is a little complicated, but this works:
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id= **FILEID** ' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id= **FILEID** " -O **FILENAME** && rm -rf /tmp/cookies.txt
Given that I don’t think I can use file(DOWNLOAD…), which I gather would use a simple curl call.
I’ve also started to look at ExternalProject_Add where I might be able to create a custom command.
I have tried adding wget module, but so far I cannot get my build to call it:
find_package(Wget)
function(WGET FILEID FILENAME)
CMAKE_PARSE_ARGUMENTS(WGETARG "" "FILEID;FILENAME" "" ${ARGN})
set(_fileid "${WGETARG_FILEID}")
set(_filename "${WGETARG_FILENAME}")
add_custom_command(OUTPUT ${_filename}
COMMAND ${WGET_EXECUTABLE} --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=${_fileid}' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/1\n/p')&id=${_fileid}" -O ${_filename} && rm -rf /tmp/cookies.txt
)
endfunction(WGET)
This seems like I’m making this too complicated - anyone out there with some experience with using wget to download some files during a cmake build - preferably set up such that it doesn’t automatically redownload the files if they are already available?
Thanks,
Heather