commit 6743c6fa87ec1604d908378b576545f17038fa15
Author: Kornel Benko <[email protected]>
Date:   Sun Jul 24 09:30:14 2016 +0200

    Add comment + factor out the error checking
---
 po/CreateLayoutTranslations.cmake |   39 ++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/po/CreateLayoutTranslations.cmake 
b/po/CreateLayoutTranslations.cmake
index 22e3a52..9f3d533 100644
--- a/po/CreateLayoutTranslations.cmake
+++ b/po/CreateLayoutTranslations.cmake
@@ -1,34 +1,39 @@
-# -DTOP_SRC_DIR=xxx \
-# -DDestFile=xxx \
-# -DLYX_PYTHON_EXECUTABLE=xxx \
-# -DParType=xxx \
-# -DSources=xxx \
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# Copyright (c) 2016 Kornel Benko [email protected]
+#
+# Script should be called like:
+# cmake -DTOP_SRC_DIR=xxx \
+#       -DDestFile=xxx \
+#       -DLYX_PYTHON_EXECUTABLE=xxx \
+#       -DParType=xxx \
+#       -DSources=xxx \
+#       -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
 
 set(_dst ${DestFile})
 set(type ${ParType})
 set(_src_files ${Sources})
 
+macro(die_if _err text)
+  string(COMPARE EQUAL  ${${_err}} 0 _erg)
+  if(NOT _erg)
+    message(FATAL_ERROR "CreateLayoutTranslations: ${text}")
+  endif()
+endmacro()
+
 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()
+die_if(_err "Copy of layouttranslations failed")
 
 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()
+die_if(_err "Calling lyx_pot.py failed")
 
 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()
+die_if(_err "Copy of layouttranslations to source failed")
 

Reply via email to