diff --git a/platform/android/android.cmake b/platform/android/android.cmake index 106764ac7..4ae596b3a 100644 --- a/platform/android/android.cmake +++ b/platform/android/android.cmake @@ -11,20 +11,24 @@ include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake) include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake) # cmake-format: off -target_compile_options(mbgl-vendor-csscolorparser PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-icu PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-parsedate PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-sqlite PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-compiler-options INTERFACE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) +# Apply size optimizations for both Release and RelWithDebInfo configs. +# Android AGP maps the release build variant to RelWithDebInfo (not Release), so we must +# include RelWithDebInfo here to ensure these flags are actually applied. +set(_OPT_CONFIGS "$,$>") +target_compile_options(mbgl-vendor-csscolorparser PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-icu PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-parsedate PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-sqlite PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-compiler-options INTERFACE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) # cmake-format: on target_link_libraries( mbgl-compiler-options INTERFACE - $<$:-O2> - $<$:-Wl,--icf=all> - $<$:-flto> - $<$:-fuse-ld=gold> + $<${_OPT_CONFIGS}:-O2> + $<${_OPT_CONFIGS}:-Wl,--icf=all> + $<${_OPT_CONFIGS}:-flto> + $<${_OPT_CONFIGS}:-fuse-ld=lld> ) target_sources(