Skip to content

Commit

Permalink
build/msvc: Add support for building gettext tools with MSVC
Browse files Browse the repository at this point in the history
Only includes the tools needed for Neovim: xgettext, msgfmt, and
msgmerge.
  • Loading branch information
b-r-o-c-k committed Jun 10, 2018
1 parent d87e5d7 commit e17728a
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 63 deletions.
10 changes: 0 additions & 10 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,9 @@ set(WIN32YANK_X86_64_SHA256 33a747a92da60fb65e668edbf7661d3d902411a2d545fe9dc086
set(WINPTY_URL https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip)
set(WINPTY_SHA256 35a48ece2ff4acdcbc8299d4920de53eb86b1fb41e64d2fe5ae7898931bcee89)

# gettext source (for building/linking, does NOT provide tools like msgmerge.exe)
set(GETTEXT_URL https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.gz)
set(GETTEXT_SHA256 ff942af0e438ced4a8b0ea4b0b6e0d6d657157c5e2364de57baa279c1c125c43)

# gettext binary (for tools like msgmerge.exe)
set(GETTEXT_X86_URL https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.19.8.1-v1.15/gettext0.19.8.1-iconv1.15-shared-32.zip)
set(GETTEXT_X86_SHA256 b7d8fe2d038950bc0447d664db614ebfc3100a1ba962a959d78e41bc708a2140)
set(GETTEXT_X86_64_URL https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.19.8.1-v1.15/gettext0.19.8.1-iconv1.15-shared-64.zip)
set(GETTEXT_X86_64_SHA256 c8ed2897438efc0a511892c2b38b623ef0c9092aced2acbd3f3daf2f12ba70b4)

set(LIBICONV_URL https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz)
set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178)

Expand Down Expand Up @@ -244,9 +237,6 @@ if(WIN32)
GetBinaryDep(TARGET "win32yank_${TARGET_ARCH}"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_INSTALL_DIR}/bin)

GetBinaryDep(TARGET "gettext_${TARGET_ARCH}"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory bin ${DEPS_INSTALL_DIR}/bin)

if("${TARGET_ARCH}" STREQUAL "X86_64")
set(TARGET_ARCH x64)
elseif(TARGET_ARCH STREQUAL "X86")
Expand Down
10 changes: 8 additions & 2 deletions third-party/cmake/BuildGettext.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ if(MSVC)
PATCH_COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/gettext init
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/gettext apply --ignore-whitespace
${CMAKE_CURRENT_SOURCE_DIR}/patches/gettext-Fix-compilation-on-a-system-without-alloca.patch
${CMAKE_CURRENT_SOURCE_DIR}/patches/gettext-Fix-building-with-MSVC.patch
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/cmake/GettextCMakeLists.txt
${DEPS_BUILD_DIR}/src/gettext/gettext-runtime/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/gettext/gettext-runtime
${DEPS_BUILD_DIR}/src/gettext/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/gettext
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
# Pass toolchain
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DLIBICONV_INCLUDE_DIRS=${DEPS_INSTALL_DIR}/include
-DLIBICONV_LIBRARIES=${DEPS_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}libcharset${CMAKE_STATIC_LIBRARY_SUFFIX}$<SEMICOLON>${DEPS_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}libiconv${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})

Expand All @@ -32,3 +35,6 @@ else()
endif()

list(APPEND THIRD_PARTY_DEPS gettext)
if(USE_BUNDLED_LIBICONV)
add_dependencies(gettext libiconv)
endif()
288 changes: 238 additions & 50 deletions third-party/cmake/GettextCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
cmake_minimum_required(VERSION 2.8.7)
project(libintl C)
project(gettext C)

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# Adds PREFIX to each item in LIST
macro(PREFIX_LIST_ITEMS LIST PREFIX)
string(REPLACE ";" ";${PREFIX}" ${LIST} ";${${LIST}}")
endmacro()

file(READ config.h.in CONFIG_CONTENT)
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 uintmax_t" "
#if _WIN64
Expand All @@ -14,70 +17,255 @@ string(REPLACE "#undef uintmax_t" "
# define uintmax_t unsigned long
#endif"
CONFIG_CONTENT ${CONFIG_CONTENT})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h ${CONFIG_CONTENT})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/config.h ${CONFIG_CONTENT})

