From 0bdd5f294e285d96a5a107a426e861414af2fca8 Mon Sep 17 00:00:00 2001 From: sfence Date: Fri, 2 May 2025 21:28:13 +0200 Subject: [PATCH] Make SDL2 default on macOS (#16039) --- .github/workflows/macos.yml | 2 +- doc/compiling/README.md | 1 + irr/src/CMakeLists.txt | 19 +++++++++++-------- irr/src/OpenGL3/{Driver.cpp => DriverGL3.cpp} | 2 +- irr/src/OpenGL3/{Driver.h => DriverGL3.h} | 0 .../OpenGLES2/{Driver.cpp => DriverGLES2.cpp} | 2 +- irr/src/OpenGLES2/{Driver.h => DriverGLES2.h} | 0 misc/macos/Info.plist.in | 2 +- src/client/item_visuals_manager.h | 1 + src/server/blockmodifier.h | 1 + util/ci/build_xcode.sh | 4 +++- util/ci/common.sh | 2 +- 12 files changed, 22 insertions(+), 14 deletions(-) rename irr/src/OpenGL3/{Driver.cpp => DriverGL3.cpp} (99%) rename irr/src/OpenGL3/{Driver.h => DriverGL3.h} (100%) rename irr/src/OpenGLES2/{Driver.cpp => DriverGLES2.cpp} (99%) rename irr/src/OpenGLES2/{Driver.h => DriverGLES2.h} (100%) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c073fe106..859cd3060 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -45,7 +45,7 @@ jobs: mkdir build cd build cmake .. \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=13 \ -DCMAKE_FIND_FRAMEWORK=LAST \ -DCMAKE_INSTALL_PREFIX=../build/macos/ \ -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE \ diff --git a/doc/compiling/README.md b/doc/compiling/README.md index 16167977b..9ce8a800e 100644 --- a/doc/compiling/README.md +++ b/doc/compiling/README.md @@ -23,6 +23,7 @@ General options and their default values: PRECOMPILE_HEADERS=FALSE - Precompile some headers (experimental; requires CMake 3.16 or later) PRECOMPILED_HEADERS_PATH= - Path to a file listing all headers to precompile (default points to src/precompiled_headers.txt) USE_SDL2=TRUE - Build with SDL2; Enables IrrlichtMt device SDL2 + USE_SDL2_STATIC=TRUE - Links with SDL2::SDL2-static instead of SDL2::SDL2 ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal) ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations diff --git a/irr/src/CMakeLists.txt b/irr/src/CMakeLists.txt index 8b6f71b3a..e41457532 100644 --- a/irr/src/CMakeLists.txt +++ b/irr/src/CMakeLists.txt @@ -1,11 +1,9 @@ -# When enabling SDL2 by default on macOS, don't forget to change -# "NSHighResolutionCapable" to true in "Info.plist". -if(NOT APPLE) - set(DEFAULT_SDL2 ON) -endif() +set(DEFAULT_SDL2 ON) option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2}) +option(USE_SDL2_STATIC "Link with SDL2 static libraries" FALSE) + # Compiler flags if(CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -228,7 +226,11 @@ endif() if(ENABLE_OPENGL) find_package(OpenGL REQUIRED) endif() +set(USE_SDL2_SHARED FALSE) if(USE_SDL2) + if(NOT USE_SDL2_STATIC) + set(USE_SDL2_SHARED TRUE) + endif() if(NOT ANDROID) find_package(SDL2 REQUIRED) else() @@ -364,14 +366,14 @@ endif() if(ENABLE_OPENGL3) set(IRRDRVROBJ ${IRRDRVROBJ} - OpenGL3/Driver.cpp + OpenGL3/DriverGL3.cpp ) endif() if(ENABLE_GLES2) set(IRRDRVROBJ ${IRRDRVROBJ} - OpenGLES2/Driver.cpp + OpenGLES2/DriverGLES2.cpp ) endif() @@ -505,7 +507,8 @@ target_link_libraries(IrrlichtMt PRIVATE ${ZLIB_LIBRARY} ${JPEG_LIBRARY} ${PNG_LIBRARY} - "$<$:SDL2::SDL2>" + "$<$:SDL2::SDL2>" + "$<$:SDL2::SDL2-static>" "$<$:${OPENGL_LIBRARIES}>" ${EGL_LIBRARY} diff --git a/irr/src/OpenGL3/Driver.cpp b/irr/src/OpenGL3/DriverGL3.cpp similarity index 99% rename from irr/src/OpenGL3/Driver.cpp rename to irr/src/OpenGL3/DriverGL3.cpp index 09286b027..057305869 100644 --- a/irr/src/OpenGL3/Driver.cpp +++ b/irr/src/OpenGL3/DriverGL3.cpp @@ -2,7 +2,7 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in Irrlicht.h -#include "Driver.h" +#include "DriverGL3.h" #include #include #include "mt_opengl.h" diff --git a/irr/src/OpenGL3/Driver.h b/irr/src/OpenGL3/DriverGL3.h similarity index 100% rename from irr/src/OpenGL3/Driver.h rename to irr/src/OpenGL3/DriverGL3.h diff --git a/irr/src/OpenGLES2/Driver.cpp b/irr/src/OpenGLES2/DriverGLES2.cpp similarity index 99% rename from irr/src/OpenGLES2/Driver.cpp rename to irr/src/OpenGLES2/DriverGLES2.cpp index 84e702a8f..f806cdd5c 100644 --- a/irr/src/OpenGLES2/Driver.cpp +++ b/irr/src/OpenGLES2/DriverGLES2.cpp @@ -2,7 +2,7 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in Irrlicht.h -#include "Driver.h" +#include "DriverGLES2.h" #include #include #include "mt_opengl.h" diff --git a/irr/src/OpenGLES2/Driver.h b/irr/src/OpenGLES2/DriverGLES2.h similarity index 100% rename from irr/src/OpenGLES2/Driver.h rename to irr/src/OpenGLES2/DriverGLES2.h diff --git a/misc/macos/Info.plist.in b/misc/macos/Info.plist.in index 9d5432708..0cb03cab8 100644 --- a/misc/macos/Info.plist.in +++ b/misc/macos/Info.plist.in @@ -21,6 +21,6 @@ LSApplicationCategoryType public.app-category.games NSHighResolutionCapable - + diff --git a/src/client/item_visuals_manager.h b/src/client/item_visuals_manager.h index 8684ef477..36604f0c7 100644 --- a/src/client/item_visuals_manager.h +++ b/src/client/item_visuals_manager.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "wieldmesh.h" // ItemMesh #include "util/basic_macros.h" diff --git a/src/server/blockmodifier.h b/src/server/blockmodifier.h index 602147ae0..55b2c355d 100644 --- a/src/server/blockmodifier.h +++ b/src/server/blockmodifier.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "irr_v3d.h" #include "mapnode.h" diff --git a/util/ci/build_xcode.sh b/util/ci/build_xcode.sh index b31d22789..8d36b2815 100755 --- a/util/ci/build_xcode.sh +++ b/util/ci/build_xcode.sh @@ -3,8 +3,10 @@ cmake .. \ -DCMAKE_FIND_FRAMEWORK=LAST \ -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE \ + -DUSE_SDL2_STATIC=TRUE \ + -DSDL2_INCLUDE_DIRS=/opt/homebrew/include/SDL2 \ -DFREETYPE_LIBRARY=/opt/homebrew/lib/libfreetype.a \ - -DGETTEXT_INCLUDE_DIR=/path/to/include/dir \ + -DGETTEXT_INCLUDE_DIR=/opt/homebrew/include \ -DGETTEXT_LIBRARY=/opt/homebrew/lib/libintl.a \ -DLUA_LIBRARY=/opt/homebrew/lib/libluajit-5.1.a \ -DOGG_LIBRARY=/opt/homebrew/lib/libogg.a \ diff --git a/util/ci/common.sh b/util/ci/common.sh index 4d4fe1195..374aabf5f 100644 --- a/util/ci/common.sh +++ b/util/ci/common.sh @@ -29,7 +29,7 @@ install_linux_deps() { install_macos_deps() { local pkgs=( cmake gettext freetype gmp jpeg-turbo jsoncpp leveldb - libogg libpng libvorbis luajit zstd + libogg libpng libvorbis luajit zstd sdl2 ) export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALL_CLEANUP=1