diff options
author | Aki <please@ignore.pl> | 2022-02-09 18:46:52 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-02-09 18:46:52 +0100 |
commit | 9ea64a9714712961a60fa436ccdaf3fd7c3a09e3 (patch) | |
tree | 1aed83e2a5a79757e864a595420f4438a4379afd /cmake/modules/AddDatafile.cmake | |
parent | 39b36e332725498bcfa0a712b2a880b4abe8a174 (diff) | |
download | starshatter-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/AddDatafile.cmake')
-rw-r--r-- | cmake/modules/AddDatafile.cmake | 18 |
1 files changed, 10 insertions, 8 deletions
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) $<TARGET_FILE:Datafile> $<SHELL_PATH:${DATAFILE_OUTPUT}> -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} $<TARGET_FILE:Datafile> $<SHELL_PATH:${DATAFILE_OUTPUT}> -mak |