]> git.lyx.org Git - lyx.git/blob - po/CreateLayoutTranslations.cmake
Move Lexer to support/ directory (and lyx::support namespace)
[lyx.git] / po / CreateLayoutTranslations.cmake
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2016 Kornel Benko kornel@lyx.org
5 #
6 # Script should be called like:
7 # cmake -DTOP_SRC_DIR=xxx \
8 #       -DDestFile=xxx \
9 #       -DLYX_PYTHON_EXECUTABLE=xxx \
10 #       -DParType=xxx \
11 #       -DSources=xxx \
12 #       -DLYX_PY_POLIB=${LYX_PY_POLIB} \
13 #       -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
14
15 set(_dst ${DestFile})
16 set(type ${ParType})
17 set(_src_files ${Sources})
18
19 macro(die_if _err text)
20   string(COMPARE EQUAL  ${${_err}} 0 _erg)
21   if(NOT _erg)
22     message(FATAL_ERROR "CreateLayoutTranslations: ${text}")
23   endif()
24 endmacro()
25
26 message(STATUS "Starting CreateLayoutTranslations")
27 if ("${LYX_PY_POLIB}" STREQUAL "")
28   message(STATUS "Missing needed pythons polib, be prepared for error")
29 endif()
30 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}"
31   RESULT_VARIABLE _err)
32 die_if(_err "Copy of layouttranslations failed")
33
34 execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE}
35   "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${type}
36   "--src_file=${_src_files}"
37   OUTPUT_VARIABLE _err_out
38   RESULT_VARIABLE _err)
39 if(_err)
40   message(STATUS "${_err_out}")
41 endif()
42 die_if(_err "Calling lyx_pot.py failed")
43
44 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dst}" "${TOP_SRC_DIR}/lib/layouttranslations"
45   RESULT_VARIABLE _err)
46 die_if(_err "Copy of layouttranslations to source failed")
47