set(HAVE_NEWLOCALE 0)
set(HAVE_POSIX_PRINTF 0)
set(HAVE_SNPRINTF 0)
set(HAVE_ASPRINTF 0)
set(HAVE_WPRINTF 0)
configure_file(intl/libgnuintl.in.h libgnuintl.h)
configure_file(gettext-runtime/intl/libgnuintl.in.h
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl/libgnuintl.h)

set(LOCALDIR "gettext")
set(LIBDIR "gettext")
set(PKGDATADIR "gettext")
set(PACKAGE_SUFFIX "gettext")
add_definitions(-DLOCALEDIR=\"${LOCALDIR}\"
-DLOCALE_ALIAS_PATH=\"${LOCALDIR}\"
-DLIBDIR=\"${LOCALDIR}\"
-DINSTALLDIR=\"${LOCALDIR}\")

add_definitions(-DBUILDING_LIBINTL
-DIN_LIBINTL
-DENABLE_RELOCATABLE=1
-DIN_LIBRARY
-DNO_XMALLOC
-Dset_relocation_prefix=libintl_set_relocation_prefix
-Drelocate=libintl_relocate
-DHAVE_CONFIG_H
-D_CRT_SECURE_NO_WARNINGS)

FILE(GLOB SOURCES
intl/bindtextdom.c
intl/dcgettext.c
intl/dcigettext.c
intl/dcngettext.c
intl/dgettext.c
intl/dngettext.c
intl/explodename.c
intl/finddomain.c
intl/gettext.c
intl/hash-string.c
intl/l10nflist.c
intl/langprefs.c
intl/loadmsgcat.c
intl/localcharset.c
intl/localealias.c
intl/localename.c
intl/lock.c
intl/log.c
intl/ngettext.c
intl/plural-exp.c
intl/plural.c
intl/printf.c
intl/relocatable.c
intl/setlocale.c
intl/textdomain.c
intl/threadlib.c
intl/version.c)

add_library(libintl ${SOURCES})
-DINSTALLDIR=\"${LOCALDIR}\"
-DEXEEXT=\".exe\"
-DLOCALEDIR=\"${LOCALDIR}\"
-DLIBDIR=\"${LIBDIR}\"
-DPACKAGE_SUFFIX=\"${PACKAGE_SUFFIX}\"
-DGETTEXTDATADIR=\"${PKGDATADIR}\"
-DBISON_LOCALEDIR=\"${LOCALDIR}\"
-DHAVE_CONFIG_H)

set(libintl_SOURCES
bindtextdom.c dcgettext.c dcigettext.c dcngettext.c dgettext.c dngettext.c
explodename.c finddomain.c gettext.c hash-string.c l10nflist.c langprefs.c
loadmsgcat.c localcharset.c localealias.c localename.c lock.c log.c ngettext.c
plural-exp.c plural.c printf.c relocatable.c setlocale.c textdomain.c
threadlib.c version.c)
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)
set_property(TARGET libintl APPEND PROPERTY COMPILE_DEFINITIONS
BUILDING_LIBINTL
IN_LIBINTL
ENABLE_RELOCATABLE=1
IN_LIBRARY
NO_XMALLOC
set_relocation_prefix=libintl_set_relocation_prefix
relocate=libintl_relocate
HAVE_CONFIG_H
_CRT_SECURE_NO_WARNINGS)


