summaryrefslogtreecommitdiff
path: root/po/CMakeLists.txt
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-09-08 22:51:43 +0100
committerRoger Leigh <rleigh@debian.org>2013-09-29 16:45:34 +0100
commit4a272b256ea0cae74cad442eca75363e9d8edb47 (patch)
tree1450526d5688bb52b058db50634cfef0a1f53624 /po/CMakeLists.txt
parentf71acb7a31d7932cf3d5f8aaa1682787c18b2127 (diff)
downloadschroot-4a272b256ea0cae74cad442eca75363e9d8edb47.tar.gz
build: Add cmake build infrastructure
This permits building using cmake rather than the existing autoconf/automake/libtool infrastructure. The autotools- based build may be removed in future commits, but either may be used until that point.
Diffstat (limited to 'po/CMakeLists.txt')
-rw-r--r--po/CMakeLists.txt93
1 files changed, 93 insertions, 0 deletions
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
new file mode 100644
index 00000000..fb42a9c4
--- /dev/null
+++ b/po/CMakeLists.txt
@@ -0,0 +1,93 @@
+# Copyright © 2004-2013 Roger Leigh <rleigh@debian.org>
+#
+# schroot is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# schroot is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+#####################################################################
+
+if(BUILD_NLS)
+
+ set(domain schroot)
+ set(xgettext_options --keyword=_ --keyword=N_ --from-code=UTF-8
+ --boost --no-location)
+ set(copyright_holder "Roger Leigh <rleigh@debian.org>")
+ set(bug_address "Roger Leigh <rleigh@debian.org>")
+
+ file(READ LINGUAS languages)
+ STRING(REGEX REPLACE "\n" ";" languages "${languages}")
+ foreach(lang ${languages})
+ set(po_files ${po_files} "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po")
+ set(gmo_files ${gmo_files} "${lang}.gmo")
+ install(FILES "${lang}.gmo"
+ DESTINATION "${SCHROOT_LOCALE_DIR}/${lang}/LC_MESSAGES"
+ RENAME "${domain}.mo")
+ endforeach(lang)
+
+ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in potfiles)
+ STRING(REGEX REPLACE "\n" ";" potfiles "${potfiles}")
+ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES)
+ foreach(file ${potfiles})
+ set(translated_files ${translated_files} "${PROJECT_SOURCE_DIR}/${file}")
+ endforeach(file ${potfiles})
+
+ foreach(file ${translated_files})
+ if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/POTFILES)
+ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES "${file}\n")
+ else(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/POTFILES)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES "${file}\n")
+ endif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/POTFILES)
+ endforeach(file ${translated_files})
+
+ # xgettext creates schroot.pot
+ add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.pot"
+ COMMAND xgettext --default-domain=${domain} --add-comments=TRANSLATORS:
+ ${xgettext_options} --files-from "${CMAKE_CURRENT_BINARY_DIR}/POTFILES"
+ --copyright-holder=${copyright_holder}
+ --msgid-bugs-address=${bug_address}
+ -d "${domain}" -p "${CMAKE_CURRENT_SOURCE_DIR}"
+ COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.po" "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.pot"
+ DEPENDS ${translated_files}
+ VERBATIM)
+
+ # msgmerge --update
+ foreach(pofile ${po_files})
+ add_custom_command(OUTPUT "${pofile}"
+ COMMAND msgmerge --update "${pofile}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.pot"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.pot"
+ VERBATIM)
+ endforeach(pofile)
+
+ # msgfmt
+ foreach(lang ${languages})
+ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo"
+ COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo"
+ COMMAND msgfmt -c --statistics -o "${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po"
+ VERBATIM)
+ endforeach(lang)
+
+ add_custom_target(update-pot DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${domain}.pot")
+ add_custom_target(update-po DEPENDS ${po_files})
+if(GIT_RELEASE_ENABLE)
+ add_dependencies(git-release update-pot update-po)
+endif(GIT_RELEASE_ENABLE)
+
+ add_custom_target(update-gmo DEPENDS ${gmo_files})
+
+ add_custom_target(po-notify
+ COMMAND podebconf-report-po --call --withtranslators --noforce --podir=${CMAKE_CURRENT_SOURCE_DIR})
+
+endif(BUILD_NLS)