From fcf9f78a81955ee50e724d9ecf47161a39933d7c Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Wed, 15 Nov 2023 14:44:29 +0100 Subject: [PATCH] Use position-independent code on Android even when linking statically --- cmake/Macros.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 7cf895f42..501aecfa8 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -212,6 +212,12 @@ macro(sfml_add_library module) sfml_set_common_ios_properties(${target}) endif() + if(SFML_OS_ANDROID) + # Always use position-independent code on Android, even when linking statically. + # This is needed because all c++ code is placed in a shared library on Android. + set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() + # add the install rule install(TARGETS ${target} EXPORT SFMLConfigExport RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin