From a0edf193fe7c130e8bef2da8677e13e603bfdaa0 Mon Sep 17 00:00:00 2001 From: isaiah Date: Sun, 1 Mar 2026 15:07:50 -0700 Subject: Add CMake build system and source files for Minecraft Client - Created Compile.md with detailed instructions for building the project using Visual Studio and CMake. - Added ClientSources.cmake to define the source files for the Minecraft Client. - Implemented CopyAssets.cmake to handle asset copying during the build process. - Introduced WorldSources.cmake to list the source files for Minecraft world functionalities. --- cmake/CopyAssets.cmake | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 cmake/CopyAssets.cmake (limited to 'cmake/CopyAssets.cmake') diff --git a/cmake/CopyAssets.cmake b/cmake/CopyAssets.cmake new file mode 100644 index 00000000..661ba785 --- /dev/null +++ b/cmake/CopyAssets.cmake @@ -0,0 +1,72 @@ +if(NOT DEFINED PROJECT_SOURCE_DIR OR NOT DEFINED OUTPUT_DIR OR NOT DEFINED CONFIGURATION) + message(FATAL_ERROR "CopyAssets.cmake requires PROJECT_SOURCE_DIR, OUTPUT_DIR, and CONFIGURATION.") +endif() + +# Some generators may pass quoted values (e.g. "Debug"); normalize that. +string(REPLACE "\"" "" PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}") +string(REPLACE "\"" "" OUTPUT_DIR "${OUTPUT_DIR}") +string(REPLACE "\"" "" CONFIGURATION "${CONFIGURATION}") + +set(_project_dir "${PROJECT_SOURCE_DIR}/Minecraft.Client") + +function(copy_tree_if_exists src_rel dst_rel) + set(_src "${_project_dir}/${src_rel}") + set(_dst "${OUTPUT_DIR}/${dst_rel}") + if(EXISTS "${_src}") + file(MAKE_DIRECTORY "${_dst}") + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${_src}" "${_dst}") + endif() +endfunction() + +function(copy_file_if_exists src_rel dst_rel) + set(_src "${PROJECT_SOURCE_DIR}/${src_rel}") + set(_dst "${OUTPUT_DIR}/${dst_rel}") + if(EXISTS "${_src}") + get_filename_component(_dst_dir "${_dst}" DIRECTORY) + file(MAKE_DIRECTORY "${_dst_dir}") + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_src}" "${_dst}") + endif() +endfunction() + +function(copy_first_existing dst_rel) + set(_copied FALSE) + foreach(_candidate IN LISTS ARGN) + if(EXISTS "${PROJECT_SOURCE_DIR}/${_candidate}") + copy_file_if_exists("${_candidate}" "${dst_rel}") + set(_copied TRUE) + break() + endif() + endforeach() + if(NOT _copied) + message(WARNING "Runtime file not found for ${dst_rel}. Checked: ${ARGN}") + endif() +endfunction() + +if(CONFIGURATION STREQUAL "Debug") + copy_tree_if_exists("Durango/Sound" "Durango/Sound") + copy_tree_if_exists("music" "music") + copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD") + copy_tree_if_exists("Common/Media" "Common/Media") + copy_tree_if_exists("Common/res" "Common/res") + copy_tree_if_exists("Common/Trial" "Common/Trial") + copy_tree_if_exists("Common/Tutorial" "Common/Tutorial") +else() + copy_tree_if_exists("music" "music") + copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD") + copy_tree_if_exists("Common/Media" "Common/Media") + copy_tree_if_exists("Common/res" "Common/res") + copy_tree_if_exists("Common/Trial" "Common/Trial") + copy_tree_if_exists("Common/Tutorial" "Common/Tutorial") + copy_tree_if_exists("DurangoMedia" "Windows64Media") + copy_tree_if_exists("Windows64Media" "Windows64Media") +endif() + +# Runtime DLLs required at launch. +copy_first_existing("iggy_w64.dll" + "Minecraft.Client/Windows64/Iggy/lib/redist64/iggy_w64.dll" + "x64/${CONFIGURATION}/iggy_w64.dll" +) +copy_first_existing("mss64.dll" + "Minecraft.Client/Windows64/Miles/lib/redist64/mss64.dll" + "x64/${CONFIGURATION}/mss64.dll" +) -- cgit v1.2.3