1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
4 # Copyright (c) 2012 Kornel Benko kornel@lyx.org
10 # Make sure, the needed programs are in PATH
11 find_program(PCREGREP_EXE "pcregrep")
13 list(APPEND Missing "pcregrep")
15 find_program(WMCTRL_EXE "wmctrl")
17 list(APPEND Missing "wmctrl")
19 # This is needed to build xvkbd
20 # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
23 # Check for needed libraries for xvkbd
24 # do not add autotests, if any of them is lacking
28 list(APPEND Missing "X11")
30 find_package(PkgConfig)
32 foreach(_lb "xaw7" "xmu" "xtst")
33 pkg_check_modules(${_lb}LIB ${_lb})
34 if(${_lb}LIB_LIBRARIES)
35 list(APPEND XVFBDLIBS ${${_lb}LIB_LIBRARIES})
37 list(APPEND Missing ${_lb})
41 foreach(_lb "Xaw7" "Xmu")
42 find_library(${_lb}LIB ${_lb})
44 list(APPEND XVFBDLIBS ${${_lb}LIB})
46 list(APPEND Missing ${_lb})
49 foreach(_lb Xt XTest X11)
51 list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
53 list(APPEND Missing ${_lb})
58 list(REMOVE_DUPLICATES XVFBDLIBS)
62 message(STATUS "Missing libraries or programs to create xvkbd: ${Missing}")
63 message(STATUS "cmake build is therefore omiting autotests")
69 add_subdirectory(xvkbd)
71 set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
72 set(LYX_HOME "out-home")
73 set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
74 set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
75 file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
76 file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
77 list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
79 file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
81 foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
82 string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
83 add_test(NAME autotests/${_t}
84 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
85 COMMAND ${CMAKE_COMMAND}
86 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
87 -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
88 -DKEYTEST_INFILE=${_tf}
89 -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
91 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
92 -DKEYTEST_OUTFILE=${_t}-out.txt
94 -DLOCALE_DIR=${LOCALE_DIR}
95 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
100 macro(getoutputformats filepath varname)
101 file(STRINGS "${filepath}" lines)
102 set(${varname} "pdf") # try at least this one
104 if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
105 if(CMAKE_MATCH_1 STREQUAL "default")
106 set(found "xhtml" "pdf" "pdf2" "pdf5")
107 elseif(CMAKE_MATCH_1 STREQUAL "xhtml")
110 set(found "xhtml" ${CMAKE_MATCH_1})
112 set(${varname} ${found})
118 foreach(libsubfolder doc examples templates)
119 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
120 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
122 # Now create 2 lists. One for files in a language dir, one without
124 set(nolang_lyx_files)
125 foreach(f ${lyx_files})
126 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
128 list(APPEND lang_lyx_files ${f})
130 list(APPEND nolang_lyx_files ${f})
133 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
135 string(REGEX REPLACE "\\.lyx$" "" f ${f})
136 add_test(NAME export/${libsubfolder}/${f}_lyx16
137 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
138 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
139 -Dlyx=$<TARGET_FILE:${_lyx}>
143 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
144 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
145 foreach(format ${formatlist})
146 add_test(NAME export/${libsubfolder}/${f}_${format}
147 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
148 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
149 -Dlyx=$<TARGET_FILE:${_lyx}>
151 -Dextension=${format}
153 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")