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
7 set(LYX_HOME "out-home")
8 set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
9 set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
10 file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
15 # Make sure, the needed programs are in PATH
16 find_program(PCREGREP_EXE "pcregrep")
18 list(APPEND Missing "pcregrep")
20 find_program(WMCTRL_EXE "wmctrl")
22 list(APPEND Missing "wmctrl")
24 # This is needed to build xvkbd
25 # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
28 # Check for needed libraries for xvkbd
29 # do not add autotests, if any of them is lacking
33 list(APPEND Missing "X11")
35 find_package(PkgConfig)
37 foreach(_lb "xaw7" "xmu" "xtst")
38 pkg_check_modules(${_lb}LIB ${_lb})
39 if(${_lb}LIB_LIBRARIES)
40 list(APPEND XVFBDLIBS ${${_lb}LIB_LIBRARIES})
42 list(APPEND Missing ${_lb})
46 foreach(_lb "Xaw7" "Xmu")
47 find_library(${_lb}LIB ${_lb})
49 list(APPEND XVFBDLIBS ${${_lb}LIB})
51 list(APPEND Missing ${_lb})
54 foreach(_lb Xt XTest X11)
56 list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
58 list(APPEND Missing ${_lb})
63 list(REMOVE_DUPLICATES XVFBDLIBS)
67 message(STATUS "Missing Libraries or programs to create xvkbd: ${Missing}")
68 message(STATUS "cmake build is therefore omitting keytests")
74 add_subdirectory(xvkbd)
76 set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
77 file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
78 file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
79 list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
81 file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
83 foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
84 string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
85 add_test(NAME keytest/${_t}
86 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
87 COMMAND ${CMAKE_COMMAND}
88 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
89 -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
90 -DKEYTEST_INFILE=${_tf}
91 -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
93 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
94 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
95 -DKEYTEST_OUTFILE=${_t}-out.txt
97 -DLOCALE_DIR=${LOCALE_DIR}
98 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
103 macro(getoutputformats filepath varname)
104 file(STRINGS "${filepath}" lines)
105 set(out_formats "xhtml" "pdf" "pdf2" "pdf5")
106 set(${varname} ${out_formats})
108 if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
109 if(CMAKE_MATCH_1 STREQUAL "default")
110 set(found ${out_formats})
111 elseif(CMAKE_MATCH_1 STREQUAL "xhtml")
114 set(found "xhtml" ${CMAKE_MATCH_1})
116 set(${varname} ${found})
122 macro(getreverted testname reverted listreverted)
123 list(FIND ${listreverted} ${${testname}} _idx)
128 set(${testname} "INVERTED_SEE-README.ctest_${${testname}}")
132 foreach(libsubfolder doc examples templates)
133 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
134 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
136 # Now create 2 lists. One for files in a language dir, one without
138 set(nolang_lyx_files)
139 foreach(f ${lyx_files})
140 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
142 list(APPEND lang_lyx_files ${f})
144 list(APPEND nolang_lyx_files ${f})
147 file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/revertedTests" revertedTests)
148 file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/ignoredTests" ignoredTests)
149 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
151 string(REGEX REPLACE "\\.lyx$" "" f ${f})
152 set(TestName "export/${libsubfolder}/${f}_lyx16")
153 getreverted(TestName reverted revertedTests)
154 add_test(NAME ${TestName}
155 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
156 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
157 -Dlyx=$<TARGET_FILE:${_lyx}>
158 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
159 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
163 -Dreverted=${reverted}
164 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
165 set(TestName "lyx2lyx/${libsubfolder}/${f}")
166 getreverted(TestName reverted revertedTests)
167 add_test(NAME ${TestName}
168 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
169 COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
170 -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
171 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
172 set(TestName "check_load/${libsubfolder}/${f}")
173 getreverted(TestName reverted revertedTests)
174 add_test(NAME ${TestName}
175 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
176 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
177 -Dlyx=$<TARGET_FILE:${_lyx}>
178 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
179 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
180 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
181 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
182 foreach(format ${formatlist})
183 set(TestName "export/${libsubfolder}/${f}_${format}")
184 list(FIND ignoredTests ${TestName} _idx)
186 getreverted(TestName reverted revertedTests)
187 add_test(NAME ${TestName}
188 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
189 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
190 -Dlyx=$<TARGET_FILE:${_lyx}>
191 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
193 -Dextension=${format}
195 -Dreverted=${reverted}
196 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")