]> git.lyx.org Git - lyx.git/blob - development/autotests/export.cmake
80ceed93ca81ae780a31c41783d318ce38c33f7b
[lyx.git] / development / autotests / export.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) 2012 Kornel Benko kornel@lyx.org
5 #
6 #
7 # LYX_ROOT  = ${TOP_SRC_DIR}/lib/{doc,examples,templates}
8 # LYX_USERDIR_VER = Name of environment variable for the user directory
9 # lyx       = 
10 # format    = lyx16x|xhtml
11 # extension = 16.lyx|xhtml
12 # file      = xxx
13 #
14 # Script should be called like:
15 # cmake -DLYX_ROOT=xxx \
16 #       -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
17 #       -DWORKDIR=${BUILD_DIR}/autotests/out-home \
18 #       -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
19 #       -Dlyx=xxx \
20 #       -Dformat=xxx \
21 #       -Dextension=xxx \
22 #       -Dfile=xxx \
23 #       -Dreverted=[01] \
24 #       -DTOP_SRC_DIR=${TOP_SRC_DIR}
25 #       -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
26 #       -P "${TOP_SRC_DIR}/development/autotests/export.cmake"
27 #
28
29 set(Perl_Script "${TOP_SRC_DIR}/development/autotests/useSystemFonts.pl")
30 if(format MATCHES "pdf4|pdf5")
31   message(STATUS "LYX_TESTS_USERDIR = ${LYX_TESTS_USERDIR}")
32   message(STATUS "Converting with perl ${Perl_Script}")
33   set(LYX_SOURCE "${WORKDIR}/${file}_${format}.lyx")
34   message(STATUS "Using source \"${LYX_ROOT}/${file}.lyx\"")
35   message(STATUS "Using dest \"${LYX_SOURCE}\"")
36   execute_process(COMMAND ${PERL_EXECUTABLE} "${Perl_Script}" "${LYX_ROOT}/${file}.lyx" "${LYX_SOURCE}" ${format}
37     RESULT_VARIABLE _err)
38   string(COMPARE EQUAL  ${_err} 0 _erg)
39   if(NOT _erg)
40     message(FATAL_ERROR "Export failed while converting")
41   endif()
42 else()
43   message(STATUS "Not converting")
44   set(LYX_SOURCE "${LYX_ROOT}/${file}.lyx")
45 endif()
46
47 message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${format} ${file}.${extension} \"${LYX_SOURCE}\"")
48 set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
49 execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${file}.${extension})
50 execute_process(
51   COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${file}.${extension} "${LYX_SOURCE}"
52   RESULT_VARIABLE _err)
53 if(reverted)
54   string(COMPARE EQUAL  ${_err} 0 _erg)
55 else()
56   string(COMPARE NOTEQUAL  ${_err} 0 _erg)
57 endif()
58 if(_erg)
59   message(STATUS "Exporting ${f}.lyx to ${format}")
60   message(FATAL_ERROR "Export failed")
61 endif()