file(READ gettext-tools/config.h.in CONFIG_CONTENT)
string(REPLACE "#undef ENDIANNESS" "#define ENDIANNESS 0" CONFIG_CONTENT ${CONFIG_CONTENT})
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_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})
string(REPLACE "#undef HAVE_STRING_H" "#define HAVE_STRING_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_SYS_TIMEB_H" "#define HAVE_SYS_TIMEB_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE__FTIME" "#define HAVE__FTIME 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef ICONV_CONST" "#define ICONV_CONST const" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef PACKAGE" "#define PACKAGE \"gettext\"\n#define gettext_VERSION" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef VERSION" "#define VERSION \"\"" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef mode_t" "#define mode_t int" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef pid_t" "#define pid_t int" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef restrict" "#define restrict __restrict" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef ssize_t" "#include <BaseTsd.h>\n#define ssize_t SSIZE_T" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef uid_t" "#define uid_t int" CONFIG_CONTENT ${CONFIG_CONTENT})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gettext-tools/config.h ${CONFIG_CONTENT})

set(libgettextsrc_COMMON_SOURCE
message.c po-error.c po-xerror.c read-catalog-abstract.c po-lex.c
po-gram-gen.c po-charset.c read-po.c read-properties.c read-stringtable.c
open-catalog.c dir-list.c
str-list.c)

set(libgettextsrc_FORMAT_SOURCE
format.c format-invalid.h format-c.c format-c-parse.h format-sh.c
format-python.c format-python-brace.c format-lisp.c format-elisp.c
format-librep.c format-scheme.c format-java.c format-csharp.c format-awk.c
format-pascal.c format-ycp.c format-tcl.c format-perl.c format-perl-brace.c
format-php.c format-gcc-internal.c format-gfc-internal.c format-qt.c
format-qt-plural.c format-kde.c format-kde-kuit.c format-boost.c format-lua.c
format-javascript.c)

set(libgettextsrc_SOURCES
${libgettextsrc_COMMON_SOURCE} read-catalog.c color.c write-catalog.c
write-properties.c write-stringtable.c write-po.c msgl-ascii.c msgl-iconv.c
msgl-equal.c msgl-cat.c msgl-header.c msgl-english.c msgl-check.c file-list.c
msgl-charset.c po-time.c plural-exp.c plural-eval.c plural-count.c
plural-table.c quote.h sentence.h sentence.c ${libgettextsrc_FORMAT_SOURCE}
read-desktop.c locating-rule.c its.c search-path.c)
PREFIX_LIST_ITEMS(libgettextsrc_SOURCES "gettext-tools/src/")

set(GLIBC_SOURCE
uniname/uniname.c javaexec.c unsetenv.c classpath.c setenv.c xsetenv.c
sh-quote.c execute.c javaversion.c csharpcomp.c csharpexec.c javacomp.c
gettimeofday.c getdtablesize.c fcntl.c dup-safer-flag.c cloexec.c
fd-safer-flag.c fd-safer.c pipe2.c pipe2-safer.c spawn-pipe.c xmemdup0.c
secure_getenv.c tmpdir.c tempname.c mkdtemp.c fnmatch.c clean-temp.c
gl_array_list.c tputs.c wait-process.c waitpid.c getdelim.c getline.c
sigprocmask.c sigaction.c addext.c argmatch.c backupfile.c basename.c
c-strcasecmp.c c-strncasecmp.c c-strstr.c closeout.c concat-filename.c
error-progname.c error.c exitfail.c file-ostream.c fstrcmp.c full-write.c
fwriteerror.c getopt.c getopt1.c hash.c libxml/buf.c localcharset.c malloca.c
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
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
unilbrk/ulc-common.c unilbrk/ulc-width-linebreaks.c unistr/u16-mbtouc-aux.c
unistr/u16-mbtouc.c unistr/u8-check.c unistr/u8-mblen.c unistr/u8-mbtouc-aux.c
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
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
libcroco/cr-fonts.c libcroco/cr-input.c libcroco/cr-num.c
libcroco/cr-om-parser.c libcroco/cr-parser.c libcroco/cr-parsing-location.c
libcroco/cr-prop-list.c libcroco/cr-pseudo.c libcroco/cr-rgb.c
libcroco/cr-sel-eng.c libcroco/cr-selector.c libcroco/cr-simple-sel.c
libcroco/cr-statement.c libcroco/cr-string.c libcroco/cr-style.c
libcroco/cr-stylesheet.c libcroco/cr-term.c libcroco/cr-tknzr.c
libcroco/cr-token.c libcroco/cr-utils.c libxml/DOCBparser.c
libxml/HTMLparser.c libxml/HTMLtree.c libxml/SAX.c libxml/SAX2.c libxml/c14n.c
libxml/catalog.c libxml/chvalid.c libxml/debugXML.c libxml/dict.c
libxml/encoding.c libxml/entities.c libxml/error.c libxml/globals.c
libxml/hash.c libxml/legacy.c libxml/list.c libxml/nanoftp.c libxml/nanohttp.c
libxml/parser.c libxml/parserInternals.c libxml/pattern.c libxml/relaxng.c
libxml/schematron.c libxml/threads.c libxml/tree.c libxml/trionan.c
libxml/uri.c libxml/valid.c libxml/xinclude.c libxml/xlink.c libxml/xmlIO.c
libxml/xmlmemory.c libxml/xmlmodule.c libxml/xmlreader.c libxml/xmlregexp.c
libxml/xmlsave.c libxml/xmlschemas.c libxml/xmlschemastypes.c
libxml/xmlstring.c libxml/xmlunicode.c libxml/xmlwriter.c libxml/xpath.c
libxml/xpointer.c fatal-signal.c copy-file.c)
PREFIX_LIST_ITEMS(GLIBC_SOURCE "gettext-tools/gnulib-lib/")

set(libgettextsrc_SOURCES ${libgettextsrc_SOURCES} ${GLIBC_SOURCE})

set(HEADER_TEMPLATES_PATH "gettext-tools/gnulib-lib")
set(HEADER_TEMPLATES_ABS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER_TEMPLATES_PATH}")
file(GLOB_RECURSE HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/*.in.h")
list(REMOVE_ITEM HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/stdint.in.h")
list(REMOVE_ITEM HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/wchar.in.h")
foreach(HEADER_TEMPLATE ${HEADER_TEMPLATES})
file(READ ${HEADER_TEMPLATE} HEADER_CONTENT)
string(REPLACE "/* The definition of _GL_ARG_NONNULL is copied here. */" "#include \"arg-nonnull.h\"" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "/* The definition of _GL_WARN_ON_USE is copied here. */" "#include \"warn-on-use.h\"" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */" "#include \"c++defs.h\"" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_LSTAT@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_MBSINIT@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_SIGACTION@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_SIGPROCMASK@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_STPCPY@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_STPNCPY@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@GNULIB_STRCHRNUL@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@HAVE_ISWCNTRL@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@HAVE_WCTYPE_T@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "@PRAGMA_COLUMNS@" "" HEADER_CONTENT "${HEADER_CONTENT}")

string(REGEX REPLACE "^${HEADER_TEMPLATES_ABS_PATH}/" "" HEADER_PATH "${HEADER_TEMPLATE}")
string(REPLACE ".in" "" HEADER_PATH ${HEADER_PATH})
string(REPLACE "_" "/" HEADER_PATH ${HEADER_PATH})
# find_file will create a cache entry for the variable
# SYSTEM_HEADER, so reset it before each call
set(SYSTEM_HEADER "SYSTEM_HEADER-NOTFOUND")
find_file(SYSTEM_HEADER ${HEADER_PATH} PATHS "${LIBICONV_INCLUDE_DIRS}")
if(SYSTEM_HEADER)
# Gnulib uses #include_next to extend system header files,
# but MSVC doesn't support it, so a regular include directive
# with a relative path is used instead
string(REGEX REPLACE ".*/(.*/${HEADER_PATH})" "../\\1"
INCLUDE_PATH "${SYSTEM_HEADER}")
string(REGEX REPLACE "@INCLUDE_NEXT[^@]*@ @NEXT_[^@\n]+@"
"include <${INCLUDE_PATH}>" HEADER_CONTENT "${HEADER_CONTENT}")
endif()

# Default any remaining template variables to 0
string(REGEX REPLACE "@[^@\n]+@" "0" HEADER_CONTENT "${HEADER_CONTENT}")

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${HEADER_TEMPLATES_PATH}/${HEADER_PATH}" "${HEADER_CONTENT}")
endforeach()

add_library(libgettextsrc ${libgettextsrc_SOURCES})
target_link_libraries(libgettextsrc ${LIBICONV_LIBRARIES})

set(msgmerge_SOURCES
msgmerge.c
msgl-fsearch.c
lang-table.c
)
PREFIX_LIST_ITEMS(msgmerge_SOURCES "gettext-tools/src/")

add_executable(msgmerge ${msgmerge_SOURCES})
target_link_libraries(msgmerge libgettextsrc)
add_dependencies(msgmerge libgettextsrc libintl)

set(msgfmt_SOURCES
msgfmt.c
write-mo.c
write-java.c
write-csharp.c
write-resources.c
write-tcl.c
write-qt.c
write-desktop.c
write-xml.c)
PREFIX_LIST_ITEMS(msgfmt_SOURCES "gettext-tools/src/")

add_executable(msgfmt ${msgfmt_SOURCES} gettext-runtime/intl/hash-string.c)
target_link_libraries(msgfmt libgettextsrc)
add_dependencies(msgfmt libgettextsrc libintl)

set(xgettext_SOURCES
xgettext.c x-c.c x-po.c x-sh.c x-python.c x-lisp.c x-elisp.c x-librep.c
x-scheme.c x-smalltalk.c x-java.c x-csharp.c x-awk.c x-ycp.c x-tcl.c x-perl.c
x-php.c x-rst.c x-lua.c x-javascript.c x-vala.c x-desktop.c)
PREFIX_LIST_ITEMS(xgettext_SOURCES "gettext-tools/src/")

add_executable(xgettext ${xgettext_SOURCES})
target_link_libraries(xgettext libgettextsrc)
add_dependencies(xgettext libgettextsrc libintl)

set_property(TARGET msgmerge msgfmt xgettext libgettextsrc APPEND PROPERTY
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/gettext-runtime/intl
${CMAKE_CURRENT_SOURCE_DIR}/gettext-tools/libgettextpo
${CMAKE_CURRENT_SOURCE_DIR}/gettext-tools/gnulib-lib
${CMAKE_CURRENT_SOURCE_DIR}/gettext-tools/gnulib-lib/libcroco
${CMAKE_CURRENT_SOURCE_DIR}/build-aux/snippet
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl
${CMAKE_CURRENT_BINARY_DIR}/gettext-tools
${CMAKE_CURRENT_BINARY_DIR}/gettext-tools/gnulib-lib
${LIBICONV_INCLUDE_DIRS})

include(GNUInstallDirs)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/libgnuintl.h
${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl/libgnuintl.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RENAME libintl.h)

install(TARGETS libintl
install(TARGETS libintl msgmerge msgfmt xgettext
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
5 changes: 4 additions & 1 deletion third-party/cmake/LibiconvCMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "${CONFIG_CONTENT}")
set(BROKEN_WCHAR_H 0)
set(HAVE_VISIBILITY 0)
set(HAVE_WCHAR_T 1)
set(ICONV_CONST "const")
set(USE_MBSTATE_T 0)
configure_file(libcharset/include/localcharset.h.build.in localcharset.h)
configure_file(include/iconv.h.build.in iconv.h)
Expand All @@ -45,7 +46,9 @@ target_link_libraries(iconv libiconv)
set(HEADER_TEMPLATES_PATH "srclib")
set(HEADER_TEMPLATES_ABS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER_TEMPLATES_PATH}")
file(GLOB_RECURSE HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/*.in.h")
foreach(HEADER_TEMPLATE IN LISTS HEADER_TEMPLATES)
list(REMOVE_ITEM HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/stdint.in.h")
list(REMOVE_ITEM HEADER_TEMPLATES "${HEADER_TEMPLATES_ABS_PATH}/wchar.in.h")
foreach(HEADER_TEMPLATE ${HEADER_TEMPLATES})
file(READ ${HEADER_TEMPLATE} HEADER_CONTENT)
string(REPLACE "/* The definition of _GL_ARG_NONNULL is copied here. */" "#include \"arg-nonnull.h\"" HEADER_CONTENT "${HEADER_CONTENT}")
string(REPLACE "/* The definition of _GL_WARN_ON_USE is copied here. */" "#include \"warn-on-use.h\"" HEADER_CONTENT "${HEADER_CONTENT}")
Expand Down
Loading

0 comments on commit e17728a

Please sign in to comment.