Cmake build: Make missing polib less destructive.

Configure still whines, but proceeds succesfull.
Only the target 'layouttranslations1' will fail.
This commit is contained in:
Kornel Benko 2016-07-27 07:34:50 +02:00
parent 056422dae9
commit cbd4e332f7
2 changed files with 9 additions and 3 deletions

View File

@ -12,8 +12,6 @@ include_directories(${TOP_SRC_DIR}/po)
SET(_lyxname ${PACKAGE}) SET(_lyxname ${PACKAGE})
SET(_py_sources) SET(_py_sources)
# Idea stolen from http://public.kitware.com/pipermail/cmake/2011-January/041666.html
macro(add_gettext_python _par _dir) macro(add_gettext_python _par _dir)
set(_sources) set(_sources)
foreach(_arg ${ARGN}) foreach(_arg ${ARGN})
@ -45,7 +43,10 @@ macro(add_gettext_python _par _dir)
if (${_par} MATCHES "layouttranslations") if (${_par} MATCHES "layouttranslations")
# lyx_pot.py requires the module "polib" if using target layouttranslations1, # lyx_pot.py requires the module "polib" if using target layouttranslations1,
# so we have to check for it # so we have to check for it
find_python_module("polib" REQUIRED) find_python_module("polib")
if ("${LYX_PY_POLIB}" STREQUAL "")
message(STATUS "You will be unable to update layouttranslations file")
endif()
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT "${_dst}" OUTPUT "${_dst}"
PRE_BUILD PRE_BUILD
@ -55,6 +56,7 @@ macro(add_gettext_python _par _dir)
"-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}" "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
"-DParType=${_par1}" "-DParType=${_par1}"
"-DSources=${_src_files}" "-DSources=${_src_files}"
"-DLYX_PY_POLIB=${LYX_PY_POLIB1}"
-P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake" -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
DEPENDS ${_sources} ${_src_files} "${TOP_SRC_DIR}/lib/layouttranslations" 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}" 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

@ -9,6 +9,7 @@
# -DLYX_PYTHON_EXECUTABLE=xxx \ # -DLYX_PYTHON_EXECUTABLE=xxx \
# -DParType=xxx \ # -DParType=xxx \
# -DSources=xxx \ # -DSources=xxx \
# -DLYX_PY_POLIB=${LYX_PY_POLIB} \
# -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake" # -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
set(_dst ${DestFile}) set(_dst ${DestFile})
@ -23,6 +24,9 @@ macro(die_if _err text)
endmacro() endmacro()
message(STATUS "Starting CreateLayoutTranslations") message(STATUS "Starting CreateLayoutTranslations")
if ("${LYX_PY_POLIB}" STREQUAL "")
message(STATUS "Missing needed pythons polib, be prepared for error")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}" execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}"
RESULT_VARIABLE _err) RESULT_VARIABLE _err)
die_if(_err "Copy of layouttranslations failed") die_if(_err "Copy of layouttranslations failed")