]> git.lyx.org Git - features.git/blob - development/cmake/po/CMakeLists.txt
This is a try to shorten the length of the command line when creating
[features.git] / development / cmake / po / CMakeLists.txt
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2008, 2009 Peter Kümmel, <syntheticpp@gmx.net>
5 # Copyright (c) 2008, 2009 Kornel Benko, <Kornel.Benko@berlin.de>
6 #
7
8 project(po)
9
10 include_directories(${TOP_SRC_DIR}/po)
11
12 SET(_lyxname ${PACKAGE})
13 SET(_py_sources)
14 macro(add_gettext_python  _par _dir)
15   set(_sources)
16   foreach(_arg ${ARGN})
17     file(GLOB _s1 ${TOP_SRC_DIR}/${_dir}/${_arg})
18     list(APPEND _sources ${_s1})
19   endforeach(_arg)
20   SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
21   if(${_par} MATCHES "^\(.*\)_[0-9]+$")
22     set(_par1 ${CMAKE_MATCH_1})
23   else()
24     set(_par1 ${_par})
25   endif()
26   ADD_CUSTOM_COMMAND(
27     OUTPUT "${_dst}"
28     PRE_BUILD
29     COMMAND python
30     ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} ${_sources}
31     DEPENDS ${_sources}
32     )
33   SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
34   LIST(APPEND _py_sources "${_dst}")
35 endmacro(add_gettext_python)
36
37 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
38 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
39 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
40
41 add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
42 add_gettext_python(layouts_1 lib/layouts *.layout)
43 add_gettext_python(layouts_2 lib/layouts *.inc)
44 add_gettext_python(layouts_3 lib/layouts *.module)
45 add_gettext_python(languages lib languages)
46 add_gettext_python(encodings lib encodings)
47 add_gettext_python(ui_1 lib/ui *.ui)
48 add_gettext_python(ui_2 lib/ui *.inc)
49 add_gettext_python(external lib external_templates)
50 add_gettext_python(formats lib configure.py)
51
52 FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
53 FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
54
55 # TODO:
56 #         We need here perl, because I don't know how
57 #         to write the alternative for "cat" in python
58 #         e.g. perl -e "\"while(<>){print;}\""
59 # But maybe Jose knows?
60
61 ADD_CUSTOM_COMMAND(
62     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
63     COMMAND ${_PERL_EXECUTABLE}
64     ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
65     DEPENDS ${_py_sources}
66     )
67
68 ADD_CUSTOM_COMMAND(
69     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
70     COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
71     ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
72     DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
73     )
74
75 SET(_potfiles_dep)
76
77 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
78 foreach(_dir src/frontends/qt4 src/insets src/mathed src/support src/tex2lyx src)
79     file(GLOB _tmp_potfiles RELATIVE ${TOP_SRC_DIR} ${TOP_SRC_DIR}/${_dir}/*.cpp)
80     foreach(_f ${_tmp_potfiles})
81         LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
82         file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
83     endforeach(_f)
84 endforeach(_dir)
85
86 ADD_CUSTOM_COMMAND(
87     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
88     COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
89     COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
90     ARGS --default-domain=${_lyxname} --directory=${TOP_SRC_DIR} --add-comments=TRANSLATORS: --language=C++ --join-existing --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ --files-from="${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in" --copyright-holder="LyX Developers" --msgid-bugs-address=lyx-devel@lists.lyx.org -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
91     DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
92     )
93
94 #
95 # We have to copy the po-files first,
96 # otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
97 # This makes the "svn up" on po-files work again
98 file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
99 set(LYX_PO_FILES)
100 foreach(_pofile ${LYX_BASE_PO_FILES})
101   add_custom_command(
102     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
103     COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
104     DEPENDS ${TOP_SRC_DIR}/po/${_pofile}
105     )
106   list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
107 endforeach(_pofile)
108
109 GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ALL ${LYX_PO_FILES})
110
111 # ADD_POFILES("lyx")
112