Cmake build: Make sure that a sequence of commands to recreate layouttranslations failes

Factored out the sequence into one cmake-script.
Previously it could happen that the python script failed, but the following
command was successfull and so the error was hidden.
This commit is contained in:
Kornel Benko 2016-07-23 20:30:45 +02:00
parent 0f4c14bba2
commit 40597c3be9
2 changed files with 41 additions and 4 deletions

View File

@ -43,10 +43,13 @@ macro(add_gettext_python _par _dir)
ADD_CUSTOM_COMMAND(
OUTPUT "${_dst}"
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}"
COMMAND ${LYX_PYTHON_EXECUTABLE}
ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dst}" "${TOP_SRC_DIR}/lib/layouttranslations"
COMMAND ${CMAKE_COMMAND}
"-DTOP_SRC_DIR=${TOP_SRC_DIR}"
"-DDestFile=${_dst}"
"-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
"-DParType=${_par1}"
"-DSources=${_src_files}"
-P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
DEPENDS ${_sources} ${_src_files} "${TOP_SRC_DIR}/lib/layouttranslations"
COMMENT "${LYX_PYTHON_EXECUTABLE} ${TOP_SRC_DIR}/po/lyx_pot.py -b ${TOP_SRC_DIR} -o ${_dst} -t ${_par1} --src_file=${_src_files}"
)

View File

@ -0,0 +1,34 @@
# -DTOP_SRC_DIR=xxx \
# -DDestFile=xxx \
# -DLYX_PYTHON_EXECUTABLE=xxx \
# -DParType=xxx \
# -DSources=xxx \
set(_dst ${DestFile})
set(type ${ParType})
set(_src_files ${Sources})
message(STATUS "Starting CreateLayoutTranslations")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}"
RESULT_VARIABLE _err)
string(COMPARE EQUAL ${_err} 0 _erg)
if(NOT _erg)
message(FATAL_ERROR "CreateLayoutTranslations: Copy of layouttranslations failed")
endif()
execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE}
"${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${type}
"--src_file=${_src_files}"
RESULT_VARIABLE _err)
string(COMPARE EQUAL ${_err} 0 _erg)
if(NOT _erg)
message(FATAL_ERROR "CreateLayoutTranslations: Calling python wit errors")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dst}" "${TOP_SRC_DIR}/lib/layouttranslations"
RESULT_VARIABLE _err)
if(NOT _erg)
message(FATAL_ERROR "CreateLayoutTranslations: Copy of layouttranslations to source failed")
endif()