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})
57 list(REMOVE_DUPLICATES XVFBDLIBS)
60 message(STATUS "Missing Libraries or programms to create xvkbd: ${Missing}")
61 message(STATUS "cmake build is therefore omiting autotests")
67 add_subdirectory(xvkbd)
69 set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
70 set(LYX_HOME "out-home")
71 set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
72 set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
73 file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
74 file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
75 list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
77 file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
79 foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
80 string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
81 add_test(NAME autotests/${_t}
82 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
83 COMMAND ${CMAKE_COMMAND}
84 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
85 -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
86 -DKEYTEST_INFILE=${_tf}
87 -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
89 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
90 -DKEYTEST_OUTFILE=${_t}-out.txt
92 -DLOCALE_DIR=${LOCALE_DIR}
93 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
98 macro(getoutputformats filepath varname)
99 file(STRINGS "${filepath}" lines)
100 set(${varname} "pdf") # try at least this one
102 if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
103 if(CMAKE_MATCH_1 STREQUAL "default")
104 set(found "xhtml" "pdf" "pdf2" "pdf5")
105 elseif(CMAKE_MATCH_1 STREQUAL "xhtml")
108 set(found "xhtml" ${CMAKE_MATCH_1})
110 set(${varname} ${found})
116 foreach(libsubfolder doc examples templates)
117 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
118 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
120 # Now create 2 lists. One for files in a language dir, one without
122 set(nolang_lyx_files)
123 foreach(f ${lyx_files})
124 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
126 list(APPEND lang_lyx_files ${f})
128 list(APPEND nolang_lyx_files ${f})
131 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
133 string(REGEX REPLACE "\\.lyx$" "" f ${f})
134 add_test(NAME export/${libsubfolder}/${f}_lyx16
135 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
136 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
137 -Dlyx=$<TARGET_FILE:${_lyx}>
141 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
142 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
143 foreach(format ${formatlist})
144 add_test(NAME export/${libsubfolder}/${f}_${format}
145 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
146 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
147 -Dlyx=$<TARGET_FILE:${_lyx}>
149 -Dextension=${format}
151 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")