diff --git a/CMakeLists.txt b/CMakeLists.txt index 3904d059d3..12d1a574f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Externals/libiconv-1.14/CMakeLists.txt b/Externals/libiconv-1.14/CMakeLists.txt index 571a6f791c..9f04f671ff 100644 --- a/Externals/libiconv-1.14/CMakeLists.txt +++ b/Externals/libiconv-1.14/CMakeLists.txt @@ -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) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 8269290729..178799b888 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -156,7 +156,7 @@ PUBLIC PRIVATE ${CURL_LIBRARIES} FatFs - ${ICONV_LIBRARIES} + Iconv::Iconv ${spng_target} ${VTUNE_LIBRARIES} )