From 9ea64a9714712961a60fa436ccdaf3fd7c3a09e3 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 9 Feb 2022 18:46:52 +0100 Subject: 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 --- cmake/modules/AddDatafile.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'cmake/modules/AddDatafile.cmake') diff --git a/cmake/modules/AddDatafile.cmake b/cmake/modules/AddDatafile.cmake index 3bf2388..f54b892 100644 --- a/cmake/modules/AddDatafile.cmake +++ b/cmake/modules/AddDatafile.cmake @@ -1,17 +1,20 @@ -# TODO: Update to match new AddDownloadableResource. -# Adds a target that creates a datafile archive containing all files under selected directory tree. For example: +# Adds a target that creates a datafile archive containing all files under selected source directory tree. For example: # # add_datafile( # shatter # SOURCE shatter # OUTPUT shatter.dat +# RESOURCES resource_shatter # ) # # Will create 'shatter.dat' in the respective binary directory containing all files in 'shatter' subdirectory of current # source directory. SOURCE option's argument defaults to the target name. OUTPUT option's argument defaults to the # target name with ".dat" suffix. # -# To create the archive Datafile.exe is used, so for non-Windows platforms an emulator that can run it is needed. +# Optionally, RESOURCES can be used to specify binary resource targets from AddDownloadableResource that will provide +# additional directories with files that will also get included in the final datafile. +# +# To create the archive the Datafile.exe is used - for non-Windows platforms an emulator that can run it is required. function(add_datafile) set(DATAFILE_TARGET ${ARGV0}) @@ -51,14 +54,13 @@ function(add_datafile) $ $ -mak COMMENT "Creating datafile ${DATAFILE_TARGET}" ) - foreach(RESOURCE IN ITEMS ${DATAFILE_RESOURCES}) - cmake_path(ABSOLUTE_PATH RESOURCE NORMALIZE BASE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - message(STATUS ${RESOURCE}) + foreach(RESOURCE_TARGET IN ITEMS ${DATAFILE_RESOURCES}) + get_property(RESOURCE_DIRECTORY TARGET ${RESOURCE_TARGET} PROPERTY RESOURCE_DIRECTORY) add_custom_command( OUTPUT ${DATAFILE_OUTPUT} APPEND - DEPENDS ${RESOURCE} + DEPENDS ${RESOURCE_TARGET} COMMAND - ${CMAKE_COMMAND} -E chdir ${RESOURCE} + ${CMAKE_COMMAND} -E chdir ${RESOURCE_DIRECTORY} ${CMAKE_COMMAND} -E env "${DATAFILE_VAR}='${DATAFILE_PATHS}'" ${CMAKE_CORSSCOMPILING_EMULATOR} $ $ -mak -- cgit v1.1