2013-08-21 11:34:26 +00:00
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
# Licence details can be found in the file COPYING.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013 Kornel Benko kornel@lyx.org
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# LYX2LYX = ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
|
|
|
|
# LYXFILE = xxx
|
|
|
|
#
|
|
|
|
# Script should be called like:
|
2014-01-31 18:10:23 +00:00
|
|
|
# cmake -DLYX_PYTHON_EXECUTABLE=xxx \
|
|
|
|
# -DLYX2LYX=xxx \
|
2013-08-25 09:41:10 +00:00
|
|
|
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
|
2013-08-21 11:34:26 +00:00
|
|
|
# -DWORKDIR=${BUILD_DIR}/autotests/out-home \
|
|
|
|
# -DLYXFILE=xxx \
|
|
|
|
# -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake"
|
|
|
|
#
|
|
|
|
|
2013-08-22 22:48:58 +00:00
|
|
|
string(RANDOM LENGTH 5 errorfile)
|
|
|
|
string(RANDOM LENGTH 6 outputfile)
|
2014-01-31 18:10:23 +00:00
|
|
|
message(STATUS "Executing ${LYX_PYTHON_EXECUTABLE} ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}")
|
2013-08-21 11:34:26 +00:00
|
|
|
execute_process(
|
2014-01-31 18:10:23 +00:00
|
|
|
COMMAND ${LYX_PYTHON_EXECUTABLE} ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}
|
2013-08-21 11:34:26 +00:00
|
|
|
RESULT_VARIABLE _err)
|
|
|
|
|
|
|
|
message(STATUS "Error output of lyx2lyx = ${_err}")
|
|
|
|
string(COMPARE NOTEQUAL ${_err} 0 _erg)
|
|
|
|
|
|
|
|
# Check file "errors" being empty
|
2013-08-22 22:48:58 +00:00
|
|
|
file(STRINGS ${errorfile} foundErrors)
|
2013-08-21 11:34:26 +00:00
|
|
|
if(foundErrors)
|
|
|
|
foreach(_l ${foundErrors})
|
2015-11-29 14:26:56 +00:00
|
|
|
if (NOT _l MATCHES "Warning: No conversion needed:")
|
|
|
|
set(_erg 1)
|
|
|
|
message(STATUS "${_l}")
|
|
|
|
endif()
|
2013-08-21 11:34:26 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2013-08-22 22:48:58 +00:00
|
|
|
# Check the output-file being not empty
|
|
|
|
file(STRINGS ${outputfile} createdLyx)
|
2013-08-21 11:34:26 +00:00
|
|
|
if(NOT createdLyx)
|
|
|
|
set(_erg 1)
|
|
|
|
message(STATUS "Created file empty")
|
|
|
|
endif()
|
|
|
|
|
2013-08-22 22:48:58 +00:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${errorfile} ${outputfile})
|
2013-08-21 11:34:26 +00:00
|
|
|
if(_erg)
|
|
|
|
message(FATAL_ERROR "lyx2lyx failed")
|
|
|
|
endif()
|