include(SelectLibraryConfigurations)

_find_package(${ARGS})
if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
    find_library(CHARSET_LIBRARY_DEBUG NAMES charsetd libcharsetd charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH)
    find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
    find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib)
    select_library_configurations(CHARSET)
    if(CHARSET_LIBRARIES)
        list(APPEND Iconv_LIBRARIES ${CHARSET_LIBRARIES})
        if(TARGET Iconv::Iconv)
            target_link_libraries(Iconv::Iconv INTERFACE ${CHARSET_LIBRARIES})
        endif()
    endif()
endif()
