summaryrefslogtreecommitdiffhomepage
path: root/cmake/modules/AddDownloadableResource.cmake
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-02-09 18:46:52 +0100
committerAki <please@ignore.pl>2022-02-09 18:46:52 +0100
commit9ea64a9714712961a60fa436ccdaf3fd7c3a09e3 (patch)
tree1aed83e2a5a79757e864a595420f4438a4379afd /cmake/modules/AddDownloadableResource.cmake
parent39b36e332725498bcfa0a712b2a880b4abe8a174 (diff)
downloadstarshatter-9ea64a9714712961a60fa436ccdaf3fd7c3a09e3.zip
starshatter-9ea64a9714712961a60fa436ccdaf3fd7c3a09e3.tar.gz
starshatter-9ea64a9714712961a60fa436ccdaf3fd7c3a09e3.tar.bz2
Somewhat finalized AddDatafile and AddDownloadableResource
Ready-to-distribute datafiles can now be produced by the build chain. This is already done for shatter.dat, content.dat, and start.dat
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()