summaryrefslogtreecommitdiffhomepage
path: root/cmake/modules/AddDownloadableResource.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/AddDownloadableResource.cmake')
-rw-r--r--cmake/modules/AddDownloadableResource.cmake37
1 files changed, 36 insertions, 1 deletions
diff --git a/cmake/modules/AddDownloadableResource.cmake b/cmake/modules/AddDownloadableResource.cmake
index bbef5b7..d0374ad 100644
--- a/cmake/modules/AddDownloadableResource.cmake
+++ b/cmake/modules/AddDownloadableResource.cmake
@@ -1,4 +1,35 @@
-# TODO: Document this and how it interacts with AddDatafile.
+# Adds a target that downloads an archive containing binary files that should be part of game distribution but are not
+# part of the version control system. For example:
+#
+# add_downloadable_resource(
+# resource_shatter
+# ARCHIVE shatter.tar.xz
+# DIRECTORY shatter.d
+# BASE_URL https://ftp.ignore.pl/starshatter/resource/latest
+# SHA1 bbed14649213a45499e0a158142f19fd619a54af
+# )
+#
+# Will download 'shatter.tar.xz' from 'https://ftp.ignore.pl/starshatter/resouce/latest' and unpack it into 'shatter.d'
+# subdirectory under respective binary directory. The archive will be validated for correctness with SHA1.
+#
+# Selected options provide default arguments:
+# * ARCHIVE defaults to '<target_name>.tar.xz'
+# * DIRECTORY defaults to '<target_name>.d'
+# * BASE_URL defaults to 'https://ftp.ignore.pl/starshatter/resource/latest'
+#
+# Targets are designed to be used with AddDatafile targets via their RESOURCES option:
+#
+# add_downloadable_resource(resource_shatter ...)
+# add_datafile(
+# shatter
+# RESOURCES resource_shatter
+# )
+#
+# This will automatically make the datafile generated by 'shatter' target to include files downloaded by
+# 'resource_shatter'.
+#
+# Downloaded archives are not cleaned by default to avoid unnecessarily long build times. Instead they need to be
+# cleaned explicitly either by removing them manually or by running 'clean_downloaded_<target_name>' target.
set(ADD_DOWNLOADABLE_RESOURCE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/download_resource.cmake.in)
function(add_downloadable_resource)
@@ -46,4 +77,8 @@ function(add_downloadable_resource)
${CMAKE_COMMAND} -E tar xf ${RESOURCE_ARCHIVE}
)
add_custom_target(${RESOURCE_TARGET} DEPENDS ${RESOURCE_DIRECTORY})
+ set_property(
+ TARGET ${RESOURCE_TARGET}
+ PROPERTY RESOURCE_DIRECTORY ${RESOURCE_DIRECTORY}
+ )
endfunction()