mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
87 lines
2.5 KiB
CMake
87 lines
2.5 KiB
CMake
# Creates the AssetCopyTargets build target
|
|
|
|
set(COPY_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyAssets.cmake")
|
|
|
|
# Source;Dest pairs relative to the current source dir and the build output.
|
|
# Order matters — later entries overwrite earlier ones on conflict.
|
|
set(ASSET_FOLDER_PAIRS
|
|
"music" "music"
|
|
"Common/Media" "Common/Media"
|
|
"Common/res" "Common/res"
|
|
"Common/Trial" "Common/Trial"
|
|
"Common/Tutorial" "Common/Tutorial"
|
|
"${PLATFORM_NAME}Media" "${PLATFORM_NAME}Media"
|
|
)
|
|
|
|
# Global exclusions applied to every folder copy
|
|
set(ASSET_EXCLUDE_FILES
|
|
"*.cpp" "*.h"
|
|
"*.xml" "*.lang"
|
|
"*.bat" "*.cmd"
|
|
"*.msscmp" "*.binka" # Old audio formats
|
|
"*.swf" # These are built into the .arc
|
|
"*.resx" "*.loc"
|
|
"*.wav" # Unsupported audio format
|
|
"*.xui"
|
|
)
|
|
|
|
# Global folder exclusions applied to every folder copy
|
|
set(ASSET_EXCLUDE_FOLDERS
|
|
"Graphics"
|
|
)
|
|
|
|
|
|
# Exclude platform-specific arc media files
|
|
set(PLATFORM_MEDIA_FILES
|
|
"MediaWindows64.arc"
|
|
"MediaDurango.arc"
|
|
"MediaOrbis.arc"
|
|
"MediaPS3.arc"
|
|
"MediaPSVita.arc"
|
|
"MediaXbox.arc" # Seems to be missing?
|
|
)
|
|
|
|
# Exclude all platform media files except the one for the current platform
|
|
foreach(media_file IN LISTS PLATFORM_MEDIA_FILES)
|
|
if(NOT media_file MATCHES "Media${PLATFORM_NAME}\\.arc")
|
|
list(APPEND ASSET_EXCLUDE_FILES "${media_file}")
|
|
endif()
|
|
endforeach()
|
|
|
|
|
|
# Join the exclusion patterns into a single string for passing to the copy script
|
|
list(JOIN ASSET_EXCLUDE_FILES "|" ASSET_EXCLUDE_FILES_STR)
|
|
list(JOIN ASSET_EXCLUDE_FOLDERS "|" ASSET_EXCLUDE_FOLDERS_STR)
|
|
|
|
function(setup_asset_copy_targets)
|
|
set(copy_commands "")
|
|
list(LENGTH ASSET_FOLDER_PAIRS pair_count)
|
|
math(EXPR last "${pair_count} - 1")
|
|
|
|
# Loop through the source;dest pairs and create a copy command for each
|
|
foreach(i RANGE 0 ${last} 2)
|
|
math(EXPR j "${i} + 1")
|
|
list(GET ASSET_FOLDER_PAIRS ${i} src)
|
|
list(GET ASSET_FOLDER_PAIRS ${j} dest)
|
|
|
|
list(APPEND copy_commands
|
|
COMMAND ${CMAKE_COMMAND}
|
|
"-DCOPY_SOURCE=${CMAKE_CURRENT_SOURCE_DIR}/${src}"
|
|
"-DCOPY_DEST=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${dest}"
|
|
"-DEXCLUDE_FILES=${ASSET_EXCLUDE_FILES_STR}"
|
|
"-DEXCLUDE_FOLDERS=${ASSET_EXCLUDE_FOLDERS_STR}"
|
|
-P "${COPY_SCRIPT}"
|
|
)
|
|
endforeach()
|
|
|
|
add_custom_target(AssetCopyTargets ALL
|
|
${copy_commands}
|
|
COMMENT "Copying assets..."
|
|
VERBATIM
|
|
)
|
|
|
|
add_dependencies(Minecraft.Client AssetCopyTargets)
|
|
|
|
set_property(TARGET AssetCopyTargets PROPERTY FOLDER "Build")
|
|
endfunction()
|