cmake_minimum_required(VERSION 3.16)
project(gettext C)

add_compile_options(-w)
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4006")

# Adds PREFIX to each item in LIST
macro(PREFIX_LIST_ITEMS LIST PREFIX)
  string(REPLACE ";" ";${PREFIX}" ${LIST} ";${${LIST}}")
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_LONG_LONG_INT" "#define HAVE_LONG_LONG_INT 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})
if(MSVC)
  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})
else()
  string(REPLACE "#undef uintmax_t" "
    #if _WIN64
    # define intmax_t long long
    # define uintmax_t unsigned long long
    #elif _WIN32
    # define intmax_t long
    # define uintmax_t unsigned long
    #endif"
    CONFIG_CONTENT ${CONFIG_CONTENT})
  endif()
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)
set(HAVE_NAMELESS_LOCALES 0)
set(HAVE_LONG_LONG_INT 1)
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}\"
  -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 intl-compat.c l10nflist.c
  langprefs.c loadmsgcat.c localcharset.c localealias.c localename-table.c
  localename.c lock.c log.c ngettext.c osdep.c
  plural-exp.c plural.c printf.c relocatable.c setlocale.c textdomain.c
  threadlib.c version.c xsize.c)

PREFIX_LIST_ITEMS(libintl_SOURCES "gettext-runtime/intl/")

