build/MSVC: fix gettext multibyte issue #11774

Problem:  On Windows with the MSVC build, gettext-translation
          "Questa è già la" displays as "Questa <e8> gi<e0> la".
Solution: Fix iconv detection iconv when building gettext.
          So HAVE_ICONV is correctly defined when building nvim.

* fix gettext mb chars on MSVC
* fix libintl detection failure on MSVC

fixes #11749
This commit is contained in:
erw7 2020-01-28 17:56:26 +09:00 committed by Justin M. Keyes
parent 910cdac22c
commit d56f6fed9c
3 changed files with 20 additions and 8 deletions

View File

@ -454,17 +454,17 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA
message(FATAL_ERROR "Sanitizers are only supported for Clang")
endif()
if(ENABLE_LIBICONV)
find_package(Iconv REQUIRED)
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
endif()
if(ENABLE_LIBINTL)
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
find_package(LibIntl REQUIRED)
include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS})
endif()
if(ENABLE_LIBICONV)
find_package(Iconv REQUIRED)
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
endif()
# Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD
# explicitly to indicate a strong preference for pthread.
set(CMAKE_THREAD_PREFER_PTHREAD ON)

View File

@ -38,6 +38,9 @@ endif()
if (LibIntl_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LibIntl_LIBRARY}")
endif()
if (MSVC)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
endif()
check_c_source_compiles("
#include <libintl.h>
@ -48,6 +51,9 @@ int main(int argc, char** argv) {
bind_textdomain_codeset(\"foo\", \"bar\");
textdomain(\"foo\");
}" HAVE_WORKING_LIBINTL)
if (MSVC)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
endif()
if (LibIntl_INCLUDE_DIR)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${LibIntl_INCLUDE_DIR}")
endif()

View File

@ -8,6 +8,9 @@ endmacro()
file(READ gettext-runtime/config.h.in CONFIG_CONTENT)
string(REPLACE "#undef HAVE_GETCWD" "#define HAVE_GETCWD 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_ICONV_H" "#define HAVE_ICONV_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_ICONV" "#define HAVE_ICONV 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef ICONV_CONST" "#define ICONV_CONST const" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef uintmax_t" "
#if _WIN64
# define intmax_t long long
@ -54,7 +57,8 @@ PREFIX_LIST_ITEMS(libintl_SOURCES "gettext-runtime/intl/")
add_library(libintl ${libintl_SOURCES})
set_property(TARGET libintl APPEND PROPERTY INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl)
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl
${LIBICONV_INCLUDE_DIRS})
set_property(TARGET libintl APPEND PROPERTY COMPILE_DEFINITIONS
BUILDING_LIBINTL
IN_LIBINTL
@ -72,6 +76,8 @@ string(REPLACE "#undef ENDIANNESS" "#define ENDIANNESS 0" CONFIG_CONTENT ${CONFI
string(REPLACE "#undef GNULIB_FWRITEERROR" "#define GNULIB_FWRITEERROR 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_DECL_STRERROR_R" "#define HAVE_DECL_STRERROR_R 0" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_DUP2" "#define HAVE_DUP2 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_ICONV_H" "#define HAVE_ICONV_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_ICONV" "#define HAVE_ICONV 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_LIBUNISTRING" "#define HAVE_LIBUNISTRING 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_STDINT_H_WITH_UINTMAX" "#define HAVE_STDINT_H_WITH_UINTMAX 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_STDINT_H" "#define HAVE_STDINT_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
@ -126,7 +132,7 @@ set(GLIBC_SOURCE
mbchar.c mbslen.c mbsstr.c mbswidth.c obstack.c ostream.c html-ostream.c
fd-ostream.c styled-ostream.c progname.c html-styled-ostream.c printf-args.c
printf-parse.c propername.c quotearg.c rawmemchr.c safe-read.c safe-write.c
stpcpy.c stpncpy.c strchrnul.c striconveh.c striconveha.c strnlen1.c
stpcpy.c stpncpy.c strchrnul.c striconv.c striconveh.c striconveha.c strnlen1.c
term-ostream.c term-styled-ostream.c tparm.c trim.c gcd.c gl_linkedhash_list.c
uniconv/u8-conv-from-enc.c unictype/ctype_space.c unilbrk/lbrktables.c
unilbrk/u8-possible-linebreaks.c unilbrk/u8-width-linebreaks.c
@ -135,7 +141,7 @@ set(GLIBC_SOURCE
unistr/u8-mbtouc-unsafe-aux.c unistr/u8-mbtouc-unsafe.c unistr/u8-mbtouc.c
unistr/u8-mbtoucr.c unistr/u8-prev.c unistr/u8-uctomb-aux.c unistr/u8-uctomb.c
uniwidth/width.c vasnprintf.c vasprintf.c wcwidth.c xasprintf.c
xconcat-filename.c xerror.c xmalloc.c xstrdup.c xvasprintf.c glib/ghash.c
xconcat-filename.c xerror.c xmalloc.c xstrdup.c xstriconv.c xstriconveh.c xvasprintf.c glib/ghash.c
glib/glist.c glib/gmessages.c glib/gprimes.c glib/gstrfuncs.c glib/gstring.c
libcroco/cr-additional-sel.c libcroco/cr-attr-sel.c libcroco/cr-cascade.c
libcroco/cr-declaration.c libcroco/cr-doc-handler.c libcroco/cr-enc-handler.c