From ae5c6e870f07f1756e723fbbfc64d98181169fdd Mon Sep 17 00:00:00 2001 From: Harrand Date: Sun, 17 Nov 2024 16:03:06 +0000 Subject: [PATCH] [cmake] add support for BUNDLE_DIRECTORIES. allows you to select entire directories to be bundled, this means every single file in those directories (recursively) will be added as BUNDLE_FILES. --- cmake/bundle.cmake | 9 ++++++++- cmake/topaz.cmake | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/bundle.cmake b/cmake/bundle.cmake index 7efabcacff..841cd5f22f 100644 --- a/cmake/bundle.cmake +++ b/cmake/bundle.cmake @@ -4,10 +4,17 @@ function(topaz_bundle_files) TOPAZ_BUNDLE_FILES "" "TARGET" - "FILES" + "FILES;DIRECTORIES" ${ARGN} ) + # for each bundle directory, glob recursively and add everything as files. + # if a new thing was added in the directory, will reconfigure thanks to CONFIGURE_DEPENDS + foreach(dir IN LISTS TOPAZ_BUNDLE_FILES_DIRECTORIES) + file(GLOB_RECURSE local_files CONFIGURE_DEPENDS RELATIVE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/${dir}/*) + list(APPEND TOPAZ_BUNDLE_FILES_FILES ${local_files}) + endforeach() + # source dir: CMAKE_CURRENT_SOURCE_DIR # Loop over each file and replicate the directory structure in the binary directory set_target_properties(${TOPAZ_BUNDLE_FILES_TARGET} PROPERTIES TOPAZ_BUNDLE_DEPENDENCIES "${TOPAZ_BUNDLE_FILES_FILES}") diff --git a/cmake/topaz.cmake b/cmake/topaz.cmake index 6a08753d3a..8226aa5b1d 100644 --- a/cmake/topaz.cmake +++ b/cmake/topaz.cmake @@ -5,7 +5,7 @@ function(topaz_add_library) TOPAZ_ADD_LIBRARY "DEFINE_PACKAGE" "TARGET" - "SOURCES;SHADERS;TEXT_FILES;BUNDLE_FILES" + "SOURCES;SHADERS;TEXT_FILES;BUNDLE_FILES;BUNDLE_DIRECTORIES" ${ARGN} ) @@ -23,10 +23,11 @@ function(topaz_add_library) OUTPUT_DIR ${PROJECT_BINARY_DIR} TEXT_FILES ${TOPAZ_ADD_LIBRARY_TEXT_FILES} ) - if(TOPAZ_ADD_LIBRARY_BUNDLE_FILES) + if(DEFINED TOPAZ_ADD_LIBRARY_BUNDLE_FILES OR DEFINED TOPAZ_ADD_LIBRARY_BUNDLE_DIRECTORIES) topaz_bundle_files( TARGET ${TOPAZ_ADD_LIBRARY_TARGET} FILES ${TOPAZ_ADD_LIBRARY_BUNDLE_FILES} + DIRECTORIES ${TOPAZ_ADD_LIBRARY_BUNDLE_DIRECTORIES} ) endif() if(TOPAZ_ADD_LIBRARY_DEFINE_PACKAGE) @@ -39,7 +40,7 @@ function(topaz_add_executable) TOPAZ_ADD_EXECUTABLE "DEFINE_PACKAGE" "TARGET;FAVICON" - "SOURCES;SHADERS;TEXT_FILES;BUNDLE_FILES" + "SOURCES;SHADERS;TEXT_FILES;BUNDLE_FILES;BUNDLE_DIRECTORIES" ${ARGN} ) @@ -63,10 +64,11 @@ function(topaz_add_executable) OUTPUT_DIR ${PROJECT_BINARY_DIR} TEXT_FILES ${TOPAZ_ADD_EXECUTABLE_TEXT_FILES} ) - if(TOPAZ_ADD_EXECUTABLE_BUNDLE_FILES) + if(DEFINED TOPAZ_ADD_EXECUTABLE_BUNDLE_FILES OR DEFINED TOPAZ_ADD_EXECUTABLE_BUNDLE_DIRECTORIES) topaz_bundle_files( TARGET ${TOPAZ_ADD_EXECUTABLE_TARGET} FILES ${TOPAZ_ADD_EXECUTABLE_BUNDLE_FILES} + DIRECTORIES ${TOPAZ_ADD_EXECUTABLE_BUNDLE_DIRECTORIES} ) endif() if(TOPAZ_ADD_EXECUTABLE_DEFINE_PACKAGE)