From 6fd9f4766d1485399b7523b09ce2cdc52da51a18 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 7 Aug 2025 15:35:42 +0200
Subject: [PATCH] android: support Google Play 16 kiB page size requirement
---
CMakeLists.txt | 2 ++
cmake/PrivateSdlFunctions.cmake | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b460254..66cfa1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,7 @@ if(SDLNET_BUILD_SHARED_LIBS)
target_link_libraries(${sdl3_net_target_name} PRIVATE SDL3::SDL3-shared)
endif()
sdl_add_warning_options(${sdl3_net_target_name} WARNING_AS_ERROR ${SDLNET_WERROR})
+sdl_add_platform_link_options(${sdl3_net_target_name})
if(WIN32)
if(SDLNET_BUILD_SHARED_LIBS)
target_sources(${sdl3_net_target_name} PRIVATE
@@ -296,6 +297,7 @@ if(SDLNET_SAMPLES)
add_executable(${TARGET} ${ARGN})
endif()
sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDLTTF_WERROR})
+ sdl_add_platform_link_options(${TARGET})
sdl_target_link_options_no_undefined(${TARGET})
target_link_libraries(${TARGET} PRIVATE SDL3_net::${sdl3_net_target_name})
target_link_libraries(${TARGET} PRIVATE ${sdl3_target_name})
diff --git a/cmake/PrivateSdlFunctions.cmake b/cmake/PrivateSdlFunctions.cmake
index 5fde085..6c44f1d 100644
--- a/cmake/PrivateSdlFunctions.cmake
+++ b/cmake/PrivateSdlFunctions.cmake
@@ -313,6 +313,13 @@ function(sdl_add_warning_options TARGET)
endif()
endfunction()
+function(sdl_add_platform_link_options TARGET)
+ if(ANDROID)
+ target_link_options(${TARGET} PRIVATE "-Wl,-z,max-page-size=16384")
+ target_link_options(${TARGET} PRIVATE "-Wl,-z,common-page-size=16384")
+ endif()
+endfunction()
+
function(sdl_no_deprecated_errors TARGET)
check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)