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.
This commit is contained in:
briaguya
2026-07-25 04:33:01 -04:00
parent 5730fdb73d
commit 4bd6581354
3 changed files with 22 additions and 7 deletions
-5
View File
@@ -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
+16 -2
View File
@@ -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
)
+6
View File
@@ -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()