From 53a7df7b69569772635acb1b7c31ff73c9635712 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 9 Dec 2024 06:46:09 +0000 Subject: [PATCH] macOS Tiger platform and instructions --- 3rdParty/Lua/CMakeLists.txt | 7 +++- CMake/Platforms.cmake | 9 +++++ CMake/platforms/macos_tiger.cmake | 10 ++++++ .../platforms/macports/finders/FindFmt.cmake | 31 +++++++++++++++++ .../finders/FindMacportsLegacySupport.cmake | 30 +++++++++++++++++ docs/building.md | 33 +++++++++++++++++++ 6 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 CMake/platforms/macos_tiger.cmake create mode 100644 CMake/platforms/macports/finders/FindFmt.cmake create mode 100644 CMake/platforms/macports/finders/FindMacportsLegacySupport.cmake diff --git a/3rdParty/Lua/CMakeLists.txt b/3rdParty/Lua/CMakeLists.txt index 2689c093c17..7dd61770735 100644 --- a/3rdParty/Lua/CMakeLists.txt +++ b/3rdParty/Lua/CMakeLists.txt @@ -15,7 +15,12 @@ FetchContent_Declare_ExcludeFromAll(Lua ) FetchContent_MakeAvailable_ExcludeFromAll(Lua) -if(ANDROID AND ("${ANDROID_ABI}" STREQUAL "armeabi-v7a" OR "${ANDROID_ABI}" STREQUAL "x86")) +if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND DARWIN_MAJOR_VERSION VERSION_EQUAL 8) + # We need legacy-support from MacPorts for: + # localtime_r gmtime_r + find_package(MacportsLegacySupport REQUIRED) + target_link_libraries(lua_static PRIVATE MacportsLegacySupport::MacportsLegacySupport) +elseif(ANDROID AND ("${ANDROID_ABI}" STREQUAL "armeabi-v7a" OR "${ANDROID_ABI}" STREQUAL "x86")) target_compile_definitions(lua_internal INTERFACE -DLUA_USE_C89) elseif(NINTENDO_3DS OR VITA OR NINTENDO_SWITCH OR NXDK) target_compile_definitions(lua_static PUBLIC -DLUA_USE_C89) diff --git a/CMake/Platforms.cmake b/CMake/Platforms.cmake index 76cd0d98a59..5e8a84b4d30 100644 --- a/CMake/Platforms.cmake +++ b/CMake/Platforms.cmake @@ -88,4 +88,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin") # to detect available APIs. string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}") string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}") + + if(DARWIN_MAJOR_VERSION VERSION_EQUAL 8) + include(platforms/macos_tiger) + endif() + + # For older macOS, we assume MacPorts because Homebrew only supports newer version + if(DARWIN_MAJOR_VERSION VERSION_LESS 11) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/platforms/macports/finders") + endif() endif() diff --git a/CMake/platforms/macos_tiger.cmake b/CMake/platforms/macos_tiger.cmake new file mode 100644 index 00000000000..22d421a258a --- /dev/null +++ b/CMake/platforms/macos_tiger.cmake @@ -0,0 +1,10 @@ +# Not supported by PowerPC gcc14. +set(ASAN OFF) + +set(USE_SDL1 ON) +set(DISABLE_ZERO_TIER ON) + +# Use vendored libfmt until this issue is resolved: +# https://trac.macports.org/ticket/71503 +set(DEVILUTIONX_SYSTEM_LIBFMT OFF) +set(DEVILUTIONX_STATIC_LIBFMT ON) diff --git a/CMake/platforms/macports/finders/FindFmt.cmake b/CMake/platforms/macports/finders/FindFmt.cmake new file mode 100644 index 00000000000..fa4f10b8c77 --- /dev/null +++ b/CMake/platforms/macports/finders/FindFmt.cmake @@ -0,0 +1,31 @@ +# MacPorts installs fmt into a versioned subdirectory +if(NOT TARGET fmt::fmt) + find_path(fmt_INCLUDE_DIR fmt/core.h + PATHS /opt/local/include/libfmt11) + mark_as_advanced(fmt_INCLUDE_DIR) + + find_library(fmt_LIBRARY NAMES fmt fmtd + PATHS /opt/local/lib/libfmt11) + mark_as_advanced(fmt_LIBRARY) + + include(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS( + fmt + DEFAULT_MSG + fmt_LIBRARY fmt_INCLUDE_DIR) + + if(fmt_FOUND) + set(fmt_LIBRARIES ${fmt_LIBRARY}) + set(fmt_INCLUDE_DIRS ${fmt_INCLUDE_DIR}) + add_library(fmt::fmt UNKNOWN IMPORTED GLOBAL) + set_target_properties( + fmt::fmt PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}" + ) + set_target_properties( + fmt::fmt PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${fmt_LIBRARY}" + ) + endif() +endif() diff --git a/CMake/platforms/macports/finders/FindMacportsLegacySupport.cmake b/CMake/platforms/macports/finders/FindMacportsLegacySupport.cmake new file mode 100644 index 00000000000..34dbc1fe2d5 --- /dev/null +++ b/CMake/platforms/macports/finders/FindMacportsLegacySupport.cmake @@ -0,0 +1,30 @@ +# Provides missing functions, such as localtime_r +if(NOT TARGET MacportsLegacySupport::MacportsLegacySupport) + set(MacportsLegacySupport_INCLUDE_DIR /opt/local/include/LegacySupport) + mark_as_advanced(MacportsLegacySupport_INCLUDE_DIR) + + find_library(MacportsLegacySupport_LIBRARY NAMES MacportsLegacySupport + PATHS /opt/local/lib) + mark_as_advanced(MacportsLegacySupport_LIBRARY) + + include(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS( + MacportsLegacySupport + DEFAULT_MSG + MacportsLegacySupport_LIBRARY MacportsLegacySupport_INCLUDE_DIR) + + if(MacportsLegacySupport_FOUND) + set(MacportsLegacySupport_LIBRARIES ${MacportsLegacySupport_LIBRARY}) + set(MacportsLegacySupport_INCLUDE_DIRS ${MacportsLegacySupport_INCLUDE_DIR}) + add_library(MacportsLegacySupport::MacportsLegacySupport UNKNOWN IMPORTED) + set_target_properties( + MacportsLegacySupport::MacportsLegacySupport PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MacportsLegacySupport_INCLUDE_DIR}" + ) + set_target_properties( + MacportsLegacySupport::MacportsLegacySupport PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MacportsLegacySupport_LIBRARY}" + ) + endif() +endif() diff --git a/docs/building.md b/docs/building.md index 7904f5a9bd8..dacd3202a78 100644 --- a/docs/building.md +++ b/docs/building.md @@ -528,6 +528,39 @@ Executing `Packaging/miyoo_mini/build.sh` will create the folder `build-miyoo-mi OnionOS Port Collection. +
macOS 10.4 Tiger + +For macOS Tiger, DevilutionX can be compiled using the compiler and libraries from [MacPorts](https://www.macports.org/). + +For PowerPC, you can use precompiled dependencies from here: + +http://macports-tiger-ppc.glebm.com/ + +After installing MacPorts, run: + +~~~ bash +# Some packages may require you to manually deactivate certain ports during installation. +# Remember to reactivate them after installing. +sudo port install curl curl-ca-bundle gcc14 cmake libsdl12 libsdl_image libsodium libfmt11 bzip2 zlib gtest python312 legacy-support + +# Set GCC 14 as the default GCC, Python 3.12 as the default Python: +sudo port select --set gcc mp-gcc14 +sudo port select --set python python312 +sudo port select --set python3 python312 + +# This will build and install `smpq` into /usr/local/bin which you need to add to your path: +tools/build_and_install_smpq.sh +~~~ + +Then, build DevilutionX: + +~~~ bash +CC=gcc cmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCPACK=ON +cmake --build build-rel -j "$(sysctl -n hw.ncpu)" +~~~ + +
+
CMake build options ### General