CMake: Use find_package and imported targets for Iconv

Fixes us forgetting to add its include directories, which could result in linking to a dylib from MacPorts while using the system's header, and failing to link because they use different function names
This commit is contained in:
TellowKrinkle
2023-03-30 13:12:48 -05:00
parent eb6bf08170
commit b9595a2230
3 changed files with 16 additions and 16 deletions

View File

@ -914,19 +914,16 @@ else()
include_directories(BEFORE Externals/curl/include)
endif()
if (NOT ANDROID)
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
if(NOT ANDROID)
find_package(Iconv)
endif()
if (NOT ANDROID AND ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
if(TARGET Iconv::Iconv)
message(STATUS "Using shared iconv")
else()
check_vendoring_approved(iconv)
message(STATUS "Using static iconv from Externals")
include_directories(Externals/libiconv-1.14/include)
add_subdirectory(Externals/libiconv-1.14)
set(ICONV_LIBRARIES iconv)
endif()
if(NOT ANDROID)