add_library(libintl ${libintl_SOURCES})
target_link_libraries(libintl ${LIBICONV_LIBRARIES})
set_property(TARGET libintl APPEND PROPERTY INCLUDE_DIRECTORIES
  ${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime
  ${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl
  ${LIBICONV_INCLUDE_DIRS})
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)


file(READ gettext-tools/config.h.in CONFIG_CONTENT)
string(REPLACE "#undef FLEXIBLE_ARRAY_MEMBER" "#define FLEXIBLE_ARRAY_MEMBER 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "__declspec (dllimport)" "" CONFIG_CONTENT ${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_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})
string(REPLACE "#undef HAVE_LONG_LONG_INT" "#define HAVE_LONG_LONG_INT 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 HAVE_FLOAT_H" "#define HAVE_FLOAT_H 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})
string(REPLACE "#undef HAVE_DECL___ARGV" "#define HAVE_DECL___ARGV 1" CONFIG_CONTENT ${CONFIG_CONTENT})
set(CONFIG_CONTENT "${CONFIG_CONTENT}\n#define isatty libtextstyle_isatty")
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
  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-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
  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
  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
  progname.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 striconv.c
  striconveh.c striconveha.c strnlen1.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 xstriconv.c xstriconveh.c xvasprintf.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 read-file.c ftello.c utime.c gettime.c utimens.c)
PREFIX_LIST_ITEMS(GLIBC_SOURCE "gettext-tools/gnulib-lib/")

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gettext-tools/gnulib-lib/configmake.h "#define PKGDATADIR \"gettext\"")

set(LIBGLIB_SOURCES
  ghash.c glist.c gmessages.c gprimes.c gstrfuncs.c gstring.c)
PREFIX_LIST_ITEMS(LIBGLIB_SOURCES "libtextstyle/lib/glib/")

set(LIBTEXTSTYLE_SOURCE
  gl_array_list.h gl_array_list.c binary-io.h
  binary-io.c c-ctype.h c-ctype.c c-strcase.h c-strcasecmp.c
  c-strncasecmp.c concat-filename.c dirname-lgpl.c
  basename-lgpl.c stripslash.c exitfail.c fatal-signal.h
  fatal-signal.c fd-hook.c fd-ostream.c file-ostream.c
  full-write.h full-write.c getprogname.h getprogname.c
  gettext.h hash.h hash.c html-ostream.c html-styled-ostream.c
  iconv-ostream.c gl_list.h gl_list.c math.c memory-ostream.c
  minmax.h noop-styled-ostream.c ostream.c safe-read.c
  safe-write.c sig-handler.c size_max.h styled-ostream.c
  term-ostream.c term-style-control.c term-styled-ostream.c
  unistd.c xalloc.h xmalloc.c xstrdup.c
  xconcat-filename.c gl_xlist.h gl_xlist.c xsize.h xsize.c
  xvasprintf.h xvasprintf.c xasprintf.c color.h color.c misc.h
  misc.c version.c isatty.c fsync.c tparm.c tputs.c)
PREFIX_LIST_ITEMS(LIBTEXTSTYLE_SOURCE "libtextstyle/lib/")

configure_file(
  libtextstyle/lib/stdbool.mini.h
  ${CMAKE_CURRENT_BINARY_DIR}/libtextstyle/lib/textstyle/stdbool.h
  COPYONLY)

set(LIBCROCO_SOURCES
  cr-additional-sel.c cr-attr-sel.c cr-cascade.c cr-declaration.c
  cr-doc-handler.c cr-enc-handler.c cr-fonts.c cr-input.c cr-num.c
  cr-om-parser.c cr-parser.c cr-parsing-location.c cr-prop-list.c cr-pseudo.c
  cr-rgb.c cr-sel-eng.c cr-selector.c cr-simple-sel.c cr-statement.c
  cr-string.c cr-style.c cr-stylesheet.c cr-term.c cr-tknzr.c cr-token.c
  cr-utils.c)
PREFIX_LIST_ITEMS(LIBCROCO_SOURCES "libtextstyle/lib/libcroco/")

set(libgettextsrc_SOURCES
  ${libgettextsrc_SOURCES} ${GLIBC_SOURCE} ${LIBGLIB_SOURCES}
  ${LIBTEXTSTYLE_SOURCE} ${LIBCROCO_SOURCES})

macro(CONFIGURE_HEADER_FILES HEADER_TEMPLATES_PATH)
  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 "@HAVE_STRUCT_TIMEVAL@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@HAVE_WINSOCK2_H@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@DLL_VARIABLE@" "" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@HAVE_NEWLOCALE@" "0" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@PRAGMA_COLUMNS@" "" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "#if @GNULIB_UTIME@" "#if 1\n#define utime gl_utime" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@HAVE_UTIME@" "1" HEADER_CONTENT "${HEADER_CONTENT}")
    string(REPLACE "@HAVE_LONG_LONG_INT@" "1" 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()
endmacro()

CONFIGURE_HEADER_FILES("gettext-tools/gnulib-lib")
CONFIGURE_HEADER_FILES("libtextstyle/lib")

add_library(libgettextsrc ${libgettextsrc_SOURCES})
target_link_libraries(libgettextsrc ${LIBICONV_LIBRARIES})
set_property(TARGET libgettextsrc APPEND PROPERTY COMPILE_DEFINITIONS
  LIBTEXTSTYLE_DLL_VARIABLE=)

set(msgmerge_SOURCES
  msgmerge.c msgl-fsearch.c lang-table.c plural-count.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
  ../../gettext-runtime/intl/hash-string.c)
PREFIX_LIST_ITEMS(msgfmt_SOURCES "gettext-tools/src/")

add_executable(msgfmt ${msgfmt_SOURCES})
target_link_libraries(msgfmt libgettextsrc)
add_dependencies(msgfmt libgettextsrc libintl)

set(xgettext_SOURCES
  xgettext.c xg-pos.c xg-encoding.c xg-mixed-string.c xg-arglist-context.c
  xg-arglist-callshape.c xg-arglist-parser.c xg-message.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_SOURCE_DIR}/libtextstyle/lib
    ${CMAKE_CURRENT_SOURCE_DIR}/libtextstyle/lib/libcroco
    ${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/intl
    ${CMAKE_CURRENT_BINARY_DIR}/gettext-tools
    ${CMAKE_CURRENT_BINARY_DIR}/gettext-tools/gnulib-lib
    ${CMAKE_CURRENT_BINARY_DIR}/libtextstyle/lib
    ${CMAKE_CURRENT_BINARY_DIR}/libtextstyle/lib/textstyle
    ${LIBICONV_INCLUDE_DIRS})

include(GNUInstallDirs)

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

install(TARGETS libintl msgmerge msgfmt xgettext
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

# vim: set ft=cmake:
