Created
February 23, 2022 16:30
-
-
Save KPB3rd/3329346cbc0b0180052efcf5bebed503 to your computer and use it in GitHub Desktop.
Download files using cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Individual File download | |
| if(NOT DEFINED DOWNLOADED OR NOT ${DOWNLOADED}) | |
| file(DOWNLOAD | |
| "ftp://10.0.IP.IP/example.txt" | |
| "${CMAKE_CURRENT_SOURCE_DIR}/data/" | |
| SHOW_PROGRESS | |
| STATUS status | |
| LOG log) | |
| endif() | |
| # Download tar | |
| # If you want to redownload, set the DOWNLOADED variable to false in the CMakeCache (or remove/clean) | |
| if(NOT DEFINED DOWNLOADED OR NOT ${DOWNLOADED}) | |
| message("Downloading...") | |
| include(FetchContent) | |
| FetchContent_Declare( | |
| x | |
| URL "ftp://10.0.IP.IP/example.tar.gz" | |
| ) | |
| FetchContent_GetProperties(x) | |
| FetchContent_MakeAvailable(x) | |
| # Copy from the _deps subdir to the desired location | |
| message("Moving " ${x_SOURCE_DIR} " to " ${CMAKE_CURRENT_SOURCE_DIR}/data/x/) | |
| file(COPY ${x_SOURCE_DIR} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/data/) | |
| # FetchContent treats things as a repo, but this is raw data. Rename to remove the "-src" to be more human understandable | |
| file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/data/x-src/ ${CMAKE_CURRENT_SOURCE_DIR}/data/x) | |
| set(DOWNLOADED true CACHE INTERNAL "") | |
| endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment