]> git.lyx.org Git - features.git/commitdiff
Cmake tests: Make foreach() command robust
authorKornel Benko <kornel@lyx.org>
Sun, 15 Dec 2019 12:38:23 +0000 (13:38 +0100)
committerKornel Benko <kornel@lyx.org>
Sun, 15 Dec 2019 12:59:33 +0000 (13:59 +0100)
Cmake's foreach command includes forms
  foreach(<loop_var> IN LISTS <lists>)
  foreach(<loop_var> IN ITEMS <items>)
  foreach(<loop_var> RANGE ...)
We get the lines to be parsed by
  file(STRINGS "${filepath}" lines)
If in the parsed lyx-file there is a line
containing only the single word 'IN',  or 'RANGE', then
the command
  foreach(_l ${lines})
can create a syntax error (at least with cmake1.16)

In fact, in file pl_Additional.lyx:12913 happens to have
such a beast.

development/autotests/ExportTests.cmake

index 85d0ecce2968249c42a16856a58f633830bb7883..febac166422fb1a2f0c7f504f423641e74a7878c 100644 (file)
@@ -53,7 +53,7 @@ macro(getoutputformats filepath varname format_set)
   # What should we test, if default_output_format is not defined?
   # For now we test everything ...
   set(out_formats "xhtml" ${DVI_FORMATS} ${PDF_FORMATS})
-  foreach(_l ${lines})
+  foreach(_l IN LISTS lines)
     if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
       set(_format ${CMAKE_MATCH_1})
       if(_format STREQUAL "default")