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.
This commit is contained in:
2024-04-07 13:31:10 +01:00
parent cda6838c08
commit 449c173c9f

View File

@@ -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)