From 4bd658135484df96b6c80d9578fda6baa5db454a Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya0@users.noreply.github.com> Date: Sat, 25 Jul 2026 04:33:01 -0400 Subject: [PATCH] Fix macos and windows builds, keep the tools out of the game build macos: libultraship declares spdlog with OVERRIDE_FIND_PACKAGE so its own find_package(spdlog REQUIRED) resolves, but torch declares spdlog without it, and FetchContent_Declare is first-wins. Configuring torch first made LUS's declaration a no-op and left find_package with no config to find. It only showed on macos because that's the platform where neither project finds an installed spdlog -- it's kept out of macports.yml because its fmt dependency breaks the universal build -- so both fall through to fetching. Declaring it ahead of both keeps macos on the same source-built v1.16.0 it used before. Torch already uses OVERRIDE_FIND_PACKAGE for tinyxml2 and zlib, so the real fix is upstream. windows: soh builds with /WX, and TorchExtract.cpp is the one translation unit reaching yaml-cpp through torch's headers, which trips the dll-interface warnings. Suppress those two on that file. EXCLUDE_FROM_ALL on soh-torch and soh-o2r-packer: they are build-time tools, so building the game shouldn't compile them. ExtractAssets and GenerateSohOtr still pull them in through DEPENDS. Drops the .gitattributes rule for the prebuilt archive, which is gone. --- .gitattributes | 5 ----- CMakeLists.txt | 18 ++++++++++++++++-- soh/CMakeLists.txt | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3b11aee0fe..6313b56c57 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1 @@ * text=auto eol=lf - -# TEMPORARY (Torch migration): checked-in archive. text=auto would almost certainly -# detect this as binary anyway, but an eol conversion on a 4.4 MB zip would corrupt it -# silently, so say so explicitly. Remove with prebuilt/ -- see prebuilt/README.md. -prebuilt/soh.o2r binary diff --git a/CMakeLists.txt b/CMakeLists.txt index b6ab7a1179..d700113ab4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,20 @@ find_package(ZLIB REQUIRED) include(FetchContent) +# Workaround: torch declares spdlog without OVERRIDE_FIND_PACKAGE and the first declaration +# wins, which leaves libultraship's find_package(spdlog REQUIRED) with no config to find. +# Declaring it here first keeps that working. See HarbourMasters/Torch#233. +find_package(spdlog QUIET) +if(NOT spdlog_FOUND) + FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.16.0 + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(spdlog) +endif() + set(USE_STANDALONE OFF CACHE BOOL "" FORCE) # static lib, no CLI set(PORT_VERSION_ENDIANNESS ON CACHE BOOL "" FORCE) # 7-byte portVersion set(ROM_CRC_BSWAP OFF CACHE BOOL "" FORCE) @@ -218,14 +232,14 @@ FetchContent_MakeAvailable(torch) # Build-time ROM extraction. soh links torch as a static library, which compiles out torch's # own CLI, so this supplies an entry point around the same code the game runs. -add_executable(soh-torch +add_executable(soh-torch EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/tools/torch-cli/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/soh/soh/Extractor/TorchExtract.cpp ) target_include_directories(soh-torch PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/soh/soh/Extractor) target_link_libraries(soh-torch PRIVATE torch) -add_executable(soh-o2r-packer +add_executable(soh-o2r-packer EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/tools/soh-o2r-packer/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/tools/soh-o2r-packer/PngTexture.cpp ) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 8d15b6f4ff..462ca6412e 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -226,6 +226,12 @@ set(ALL_FILES ################################################################################ add_executable(${PROJECT_NAME} ${ALL_FILES}) +if(MSVC) + # yaml-cpp, reached through torch's headers, trips the dll-interface warnings, and soh + # builds with /WX. + set_source_files_properties(soh/Extractor/TorchExtract.cpp PROPERTIES COMPILE_OPTIONS "/wd4251;/wd4275") +endif() + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") endif()