aboutsummaryrefslogtreecommitdiff
path: root/cmake/CopyAssets.cmake
diff options
context:
space:
mode:
authorrtm516 <rtm516@users.noreply.github.com>2026-03-17 21:39:22 +0000
committerGitHub <noreply@github.com>2026-03-17 16:39:22 -0500
commit02a5961f39673be403fda3edbf6fb1265bd93477 (patch)
treeade5f3cfd70fcb6e0add6492f182cc571bec7f3a /cmake/CopyAssets.cmake
parent1a3fcb5b2010fbbf5ef0ab52f7291a4129f05842 (diff)
Move project to CMake (#781)
* Move to cmake * Move sources to source_groups and ditch more old VS files * Add BuildVer.h generation * Break out cmake source lists to platforms * Don't copy swf files * Revert audio changes from merge * Add platform defines * Match MSBuild flags * Move BuildVer.h to common include and fix rebuild issue * Seperate projects properly * Exclude more files and make sure GameHDD exists * Missing line * Remove remaining VS project files * Update readme and actions * Use incremental LTCG * Update workflows * Update build workflows and output folder * Disable vcpkg checks * Force MSVC * Use precompiled headers * Only use PCH for cpp * Exclude compat_shims from PCH * Handle per-platform source includes * Copy only current platform media * Define Iggy libs per platform * Fix EnsureGameHDD check * Only set WIN32_EXECUTABLE on Windows * Correct Iggy libs path * Remove include of terrain_MipmapLevel * Correct path to xsb/xwb * Implement copilot suggestions * Add clang flags (untested) * Fix robocopy error checking * Update documentation * Drop CMakePresets.json version as we dont use v6 features * Always cleanup artifacts in nightly even if some builds fail * Re-work compiler target options * Move newer iggy dll into redist and cleanup * Fix typos * Remove 'Source Files' from all source groups * Remove old ps1 build scripts
Diffstat (limited to 'cmake/CopyAssets.cmake')
-rw-r--r--cmake/CopyAssets.cmake101
1 files changed, 101 insertions, 0 deletions
diff --git a/cmake/CopyAssets.cmake b/cmake/CopyAssets.cmake
new file mode 100644
index 00000000..a78c9170
--- /dev/null
+++ b/cmake/CopyAssets.cmake
@@ -0,0 +1,101 @@
+function(setup_asset_folder_copy TARGET_NAME ASSET_FOLDER_PAIRS)
+ set(COPY_FOLDER_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/CopyFolderScript.cmake")
+
+ # 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)
+
+ 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=${src}"
+ "-DCOPY_DEST=$<TARGET_FILE_DIR:${TARGET_NAME}>/${dest}"
+ "-DEXCLUDE_FILES=${ASSET_EXCLUDE_FILES_STR}"
+ "-DEXCLUDE_FOLDERS=${ASSET_EXCLUDE_FOLDERS_STR}"
+ -P "${COPY_FOLDER_SCRIPT}"
+ )
+ endforeach()
+
+ add_custom_target(AssetFolderCopy_${TARGET_NAME} ALL
+ ${copy_commands}
+ COMMENT "Copying assets (folders) for ${TARGET_NAME}..."
+ VERBATIM
+ )
+
+ add_dependencies(${TARGET_NAME} AssetFolderCopy_${TARGET_NAME})
+ set_property(TARGET AssetFolderCopy_${TARGET_NAME} PROPERTY FOLDER "Build")
+endfunction()
+
+function(setup_asset_file_copy TARGET_NAME ASSET_FILE_PAIRS)
+ set(COPY_FILE_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/CopyFileScript.cmake")
+
+ set(copy_commands "")
+ list(LENGTH ASSET_FILE_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_FILE_PAIRS ${i} src)
+ list(GET ASSET_FILE_PAIRS ${j} dest)
+
+ list(APPEND copy_commands
+ COMMAND ${CMAKE_COMMAND}
+ "-DCOPY_SOURCE=${src}"
+ "-DCOPY_DEST=$<TARGET_FILE_DIR:${TARGET_NAME}>/${dest}"
+ -P "${COPY_FILE_SCRIPT}"
+ )
+ endforeach()
+
+ add_custom_target(AssetFileCopy_${TARGET_NAME} ALL
+ ${copy_commands}
+ COMMENT "Copying assets (files) for ${TARGET_NAME}..."
+ VERBATIM
+ )
+
+ add_dependencies(${TARGET_NAME} AssetFileCopy_${TARGET_NAME})
+ set_property(TARGET AssetFileCopy_${TARGET_NAME} PROPERTY FOLDER "Build")
+endfunction()