From 2728f23da25df99a0b38c87b38e29a969df9375c Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 4 Dec 2024 15:02:29 -0700 Subject: [PATCH 1/5] Fix torchlib inclusion. --- CMakeLists.txt | 68 +++++++++++++++++++++++++++++++------------------- tools/Torch | 2 +- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 179a5d99..9a923fcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") # Add a custom module path to locate additional CMake modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +set(YAML_CPP_STATIC_DEFINE ON) +add_compile_definitions(YAML_CPP_STATIC_DEFINE) if (WIN32) include(cmake/automate-vcpkg.cmake) @@ -234,7 +236,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "INCLUDE_GAME_PRINTF;" "UNICODE;" "_UNICODE" - STORMLIB_NO_AUTO_LINK "_CRT_SECURE_NO_WARNINGS;" "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) @@ -253,10 +254,11 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "WIN32;" "UNICODE;" "_UNICODE" - STORMLIB_NO_AUTO_LINK "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) endif() + add_compile_definitions(STORMLIB_NO_AUTO_LINK) + set(STORMLIB_NO_AUTO_LINK ON) elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") target_compile_definitions(${PROJECT_NAME} PRIVATE "$<$:" @@ -321,10 +323,43 @@ endif() target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") -set(USE_STANDALONE OFF) -set(BUILD_STORMLIB OFF) -set(BUILD_SM64 OFF) -set(BUILD_MK64 OFF) +include(ExternalProject) +ExternalProject_Add(TorchExternal + PREFIX TorchExternal + SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/TorchExternal +) +ExternalProject_Get_Property(TorchExternal install_dir) +set(TORCH_EXECUTABLE ${install_dir}/src/TorchExternal-build/$/torch) +add_custom_target( + ExtractAssetHeaders + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 +) +add_custom_target( + GeneratePortOtr + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} pack port starship.otr + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" +) +add_custom_target( + ExtractAssets + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 + COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 + COMMAND ${TORCH_EXECUTABLE} pack port starship.otr + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" +) + +option(USE_STANDALONE "Build as a standalone executable" OFF) +option(BUILD_STORMLIB "Build with StormLib support" OFF) + +option(BUILD_SM64 "Build with Super Mario 64 support" OFF) +option(BUILD_MK64 "Build with Mario Kart 64 support" OFF) add_subdirectory(tools/Torch) target_link_libraries(${PROJECT_NAME} PRIVATE torch) @@ -533,23 +568,4 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wl,-export-dynamic ) endif() -endif() - -include(ExternalProject) -ExternalProject_Add(TorchExternal - PREFIX TorchExternal - SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch -) -ExternalProject_Get_Property(TorchExternal install_dir) -set(TORCH_EXECUTABLE ${install_dir}/src/Torch-build/$/torch) -add_custom_target( - ExtractAssets - DEPENDS TorchExternal - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 - COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 - COMMAND ${TORCH_EXECUTABLE} pack port starship.otr - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" -) \ No newline at end of file +endif() \ No newline at end of file diff --git a/tools/Torch b/tools/Torch index 65ed1fac..cc8e414c 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 65ed1faca66325606d1a2120d93a9814cf6d6361 +Subproject commit cc8e414c16dc502c62c7fec3743f6134a28b4e39 From d71ddcb39e0bfaf2d25feaabce85879a59b90c44 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 4 Dec 2024 17:57:16 -0700 Subject: [PATCH 2/5] Update current Torch ref. --- tools/Torch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Torch b/tools/Torch index cc8e414c..7ae1fed7 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit cc8e414c16dc502c62c7fec3743f6134a28b4e39 +Subproject commit 7ae1fed709989c56d63791e2f6e4713f6e0868de From 1df1ec5d66b144b419f13edb6ec9f5591cc895c0 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 4 Dec 2024 19:56:22 -0700 Subject: [PATCH 3/5] Add semicolon to _UNICODE compile option items. --- CMakeLists.txt | 4 ++-- tools/Torch | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a923fcf..7d02a904 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,7 +235,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") ">" "INCLUDE_GAME_PRINTF;" "UNICODE;" - "_UNICODE" + "_UNICODE;" "_CRT_SECURE_NO_WARNINGS;" "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) @@ -253,7 +253,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "INCLUDE_GAME_PRINTF;" "WIN32;" "UNICODE;" - "_UNICODE" + "_UNICODE;" "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) endif() diff --git a/tools/Torch b/tools/Torch index 7ae1fed7..31a164ac 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 7ae1fed709989c56d63791e2f6e4713f6e0868de +Subproject commit 31a164acc2f755be474a597e13ab8c366fe52d5a From d3d110fecc4b5fbbc311580bd23ad0694cee7f15 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Thu, 5 Dec 2024 18:17:44 -0700 Subject: [PATCH 4/5] Add copy action for assets folder and config.yml to build dir to reference for extraction with Torchlib. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d02a904..cf0daf0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,10 @@ set(VCPKG_TRIPLET x64-windows-static) set(VCPKG_TARGET_TRIPLET x64-windows-static) vcpkg_bootstrap() vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 glew glfw3 nlohmann-json tinyxml2 spdlog) +if(NOT EXISTS ${CMAKE_BINARY_DIR}/config.yml) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/config.yml" "${CMAKE_BINARY_DIR}/config.yml") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/assets/" "${CMAKE_BINARY_DIR}/assets/") +endif() endif() if (MSVC) @@ -348,7 +352,6 @@ add_custom_target( ExtractAssets DEPENDS TorchExternal WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 COMMAND ${TORCH_EXECUTABLE} pack port starship.otr COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" From 07bd9b68c5a896dc7595c801ad164212c245c740 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Thu, 5 Dec 2024 18:38:33 -0700 Subject: [PATCH 5/5] Update Torch ref to latest main. --- tools/Torch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Torch b/tools/Torch index 31a164ac..42906f4d 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 31a164acc2f755be474a597e13ab8c366fe52d5a +Subproject commit 42906f4d1504939aa7f85f08a39308db250a6b14