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)

View File

@ -1,10 +1,13 @@
include_directories(include)
include_directories(libcharset/include)
set(SRCS lib/iconv.c
lib/relocatable.c
libcharset/lib/localcharset.c
add_library(iconv STATIC
lib/iconv.c
lib/relocatable.c
libcharset/lib/localcharset.c
)
target_include_directories(iconv
PUBLIC
include
PRIVATE
libcharset/include
)
add_library(iconv STATIC ${SRCS})
dolphin_disable_warnings_msvc(iconv)
add_library(Iconv::Iconv ALIAS iconv)

View File

@ -156,7 +156,7 @@ PUBLIC
PRIVATE
${CURL_LIBRARIES}
FatFs
${ICONV_LIBRARIES}
Iconv::Iconv
${spng_target}
${VTUNE_LIBRARIES}
)