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) include_directories(BEFORE Externals/curl/include)
endif() endif()
if (NOT ANDROID) if(NOT ANDROID)
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) find_package(Iconv)
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
endif() endif()
if (NOT ANDROID AND ICONV_LIBRARIES AND ICONV_INCLUDE_DIR) if(TARGET Iconv::Iconv)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES) message(STATUS "Using shared iconv")
else() else()
check_vendoring_approved(iconv) check_vendoring_approved(iconv)
message(STATUS "Using static iconv from Externals") message(STATUS "Using static iconv from Externals")
include_directories(Externals/libiconv-1.14/include)
add_subdirectory(Externals/libiconv-1.14) add_subdirectory(Externals/libiconv-1.14)
set(ICONV_LIBRARIES iconv)
endif() endif()
if(NOT ANDROID) if(NOT ANDROID)

View File

@ -1,10 +1,13 @@
include_directories(include) add_library(iconv STATIC
include_directories(libcharset/include) lib/iconv.c
lib/relocatable.c
set(SRCS lib/iconv.c libcharset/lib/localcharset.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) dolphin_disable_warnings_msvc(iconv)
add_library(Iconv::Iconv ALIAS iconv)

View File

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