generation of data archive from cmake solution

This commit is contained in:
veclav talica 2024-08-22 18:36:04 +03:00
parent fa85fb8dd1
commit 9da92775bc
2 changed files with 16 additions and 10 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
**/*.dll
**/*.7z
**/*.zip
**/*.btw
.vs/
.vscode/

View File

@ -18,7 +18,10 @@ endif ()
set(TOWNENGINE_TARGET townengine CACHE INTERNAL "")
set(TOWNENGINE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
option(TOWNENGINE_HOT_RELOAD "Enable hot reloading support" TRUE)
option(TOWNENGINE_HOT_RELOAD "Enable hot reloading support" ON)
option(TOWNENGINE_ARCHIVE_DATA "Enable archival of assets" OFF)
# add -fPIC globally so that it's linked well
add_compile_options($<$<BOOL:${TOWNENGINE_HOT_RELOAD}>:-fPIC>)
set(PHYSFS_BUILD_SHARED FALSE)
@ -240,16 +243,25 @@ function(use_townengine target sources output_directory data_dir)
if (UNIX)
# create a bootstrapping script
set(TOWNENGINE_BOOTSTRAP_EXEC_ARGS
"$<IF:$<BOOL:${TOWNENGINE_ARCHIVE_DATA}>,--data-dir ./data.${PACKAGE_EXTENSION},--data-dir ${data_dir}>")
string(JOIN "\n" TOWNENGINE_BOOTSTRAP
"#!/bin/env sh"
"cd \"$(dirname \"$0\")\""
"LD_LIBRARY_PATH=./ ./launcher --data-dir ${data_dir}"
"LD_LIBRARY_PATH=./ ./launcher ${TOWNENGINE_BOOTSTRAP_EXEC_ARGS}"
"")
FILE(GENERATE OUTPUT ${output_directory}/${target}
CONTENT "${TOWNENGINE_BOOTSTRAP}"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
endif ()
if (TOWNENGINE_ARCHIVE_DATA)
# zip up assets
add_custom_command(TARGET ${target}_app POST_BUILD
COMMAND cd ${data_dir} && zip -r ${output_directory}/data.${PACKAGE_EXTENSION} ./*
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()
endfunction()
give_options(${TOWNENGINE_TARGET})
@ -265,10 +277,3 @@ endif ()
add_custom_command(TARGET ${TOWNENGINE_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/compile_commands.json
${TOWNENGINE_ROOT_DIR})
# zip up assets
# currently, you must run cmake from the project root dir for this to work correctly
#file(ARCHIVE_CREATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/data.${PACKAGE_EXTENSION}
# PATHS ${PROJECT_SOURCE_DIR}/assets
# FORMAT zip
#)