cmake: Check for libcharset and use if found.

For Visual Studio, the static builds now require linking libcharset
explicitly, otherwise an `unresolved external symbol locale_charset`
error is thrown during linking.

This library is sometimes required on other platforms for iconv/gettext,
and checking for it and linking it should be harmless.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2020-01-17 16:03:07 +00:00
parent 0c0a35fd04
commit 77c299c13f
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 7 additions and 2 deletions

View File

@ -418,8 +418,9 @@ if(ENABLE_NLS)
endif()
if(ENABLE_LINK OR ENABLE_WX)
find_path(LIBINTL_INC libintl.h)
find_library(LIBINTL_LIB NAMES intl libintl)
find_library(LIBICONV_LIB NAMES iconv libiconv)
find_library(LIBINTL_LIB NAMES intl libintl)
find_library(LIBICONV_LIB NAMES iconv libiconv)
find_library(LIBCHARSET_LIB NAMES charset libcharset)
if(LIBINTL_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIB})
list(APPEND VBAMCORE_LIBS ${LIBINTL_LIB})
@ -428,6 +429,10 @@ if(ENABLE_NLS)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_LIB})
list(APPEND VBAMCORE_LIBS ${LIBICONV_LIB})
endif()
if(LIBCHARSET_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_LIB})
list(APPEND VBAMCORE_LIBS ${LIBCHARSET_LIB})
endif()
include(CheckFunctionExists)
check_function_exists(gettext GETTEXT_FN)
if(NOT (LIBINTL_INC OR GETTEXT_FN))