From 449c173c9ff0b10734d1966e49984fa87925af1b Mon Sep 17 00:00:00 2001 From: Miguel Horta Date: Sun, 7 Apr 2024 13:31:10 +0100 Subject: [PATCH] fix: fix FindICU both for Android and native FindICU when used natively (i.e. without Android.cmake, compilation for pc) uses PkgConfig. Old code would only check the first depedency returned by PkgConfig as ${PC_ICU_${MOD_NAME}_LIBRARY} would already be set for the remaing cycles, and no new find_library would be performed. This resulted in libicui18n being included thrice, but depedencies uc and data being ommited. --- cmake/FindICU.cmake | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cmake/FindICU.cmake b/cmake/FindICU.cmake index 53867c3337..378c8b26de 100644 --- a/cmake/FindICU.cmake +++ b/cmake/FindICU.cmake @@ -39,19 +39,21 @@ foreach(MOD_NAME IN LISTS ICU_FIND_COMPONENTS) endif() pkg_check_modules(PC_ICU_${MOD_NAME} QUIET icu-${MOD_NAME}) - # Check the libraries returned by pkg-config really exist. - unset(PC_LIBRARIES) - foreach(LIBRARY IN LISTS PC_ICU_${MOD_NAME}_LIBRARIES) - unset(PC_LIBRARY CACHE) - if(NOT PC_ICU_${MOD_NAME}_LIBRARY) - find_library(PC_LIBRARY NAMES ${LIBRARY}) - endif() - if(NOT PC_ICU_${MOD_NAME}_LIBRARY) - unset(PC_ICU_${MOD_NAME}_FOUND) - endif() - list(APPEND PC_LIBRARIES ${PC_LIBRARY}) - endforeach() - unset(PC_LIBRARY CACHE) + if(NOT ANDROID) + # Check the libraries returned by pkg-config really exist. + unset(PC_LIBRARIES) + foreach(LIBRARY IN LISTS PC_ICU_${MOD_NAME}_LIBRARIES) + unset(PC_LIBRARY CACHE) + find_library(PC_LIBRARY NAMES ${LIBRARY}) + if(NOT PC_LIBRARY) + unset(PC_ICU_${MOD_NAME}_FOUND) + endif() + list(APPEND PC_LIBRARIES ${PC_LIBRARY}) + endforeach() + unset(PC_LIBRARY CACHE) + else() + list(APPEND PC_LIBRARIES ${PC_ICU_${MOD_NAME}_LIBRARY}) + endif(NOT ANDROID) if(${PC_ICU_${MOD_NAME}_FOUND}) set(ICU_COMPONENT_FOUND TRUE)