diff options
| -rw-r--r-- | CMakeLists.txt | 28 | ||||
| -rw-r--r-- | cmake/TorchExternalFixes.cmake | 18 | ||||
| -rw-r--r-- | vcpkg.json | 12 |
3 files changed, 58 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 45dff319a..53ae41d78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,23 @@ cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) project(Spaghettify VERSION 1.0.0 LANGUAGES C CXX ASM) include(FetchContent) +# fmt's consteval format-string checking fails to compile under newer +# AppleClang (Xcode 16+) with the spdlog/fmt versions in use (both vcpkg's on +# CI and Torch's bundled copy — see cmake/TorchExternalFixes.cmake for the +# latter): +# error: call to consteval function 'fmt::basic_format_string<...>' is not +# a constant expression +# Defining FMT_CONSTEVAL as empty falls back to fmt's pre-C++20 constexpr +# checking, which compiles cleanly with identical runtime behavior. Scoped to +# AppleClang; other platforms and compilers are untouched. +# TODO: Temporary hack. Remove this (plus cmake/TorchExternalFixes.cmake and +# the vcpkg.json fmt/spdlog pins) once the Torch pin is bumped past Torch's +# spdlog/fmt update. Note the bump also needs matching MK64 loader changes, +# see the discussion on PR #712. +if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_definitions("FMT_CONSTEVAL=") +endif() + set(NATO_PHONETIC_ALPHABET "Alfa" "Bravo" "Charlie" "Delta" "Echo" "Foxtrot" "Golf" "Hotel" "India" "Juliett" "Kilo" "Lima" "Mike" "November" "Oscar" "Papa" @@ -704,10 +721,21 @@ add_custom_command( if(NOT CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") include(ExternalProject) + # Torch's pinned spdlog bundles an fmt that trips a consteval error under + # newer AppleClang (Xcode 16+): "call to consteval function + # 'fmt::basic_format_string<...>' is not a constant expression". Neutralize + # FMT_CONSTEVAL inside the Torch sub-build via CMAKE_PROJECT_INCLUDE (Torch's + # CMakeLists overwrites CMAKE_CXX_FLAGS, so flags can't be injected that + # way). Fixes the build-macos-arm64 job; the intel runner's older Xcode + # doesn't hit it. + # TODO: Temporary hack. Remove the CMAKE_PROJECT_INCLUDE line below (plus + # cmake/TorchExternalFixes.cmake itself) once the Torch pin is bumped past + # Torch's spdlog/fmt update, see the discussion on PR #712. ExternalProject_Add(TorchExternal PREFIX TorchExternal SOURCE_DIR ${CMAKE_SOURCE_DIR}/torch CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/torch + -DCMAKE_PROJECT_INCLUDE=${CMAKE_SOURCE_DIR}/cmake/TorchExternalFixes.cmake ) ExternalProject_Get_Property(TorchExternal install_dir) diff --git a/cmake/TorchExternalFixes.cmake b/cmake/TorchExternalFixes.cmake new file mode 100644 index 000000000..9dd5bf9e3 --- /dev/null +++ b/cmake/TorchExternalFixes.cmake @@ -0,0 +1,18 @@ +# Included in the TorchExternal sub-build via CMAKE_PROJECT_INCLUDE (runs right +# after Torch's project() call). +# +# Torch's pinned spdlog bundles an fmt whose consteval format-string checking +# fails to compile under newer AppleClang (Xcode 16+): +# error: call to consteval function 'fmt::basic_format_string<...>' is not a +# constant expression +# Defining FMT_CONSTEVAL to empty falls back to fmt's pre-C++20 constexpr +# checking, which compiles cleanly. Scoped to AppleClang so other platforms and +# compilers are untouched. add_compile_definitions (rather than CMAKE_CXX_FLAGS) +# because Torch's CMakeLists overwrites the latter. +# TODO: Temporary hack. Delete this file (plus the CMAKE_PROJECT_INCLUDE line +# in CMakeLists.txt and the vcpkg.json fmt/spdlog pins) once the Torch pin is +# bumped past Torch's spdlog/fmt update. Note the bump also needs matching +# MK64 loader changes, see the discussion on PR #712. +if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_definitions("FMT_CONSTEVAL=") +endif() diff --git a/vcpkg.json b/vcpkg.json index 53da50815..f1d6c7be3 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -31,5 +31,17 @@ "libogg", "libvorbis" ], + "overrides": [ + { + "$reason": "fmt 11.0.2 (spdlog's dependency) fails to compile under newer AppleClang (consteval format-string checking) and hard-defines FMT_CONSTEVAL with no override guard, so it cannot be disabled either. 10.2.1 keeps the #ifndef guard, letting the AppleClang-scoped FMT_CONSTEVAL= define in CMakeLists.txt take effect. spdlog is pinned to the matching 1.14.1 (1.15.x requires fmt >= 11). TODO: Temporary hack. Remove both pins (plus the FMT_CONSTEVAL blocks in CMakeLists.txt and cmake/TorchExternalFixes.cmake) once the Torch pin is bumped past Torch's spdlog/fmt update. Note the bump also needs matching MK64 loader changes, see the discussion on PR #712.", + "name": "fmt", + "version": "10.2.1", + "port-version": 2 + }, + { + "name": "spdlog", + "version": "1.14.1" + } + ], "builtin-baseline": "2e58bb35ff7a3a037920d959ce20cb4d8c22319a" } |
