Skip to content

Commit c47ff28

Browse files
glebmAJenbo
authored andcommitted
macOS Tiger platform and instructions
1 parent cdff601 commit c47ff28

File tree

5 files changed

+111
-1
lines changed

5 files changed

+111
-1
lines changed

3rdParty/Lua/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ FetchContent_Declare_ExcludeFromAll(Lua
1515
)
1616
FetchContent_MakeAvailable_ExcludeFromAll(Lua)
1717

18-
if(ANDROID AND ("${ANDROID_ABI}" STREQUAL "armeabi-v7a" OR "${ANDROID_ABI}" STREQUAL "x86"))
18+
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND DARWIN_MAJOR_VERSION VERSION_EQUAL 8)
19+
# We need legacy-support from MacPorts for:
20+
# localtime_r gmtime_r
21+
find_package(MacportsLegacySupport REQUIRED)
22+
target_link_libraries(lua_static PRIVATE MacportsLegacySupport::MacportsLegacySupport)
23+
elseif(ANDROID AND ("${ANDROID_ABI}" STREQUAL "armeabi-v7a" OR "${ANDROID_ABI}" STREQUAL "x86"))
1924
target_compile_definitions(lua_internal INTERFACE -DLUA_USE_C89)
2025
elseif(NINTENDO_3DS OR VITA OR NINTENDO_SWITCH OR NXDK)
2126
target_compile_definitions(lua_static PUBLIC -DLUA_USE_C89)

CMake/Platforms.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,16 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
8888
# to detect available APIs.
8989
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}")
9090
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}")
91+
92+
if(DARWIN_MAJOR_VERSION VERSION_EQUAL 8)
93+
include(platforms/macos_tiger)
94+
endif()
95+
96+
# For older macOS, we assume MacPorts because Homebrew only supports newer version
97+
if(DARWIN_MAJOR_VERSION VERSION_LESS 11)
98+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/platforms/macports/finders")
99+
100+
# On MacPorts, libfmt is in a subdirectory:
101+
list(APPEND CMAKE_MODULE_PATH "/opt/local/lib/libfmt11/cmake")
102+
endif()
91103
endif()

CMake/platforms/macos_tiger.cmake

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ASAN and UBSAN are not supported by macports gcc14 on PowerPC.
2+
set(ASAN OFF)
3+
set(UBSAN OFF)
4+
5+
# SDL2 does not build for Tiger, so we use SDL1 instead.
6+
set(USE_SDL1 ON)
7+
8+
# ZeroTier is yet to be tested.
9+
set(DISABLE_ZERO_TIER ON)
10+
11+
# Use vendored libfmt until this issue is resolved:
12+
# https://trac.macports.org/ticket/71503
13+
set(DEVILUTIONX_SYSTEM_LIBFMT OFF)
14+
set(DEVILUTIONX_STATIC_LIBFMT ON)
15+
16+
# https://trac.macports.org/ticket/71511
17+
set(DEVILUTIONX_SYSTEM_GOOGLETEST OFF)
18+
set(DEVILUTIONX_STATIC_GOOGLETEST OFF)
19+
set(DEVILUTIONX_SYSTEM_BENCHMARK OFF)
20+
set(DEVILUTIONX_STATIC_BENCHMARK OFF)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Provides missing functions, such as localtime_r
2+
if(NOT TARGET MacportsLegacySupport::MacportsLegacySupport)
3+
set(MacportsLegacySupport_INCLUDE_DIR /opt/local/include/LegacySupport)
4+
mark_as_advanced(MacportsLegacySupport_INCLUDE_DIR)
5+
6+
find_library(MacportsLegacySupport_LIBRARY NAMES MacportsLegacySupport
7+
PATHS /opt/local/lib)
8+
mark_as_advanced(MacportsLegacySupport_LIBRARY)
9+
10+
include(FindPackageHandleStandardArgs)
11+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
12+
MacportsLegacySupport
13+
DEFAULT_MSG
14+
MacportsLegacySupport_LIBRARY MacportsLegacySupport_INCLUDE_DIR)
15+
16+
if(MacportsLegacySupport_FOUND)
17+
set(MacportsLegacySupport_LIBRARIES ${MacportsLegacySupport_LIBRARY})
18+
set(MacportsLegacySupport_INCLUDE_DIRS ${MacportsLegacySupport_INCLUDE_DIR})
19+
add_library(MacportsLegacySupport::MacportsLegacySupport UNKNOWN IMPORTED)
20+
set_target_properties(
21+
MacportsLegacySupport::MacportsLegacySupport PROPERTIES
22+
INTERFACE_INCLUDE_DIRECTORIES "${MacportsLegacySupport_INCLUDE_DIR}"
23+
)
24+
set_target_properties(
25+
MacportsLegacySupport::MacportsLegacySupport PROPERTIES
26+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
27+
IMPORTED_LOCATION "${MacportsLegacySupport_LIBRARY}"
28+
)
29+
endif()
30+
endif()

docs/building.md

+43
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,49 @@ Executing `Packaging/miyoo_mini/build.sh` will create the folder `build-miyoo-mi
528528
OnionOS Port Collection.
529529
</details>
530530

531+
<details><summary>macOS 10.4 Tiger</summary>
532+
533+
For macOS Tiger, DevilutionX can be compiled using the compiler and libraries from [MacPorts](https://www.macports.org/).
534+
535+
For PowerPC, you can use precompiled dependencies from here:
536+
537+
http://macports-tiger-ppc.glebm.com/
538+
539+
After installing MacPorts, run:
540+
541+
~~~ bash
542+
# Some packages may require you to manually deactivate certain ports during installation.
543+
# Remember to reactivate them after installing.
544+
sudo port install curl curl-ca-bundle gcc14 cmake \
545+
libsdl12 libsdl_image libsodium bzip2 zlib lua54
546+
547+
# Set GCC 14 as the default GCC:
548+
sudo port select --set gcc mp-gcc14
549+
~~~
550+
551+
<!-- The following packages have issues so we use the vendored versions:
552+
libfmt11 google-benchmark gtest -->
553+
554+
Then, build DevilutionX:
555+
556+
~~~ bash
557+
CC=gcc cmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCPACK=ON -DMACOSX_STANDALONE_APP_BUNDLE=ON
558+
cmake --build build-rel -j "$(sysctl -n hw.ncpu)"
559+
560+
# `sudo` is required to produce a bundle with all the shared libraries.
561+
sudo cmake --build build-rel --target package -j "$(sysctl -n hw.ncpu)"
562+
~~~
563+
564+
To run tools from the `tools/` directory (only needed for development), you also need Python:
565+
566+
~~~ bash
567+
sudo port install python312
568+
sudo port select --set python python312
569+
sudo port select --set python3 python312
570+
~~~
571+
572+
</details>
573+
531574
<details><summary><b>CMake build options</b></summary>
532575

533576
### General

0 commit comments

Comments
 (0)