Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

UseLATEX.cmake 48 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
  1. # $Id$
  2. #
  3. # CMAKE commands to actually use the LaTeX compiler
  4. # Version: 1.9.1
  5. # Author: Kenneth Moreland <kmorel@sandia.gov>
  6. #
  7. # Edited: P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
  8. #
  9. # Copyright 2004 Sandia Corporation.
  10. # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
  11. # license for use of this work by or on behalf of the
  12. # U.S. Government. Redistribution and use in source and binary forms, with
  13. # or without modification, are permitted provided that this Notice and any
  14. # statement of authorship are reproduced on all copies.
  15. #
  16. # The following MACROS are defined:
  17. #
  18. # ADD_LATEX_DOCUMENT(<tex_file>
  19. # [BIBFILES <bib_files>]
  20. # [INPUTS <input_tex_files>]
  21. # [IMAGE_DIRS] <image_directories>
  22. # [IMAGES] <image_files>
  23. # [CONFIGURE] <tex_files>
  24. # [DEPENDS] <tex_files>
  25. # [MULTIBIB_NEWCITES] <suffix_list>
  26. # [USE_INDEX] [USE_GLOSSARY] [USE_NOMENCL]
  27. # [DEFAULT_PDF] [DEFAULT_SAFEPDF]
  28. # [MANGLE_TARGET_NAMES])
  29. # Adds targets that compile <tex_file>. The latex output is placed
  30. # in LATEX_OUTPUT_PATH or CMAKE_CURRENT_BINARY_DIR if the former is
  31. # not set. The latex program is picky about where files are located,
  32. # so all input files are copied from the source directory to the
  33. # output directory. This includes the target tex file, any tex file
  34. # listed with the INPUTS option, the bibliography files listed with
  35. # the BIBFILES option, and any .cls, .bst, and .clo files found in
  36. # the current source directory. Images found in the IMAGE_DIRS
  37. # directories or listed by IMAGES are also copied to the output
  38. # directory and coverted to an appropriate format if necessary. Any
  39. # tex files also listed with the CONFIGURE option are also processed
  40. # with the CMake CONFIGURE_FILE command (with the @ONLY flag). Any
  41. # file listed in CONFIGURE but not the target tex file or listed with
  42. # INPUTS has no effect. DEPENDS can be used to specify generated files
  43. # that are needed to compile the latex target.
  44. #
  45. # The following targets are made:
  46. # dvi: Makes <name>.dvi
  47. # pdf: Makes <name>.pdf using pdflatex.
  48. # safepdf: Makes <name>.pdf using ps2pdf. If using the default
  49. # program arguments, this will ensure all fonts are
  50. # embedded and no lossy compression has been performed
  51. # on images.
  52. # ps: Makes <name>.ps
  53. # html: Makes <name>.html
  54. # auxclean: Deletes <name>.aux and other auxiliary files.
  55. # This is sometimes necessary if a LaTeX error occurs
  56. # and writes a bad aux file. Unlike the regular clean
  57. # target, it does not delete other input files, such as
  58. # converted images, to save time on the rebuild.
  59. #
  60. # The dvi target is added to the ALL. That is, it will be the target
  61. # built by default. If the DEFAULT_PDF argument is given, then the
  62. # pdf target will be the default instead of dvi.
  63. #
  64. # If the argument MANGLE_TARGET_NAMES is given, then each of the
  65. # target names above will be mangled with the <tex_file> name. This
  66. # is to make the targets unique if ADD_LATEX_DOCUMENT is called for
  67. # multiple documents. If the argument USE_INDEX is given, then
  68. # commands to build an index are made. If the argument USE_GLOSSARY
  69. # is given, then commands to build a glossary are made. If the
  70. # argument MULTIBIB_NEWCITES is given, then additional bibtex calls
  71. # are added to the build to support the extra auxiliary files created
  72. # with the \newcite command in the multibib package.
  73. #
  74. # History:
  75. #
  76. # 1.9.1 Fixed typo that caused the LATEX_SMALL_IMAGES option to fail to
  77. # activate.
  78. #
  79. # 1.9.0 Add support for the multibib package (thanks to Antonio LaTorre).
  80. #
  81. # 1.8.2 Fix corner case when an argument name was also a variable containing
  82. # the text of an argument. In this case, the CMake IF was matching
  83. # the argument text with the contents of the variable with the same
  84. # argument name.
  85. #
  86. # 1.8.1 Fix problem where ps2pdf was not getting the appropriate arguments.
  87. #
  88. # 1.8.0 Add support for synctex.
  89. #
  90. # 1.7.7 Support calling xindy when making glossaries.
  91. #
  92. # Improved make clean support.
  93. #
  94. # 1.7.6 Add support for the nomencl package (thanks to Myles English).
  95. #
  96. # 1.7.5 Fix issue with bibfiles being copied two different ways, which causes
  97. # Problems with dependencies (thanks to Edwin van Leeuwen).
  98. #
  99. # 1.7.4 Added the DEFAULT_SAFEPDF option (thanks to Raymond Wan).
  100. #
  101. # Added warnings when image directories are not found (and were
  102. # probably not given relative to the source directory).
  103. #
  104. # 1.7.3 Fix some issues with interactions between makeglossaries and bibtex
  105. # (thanks to Mark de Wever).
  106. #
  107. # 1.7.2 Use ps2pdf to convert eps to pdf to get around the problem with
  108. # ImageMagick dropping the bounding box (thanks to Lukasz Lis).
  109. #
  110. # 1.7.1 Fixed some dependency issues.
  111. #
  112. # 1.7.0 Added DEPENDS options (thanks to Theodore Papadopoulo).
  113. #
  114. # 1.6.1 Ported the makeglossaries command to CMake and embedded the port
  115. # into UseLATEX.cmake.
  116. #
  117. # 1.6.0 Allow the use of the makeglossaries command. Thanks to Oystein
  118. # S. Haaland for the patch.
  119. #
  120. # 1.5.0 Allow any type of file in the INPUTS lists, not just tex file
  121. # (suggested by Eric Noulard). As a consequence, the ability to
  122. # specify tex files without the .tex extension is removed. The removed
  123. # function is of dubious value anyway.
  124. #
  125. # When copying input files, skip over any file that exists in the
  126. # binary directory but does not exist in the source directory with the
  127. # assumption that these files were added by some other mechanism. I
  128. # find this useful when creating large documents with multiple
  129. # chapters that I want to build separately (for speed) as I work on
  130. # them. I use the same boilerplate as the starting point for all
  131. # and just copy it with different configurations. This was what the
  132. # separate ADD_LATEX_DOCUMENT method was supposed to originally be for.
  133. # Since its external use is pretty much deprecated, I removed that
  134. # documentation.
  135. #
  136. # 1.4.1 Copy .sty files along with the other class and package files.
  137. #
  138. # 1.4.0 Added a MANGLE_TARGET_NAMES option that will mangle the target names.
  139. #
  140. # Fixed problem with copying bib files that became apparent with
  141. # CMake 2.4.
  142. #
  143. # 1.3.0 Added a LATEX_OUTPUT_PATH variable that allows you or the user to
  144. # specify where the built latex documents to go. This is especially
  145. # handy if you want to do in-source builds.
  146. #
  147. # Removed the ADD_LATEX_IMAGES macro and absorbed the functionality
  148. # into ADD_LATEX_DOCUMENT. The old interface was always kind of
  149. # clunky anyway since you had to specify the image directory in both
  150. # places. It also made supporting LATEX_OUTPUT_PATH problematic.
  151. #
  152. # Added support for jpeg files.
  153. #
  154. # 1.2.0 Changed the configuration options yet again. Removed the NO_CONFIGURE
  155. # Replaced it with a CONFIGURE option that lists input files for which
  156. # configure should be run.
  157. #
  158. # The pdf target no longer depends on the dvi target. This allows you
  159. # to build latex documents that require pdflatex. Also added an option
  160. # to make the pdf target the default one.
  161. #
  162. # 1.1.1 Added the NO_CONFIGURE option. The @ character can be used when
  163. # specifying table column separators. If two or more are used, then
  164. # will incorrectly substitute them.
  165. #
  166. # 1.1.0 Added ability include multiple bib files. Added ability to do copy
  167. # sub-tex files for multipart tex files.
  168. #
  169. # 1.0.0 If both ps and pdf type images exist, just copy the one that
  170. # matches the current render mode. Replaced a bunch of STRING
  171. # commands with GET_FILENAME_COMPONENT commands that were made to do
  172. # the desired function.
  173. #
  174. # 0.4.0 First version posted to CMake Wiki.
  175. #
  176. #############################################################################
  177. # Find the location of myself while originally executing. If you do this
  178. # inside of a macro, it will recode where the macro was invoked.
  179. #############################################################################
  180. SET(LATEX_USE_LATEX_LOCATION ${CMAKE_CURRENT_LIST_FILE}
  181. CACHE INTERNAL "Location of UseLATEX.cmake file." FORCE
  182. )
  183. #############################################################################
  184. # Generic helper macros
  185. #############################################################################
  186. # Helpful list macros.
  187. MACRO(LATEX_CAR var)
  188. SET(${var} ${ARGV1})
  189. ENDMACRO(LATEX_CAR)
  190. MACRO(LATEX_CDR var junk)
  191. SET(${var} ${ARGN})
  192. ENDMACRO(LATEX_CDR)
  193. MACRO(LATEX_LIST_CONTAINS var value)
  194. SET(${var})
  195. FOREACH (value2 ${ARGN})
  196. IF ("not_a_var_${value}" STREQUAL "not_a_var_${value2}")
  197. SET(${var} TRUE)
  198. ENDIF ("not_a_var_${value}" STREQUAL "not_a_var_${value2}")
  199. ENDFOREACH (value2)
  200. ENDMACRO(LATEX_LIST_CONTAINS)
  201. # Parse macro arguments.
  202. MACRO(LATEX_PARSE_ARGUMENTS prefix arg_names option_names)
  203. SET(DEFAULT_ARGS)
  204. FOREACH(arg_name ${arg_names})
  205. SET(${prefix}_${arg_name})
  206. ENDFOREACH(arg_name)
  207. FOREACH(option ${option_names})
  208. SET(${prefix}_${option})
  209. ENDFOREACH(option)
  210. SET(current_arg_name DEFAULT_ARGS)
  211. SET(current_arg_list)
  212. FOREACH(arg ${ARGN})
  213. LATEX_LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
  214. IF (is_arg_name)
  215. SET(${prefix}_${current_arg_name} ${current_arg_list})
  216. SET(current_arg_name ${arg})
  217. SET(current_arg_list)
  218. ELSE (is_arg_name)
  219. LATEX_LIST_CONTAINS(is_option ${arg} ${option_names})
  220. IF (is_option)
  221. SET(${prefix}_${arg} TRUE)
  222. ELSE (is_option)
  223. SET(current_arg_list ${current_arg_list} ${arg})
  224. ENDIF (is_option)
  225. ENDIF (is_arg_name)
  226. ENDFOREACH(arg)
  227. SET(${prefix}_${current_arg_name} ${current_arg_list})
  228. ENDMACRO(LATEX_PARSE_ARGUMENTS)
  229. # Match the contents of a file to a regular expression.
  230. MACRO(LATEX_FILE_MATCH variable filename regexp default)
  231. # The FILE STRINGS command would be a bit better, but it's not supported on
  232. # older versions of CMake.
  233. FILE(READ ${filename} file_contents)
  234. STRING(REGEX MATCHALL "${regexp}"
  235. ${variable} ${file_contents}
  236. )
  237. IF (NOT ${variable})
  238. SET(${variable} "${default}")
  239. ENDIF (NOT ${variable})
  240. ENDMACRO(LATEX_FILE_MATCH)
  241. #############################################################################
  242. # Macros that perform processing during a LaTeX build.
  243. #############################################################################
  244. MACRO(LATEX_MAKEGLOSSARIES)
  245. # This is really a bare bones port of the makeglossaries perl script into
  246. # CMake scripting.
  247. MESSAGE("**************************** In makeglossaries")
  248. IF (NOT LATEX_TARGET)
  249. MESSAGE(SEND_ERROR "Need to define LATEX_TARGET")
  250. ENDIF (NOT LATEX_TARGET)
  251. SET(aux_file ${LATEX_TARGET}.aux)
  252. IF (NOT EXISTS ${aux_file})
  253. MESSAGE(SEND_ERROR "${aux_file} does not exist. Run latex on your target file.")
  254. ENDIF (NOT EXISTS ${aux_file})
  255. LATEX_FILE_MATCH(newglossary_lines ${aux_file}
  256. "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}"
  257. "@newglossary{main}{glg}{gls}{glo}"
  258. )
  259. LATEX_FILE_MATCH(istfile_line ${aux_file}
  260. "@istfilename[ \t]*{([^}]*)}"
  261. "@istfilename{${LATEX_TARGET}.ist}"
  262. )
  263. STRING(REGEX REPLACE "@istfilename[ \t]*{([^}]*)}" "\\1"
  264. istfile ${istfile_line}
  265. )
  266. STRING(REGEX MATCH ".*\\.xdy" use_xindy "${istfile}")
  267. IF (use_xindy)
  268. MESSAGE("*************** Using xindy")
  269. IF (NOT XINDY_COMPILER)
  270. MESSAGE(SEND_ERROR "Need to define XINDY_COMPILER")
  271. ENDIF (NOT XINDY_COMPILER)
  272. ELSE (use_xindy)
  273. MESSAGE("*************** Using makeindex")
  274. IF (NOT MAKEINDEX_COMPILER)
  275. MESSAGE(SEND_ERROR "Need to define MAKEINDEX_COMPILER")
  276. ENDIF (NOT MAKEINDEX_COMPILER)
  277. ENDIF (use_xindy)
  278. FOREACH(newglossary ${newglossary_lines})
  279. STRING(REGEX REPLACE
  280. "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}"
  281. "\\1" glossary_name ${newglossary}
  282. )
  283. STRING(REGEX REPLACE
  284. "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}"
  285. "${LATEX_TARGET}.\\2" glossary_log ${newglossary}
  286. )
  287. STRING(REGEX REPLACE
  288. "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}"
  289. "${LATEX_TARGET}.\\3" glossary_out ${newglossary}
  290. )
  291. STRING(REGEX REPLACE
  292. "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}"
  293. "${LATEX_TARGET}.\\4" glossary_in ${newglossary}
  294. )
  295. IF (use_xindy)
  296. LATEX_FILE_MATCH(xdylanguage_line ${aux_file}
  297. "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}"
  298. "@xdylanguage{${glossary_name}}{english}"
  299. )
  300. STRING(REGEX REPLACE
  301. "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}"
  302. "\\1"
  303. language
  304. ${xdylanguage_line}
  305. )
  306. # What crazy person makes a LaTeX index generater that uses different
  307. # identifiers for language than babel (or at least does not support
  308. # the old ones)?
  309. IF (${language} STREQUAL "frenchb")
  310. SET(language "french")
  311. ELSEIF (${language} MATCHES "^n?germanb?$")
  312. SET(language "german")
  313. ELSEIF (${language} STREQUAL "magyar")
  314. SET(language "hungarian")
  315. ELSEIF (${language} STREQUAL "lsorbian")
  316. SET(language "lower-sorbian")
  317. ELSEIF (${language} STREQUAL "norsk")
  318. SET(language "norwegian")
  319. ELSEIF (${language} STREQUAL "portuges")
  320. SET(language "portuguese")
  321. ELSEIF (${language} STREQUAL "russianb")
  322. SET(language "russian")
  323. ELSEIF (${language} STREQUAL "slovene")
  324. SET(language "slovenian")
  325. ELSEIF (${language} STREQUAL "ukraineb")
  326. SET(language "ukrainian")
  327. ELSEIF (${language} STREQUAL "usorbian")
  328. SET(language "upper-sorbian")
  329. ENDIF (${language} STREQUAL "frenchb")
  330. IF (language)
  331. SET(language_flags "-L ${language}")
  332. ELSE (language)
  333. SET(language_flags "")
  334. ENDIF (language)
  335. LATEX_FILE_MATCH(codepage_line ${aux_file}
  336. "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}"
  337. "@gls@codepage{${glossary_name}}{utf}"
  338. )
  339. STRING(REGEX REPLACE
  340. "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}"
  341. "\\1"
  342. codepage
  343. ${codepage_line}
  344. )
  345. IF (codepage)
  346. SET(codepage_flags "-C ${codepage}")
  347. ELSE (codepage)
  348. # Ideally, we would check that the language is compatible with the
  349. # default codepage, but I'm hoping that distributions will be smart
  350. # enough to specify their own codepage. I know, it's asking a lot.
  351. SET(codepage_flags "")
  352. ENDIF (codepage)
  353. MESSAGE("${XINDY_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} ${language_flags} ${codepage_flags} -I xindy -M ${glossary_name} -t ${glossary_log} -o ${glossary_out} ${glossary_in}"
  354. )
  355. EXEC_PROGRAM(${XINDY_COMPILER}
  356. ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS}
  357. ${language_flags}
  358. ${codepage_flags}
  359. -I xindy
  360. -M ${glossary_name}
  361. -t ${glossary_log}
  362. -o ${glossary_out}
  363. ${glossary_in}
  364. OUTPUT_VARIABLE xindy_output
  365. )
  366. MESSAGE("${xindy_output}")
  367. # So, it is possible (perhaps common?) for aux files to specify a
  368. # language and codepage that are incompatible with each other. Check
  369. # for that condition, and if it happens run again with the default
  370. # codepage.
  371. IF ("${xindy_output}" MATCHES "^Cannot locate xindy module for language (.+) in codepage (.+)\\.$")
  372. MESSAGE("*************** Retrying xindy with default codepage.")
  373. EXEC_PROGRAM(${XINDY_COMPILER}
  374. ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS}
  375. ${language_flags}
  376. -I xindy
  377. -M ${glossary_name}
  378. -t ${glossary_log}
  379. -o ${glossary_out}
  380. ${glossary_in}
  381. )
  382. ENDIF ("${xindy_output}" MATCHES "^Cannot locate xindy module for language (.+) in codepage (.+)\\.$")
  383. #ENDIF ("${xindy_output}" MATCHES "Cannot locate xindy module for language (.+) in codepage (.+)\\.")
  384. ELSE (use_xindy)
  385. MESSAGE("${MAKEINDEX_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in}")
  386. EXEC_PROGRAM(${MAKEINDEX_COMPILER} ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS}
  387. -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in}
  388. )
  389. ENDIF (use_xindy)
  390. ENDFOREACH(newglossary)
  391. ENDMACRO(LATEX_MAKEGLOSSARIES)
  392. MACRO(LATEX_MAKENOMENCLATURE)
  393. MESSAGE("**************************** In makenomenclature")
  394. IF (NOT LATEX_TARGET)
  395. MESSAGE(SEND_ERROR "Need to define LATEX_TARGET")
  396. ENDIF (NOT LATEX_TARGET)
  397. IF (NOT MAKEINDEX_COMPILER)
  398. MESSAGE(SEND_ERROR "Need to define MAKEINDEX_COMPILER")
  399. ENDIF (NOT MAKEINDEX_COMPILER)
  400. SET(nomencl_out ${LATEX_TARGET}.nls)
  401. SET(nomencl_in ${LATEX_TARGET}.nlo)
  402. EXEC_PROGRAM(${MAKEINDEX_COMPILER} ARGS ${MAKENOMENCLATURE_COMPILER_FLAGS}
  403. ${nomencl_in} -s "nomencl.ist" -o ${nomencl_out}
  404. )
  405. ENDMACRO(LATEX_MAKENOMENCLATURE)
  406. MACRO(LATEX_CORRECT_SYNCTEX)
  407. MESSAGE("**************************** In correct SyncTeX")
  408. IF (NOT LATEX_TARGET)
  409. MESSAGE(SEND_ERROR "Need to define LATEX_TARGET")
  410. ENDIF (NOT LATEX_TARGET)
  411. IF (NOT GZIP)
  412. MESSAGE(SEND_ERROR "Need to define GZIP")
  413. ENDIF (NOT GZIP)
  414. IF (NOT LATEX_SOURCE_DIRECTORY)
  415. MESSAGE(SEND_ERROR "Need to define LATEX_SOURCE_DIRECTORY")
  416. ENDIF (NOT LATEX_SOURCE_DIRECTORY)
  417. IF (NOT LATEX_BINARY_DIRECTORY)
  418. MESSAGE(SEND_ERROR "Need to define LATEX_BINARY_DIRECTORY")
  419. ENDIF (NOT LATEX_BINARY_DIRECTORY)
  420. SET(synctex_file ${LATEX_BINARY_DIRECTORY}/${LATEX_TARGET}.synctex)
  421. SET(synctex_file_gz ${synctex_file}.gz)
  422. IF (EXISTS ${synctex_file_gz})
  423. MESSAGE("Making backup of synctex file.")
  424. CONFIGURE_FILE(${synctex_file_gz} ${synctex_file}.bak.gz COPYONLY)
  425. MESSAGE("Uncompressing synctex file.")
  426. EXEC_PROGRAM(${GZIP}
  427. ARGS --decompress ${synctex_file_gz}
  428. )
  429. MESSAGE("Reading synctex file.")
  430. FILE(READ ${synctex_file} synctex_data)
  431. MESSAGE("Replacing relative with absolute paths.")
  432. STRING(REGEX REPLACE
  433. "(Input:[0-9]+:)([^/\n][^\n]*)"
  434. "\\1${LATEX_SOURCE_DIRECTORY}/\\2"
  435. synctex_data
  436. "${synctex_data}"
  437. )
  438. MESSAGE("Writing synctex file.")
  439. FILE(WRITE ${synctex_file} "${synctex_data}")
  440. MESSAGE("Compressing synctex file.")
  441. EXEC_PROGRAM(${GZIP}
  442. ARGS ${synctex_file}
  443. )
  444. ELSE (EXISTS ${synctex_file_gz})
  445. MESSAGE(SEND_ERROR "File ${synctex_file_gz} not found. Perhaps synctex is not supported by your LaTeX compiler.")
  446. ENDIF (EXISTS ${synctex_file_gz})
  447. ENDMACRO(LATEX_CORRECT_SYNCTEX)
  448. macro (LATEX_RUN_TEX_COMMAND)
  449. # Set search path for included files and run TeX command
  450. #
  451. # Example usage:
  452. # ${CMAKE_COMMAND}
  453. # -D TEX_INCLUDE_DIR=path
  454. # -D TEX_COMMAND=pdflatex file
  455. # -D WORKING_DIR=dir
  456. # -P ${LATEX_USE_LATEX_LOCATION}
  457. if (NOT TEX_INCLUDE_DIR OR NOT TEX_COMMAND OR NOT WORKING_DIR)
  458. message (FATAL_ERROR "Must define TEX_INCLUDE_DIR, TEX_COMMAND, and WORKING_DIR.")
  459. endif ()
  460. # Create native path from tex_include_dir.
  461. file (TO_NATIVE_PATH ${TEX_INCLUDE_DIR} _texinputs)
  462. # The '.' is there to ensure that the current directory is searched first; the
  463. # trailing ':' says 'patch in the value of TEXINPUTS from your configuration
  464. # file, here'.
  465. if (WIN32)
  466. set (_texinputs ".;${_texinputs};")
  467. else (WIN32) # on UNIX
  468. string (REPLACE ";" ":" _texinputs ".;${_texinputs};")
  469. endif (WIN32)
  470. # Set TEXINPUTS environment.
  471. set (ENV{TEXINPUTS} "${_texinputs}")
  472. # Create command/args list.
  473. string (REPLACE " " ";" TEX_COMMAND ${TEX_COMMAND})
  474. # Execute TeX command
  475. execute_process(COMMAND ${TEX_COMMAND}
  476. WORKING_DIRECTORY ${WORKING_DIR})
  477. endmacro (LATEX_RUN_TEX_COMMAND)
  478. #############################################################################
  479. # Helper macros for establishing LaTeX build.
  480. #############################################################################
  481. MACRO(LATEX_NEEDIT VAR NAME)
  482. IF (NOT ${VAR})
  483. MESSAGE(SEND_ERROR "I need the ${NAME} command.")
  484. ENDIF(NOT ${VAR})
  485. ENDMACRO(LATEX_NEEDIT)
  486. MACRO(LATEX_WANTIT VAR NAME)
  487. IF (NOT ${VAR})
  488. MESSAGE(STATUS "I could not find the ${NAME} command.")
  489. ENDIF(NOT ${VAR})
  490. ENDMACRO(LATEX_WANTIT)
  491. MACRO(LATEX_SETUP_VARIABLES)
  492. SET(LATEX_OUTPUT_PATH "${LATEX_OUTPUT_PATH}"
  493. CACHE PATH "If non empty, specifies the location to place LaTeX output."
  494. )
  495. FIND_PACKAGE(LATEX)
  496. #FIND_PROGRAM(XINDY_COMPILER
  497. # NAME xindy
  498. # PATHS ${MIKTEX_BINARY_PATH} /usr/bin
  499. # )
  500. FIND_PACKAGE(UnixCommands)
  501. MARK_AS_ADVANCED(CLEAR
  502. LATEX_COMPILER
  503. PDFLATEX_COMPILER
  504. BIBTEX_COMPILER
  505. MAKEINDEX_COMPILER
  506. XINDY_COMPILER
  507. DVIPS_CONVERTER
  508. PS2PDF_CONVERTER
  509. LATEX2HTML_CONVERTER
  510. )
  511. #LATEX_NEEDIT(LATEX_COMPILER latex)
  512. LATEX_WANTIT(PDFLATEX_COMPILER pdflatex)
  513. LATEX_NEEDIT(BIBTEX_COMPILER bibtex)
  514. LATEX_NEEDIT(MAKEINDEX_COMPILER makeindex)
  515. #LATEX_WANTIT(DVIPS_CONVERTER dvips)
  516. #LATEX_WANTIT(PS2PDF_CONVERTER ps2pdf)
  517. #LATEX_WANTIT(LATEX2HTML_CONVERTER latex2html)
  518. SET(LATEX_COMPILER_FLAGS "-interaction=nonstopmode"
  519. CACHE STRING "Flags passed to latex.")
  520. SET(PDFLATEX_COMPILER_FLAGS ${LATEX_COMPILER_FLAGS}
  521. CACHE STRING "Flags passed to pdflatex.")
  522. SET(LATEX_SYNCTEX_FLAGS "-synctex=1"
  523. CACHE STRING "latex/pdflatex flags used to create synctex file.")
  524. SET(BIBTEX_COMPILER_FLAGS ""
  525. CACHE STRING "Flags passed to bibtex.")
  526. SET(MAKEINDEX_COMPILER_FLAGS ""
  527. CACHE STRING "Flags passed to makeindex.")
  528. SET(MAKEGLOSSARIES_COMPILER_FLAGS ""
  529. CACHE STRING "Flags passed to makeglossaries.")
  530. SET(MAKENOMENCLATURE_COMPILER_FLAGS ""
  531. CACHE STRING "Flags passed to makenomenclature.")
  532. SET(DVIPS_CONVERTER_FLAGS "-Ppdf -G0 -t letter"
  533. CACHE STRING "Flags passed to dvips.")
  534. SET(PS2PDF_CONVERTER_FLAGS "-dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode"
  535. CACHE STRING "Flags passed to ps2pdf.")
  536. SET(LATEX2HTML_CONVERTER_FLAGS ""
  537. CACHE STRING "Flags passed to latex2html.")
  538. MARK_AS_ADVANCED(
  539. LATEX_COMPILER_FLAGS
  540. PDFLATEX_COMPILER_FLAGS
  541. LATEX_SYNCTEX_FLAGS
  542. BIBTEX_COMPILER_FLAGS
  543. MAKEINDEX_COMPILER_FLAGS
  544. MAKEGLOSSARIES_COMPILER_FLAGS
  545. MAKENOMENCLATURE_COMPILER_FLAGS
  546. DVIPS_CONVERTER_FLAGS
  547. PS2PDF_CONVERTER_FLAGS
  548. LATEX2HTML_CONVERTER_FLAGS
  549. )
  550. SEPARATE_ARGUMENTS(LATEX_COMPILER_FLAGS)
  551. SEPARATE_ARGUMENTS(PDFLATEX_COMPILER_FLAGS)
  552. SEPARATE_ARGUMENTS(LATEX_SYNCTEX_FLAGS)
  553. SEPARATE_ARGUMENTS(BIBTEX_COMPILER_FLAGS)
  554. SEPARATE_ARGUMENTS(MAKEINDEX_COMPILER_FLAGS)
  555. SEPARATE_ARGUMENTS(MAKEGLOSSARIES_COMPILER_FLAGS)
  556. SEPARATE_ARGUMENTS(MAKENOMENCLATURE_COMPILER_FLAGS)
  557. SEPARATE_ARGUMENTS(DVIPS_CONVERTER_FLAGS)
  558. SEPARATE_ARGUMENTS(PS2PDF_CONVERTER_FLAGS)
  559. SEPARATE_ARGUMENTS(LATEX2HTML_CONVERTER_FLAGS)
  560. #FIND_PROGRAM(IMAGEMAGICK_CONVERT convert
  561. # DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)."
  562. # )
  563. #IF (NOT IMAGEMAGICK_CONVERT)
  564. # MESSAGE(SEND_ERROR "Could not find convert program. Please download ImageMagick from http://www.imagemagick.org and install.")
  565. #ENDIF (NOT IMAGEMAGICK_CONVERT)
  566. OPTION(LATEX_USE_SYNCTEX
  567. "If on, have LaTeX generate a synctex file, which WYSIWYG editors can use to correlate output files like dvi and pdf with the lines of LaTeX source that generates them. In addition to adding the LATEX_SYNCTEX_FLAGS to the command line, this option also adds build commands that \"corrects\" the resulting synctex file to point to the original LaTeX files rather than those generated by UseLATEX.cmake."
  568. OFF
  569. )
  570. OPTION(LATEX_SMALL_IMAGES
  571. "If on, the raster images will be converted to 1/6 the original size. This is because papers usually require 600 dpi images whereas most monitors only require at most 96 dpi. Thus, smaller images make smaller files for web distributation and can make it faster to read dvi files."
  572. OFF)
  573. IF (LATEX_SMALL_IMAGES)
  574. SET(LATEX_RASTER_SCALE 16)
  575. SET(LATEX_OPPOSITE_RASTER_SCALE 100)
  576. ELSE (LATEX_SMALL_IMAGES)
  577. SET(LATEX_RASTER_SCALE 100)
  578. SET(LATEX_OPPOSITE_RASTER_SCALE 16)
  579. ENDIF (LATEX_SMALL_IMAGES)
  580. # Just holds extensions for known image types. They should all be lower case.
  581. SET(LATEX_DVI_VECTOR_IMAGE_EXTENSIONS .eps)
  582. SET(LATEX_DVI_RASTER_IMAGE_EXTENSIONS)
  583. SET(LATEX_DVI_IMAGE_EXTENSIONS
  584. ${LATEX_DVI_VECTOR_IMAGE_EXTENSIONS} ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS})
  585. SET(LATEX_PDF_VECTOR_IMAGE_EXTENSIONS .pdf)
  586. SET(LATEX_PDF_RASTER_IMAGE_EXTENSIONS .png .jpeg .jpg)
  587. SET(LATEX_PDF_IMAGE_EXTENSIONS
  588. ${LATEX_PDF_VECTOR_IMAGE_EXTENSIONS} ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS})
  589. SET(LATEX_IMAGE_EXTENSIONS
  590. ${LATEX_DVI_IMAGE_EXTENSIONS} ${LATEX_PDF_IMAGE_EXTENSIONS})
  591. ENDMACRO(LATEX_SETUP_VARIABLES)
  592. MACRO(LATEX_GET_OUTPUT_PATH var)
  593. SET(${var})
  594. IF (LATEX_OUTPUT_PATH)
  595. IF ("${LATEX_OUTPUT_PATH}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  596. MESSAGE(SEND_ERROR "You cannot set LATEX_OUTPUT_PATH to the same directory that contains LaTeX input files.")
  597. ELSE ("${LATEX_OUTPUT_PATH}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  598. SET(${var} "${LATEX_OUTPUT_PATH}")
  599. ENDIF ("${LATEX_OUTPUT_PATH}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  600. ELSE (LATEX_OUTPUT_PATH)
  601. IF ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  602. MESSAGE(SEND_ERROR "LaTeX files must be built out of source or you must set LATEX_OUTPUT_PATH.")
  603. ELSE ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  604. SET(${var} "${CMAKE_CURRENT_BINARY_DIR}")
  605. ENDIF ("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  606. ENDIF (LATEX_OUTPUT_PATH)
  607. ENDMACRO(LATEX_GET_OUTPUT_PATH)
  608. MACRO(LATEX_ADD_CONVERT_COMMAND output_path input_path output_extension
  609. input_extension flags)
  610. SET (converter ${IMAGEMAGICK_CONVERT})
  611. SET (convert_flags "")
  612. # ImageMagick has broken eps to pdf conversion
  613. # use ps2pdf instead
  614. IF (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf")
  615. IF (PS2PDF_CONVERTER)
  616. SET (converter ${PS2PDF_CONVERTER})
  617. SET (convert_flags -dEPSCrop ${PS2PDF_CONVERTER_FLAGS})
  618. ELSE (PS2PDF_CONVERTER)
  619. MESSAGE(SEND_ERROR "Using postscript files with pdflatex requires ps2pdf for conversion.")
  620. ENDIF (PS2PDF_CONVERTER)
  621. ELSE (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf")
  622. SET (convert_flags ${flags})
  623. ENDIF (${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf")
  624. ADD_CUSTOM_COMMAND(OUTPUT ${output_path}
  625. COMMAND ${converter}
  626. ARGS ${convert_flags} ${input_path} ${output_path}
  627. DEPENDS ${input_path}
  628. )
  629. ENDMACRO(LATEX_ADD_CONVERT_COMMAND)
  630. # Makes custom commands to convert a file to a particular type.
  631. MACRO(LATEX_CONVERT_IMAGE output_files input_file output_extension convert_flags
  632. output_extensions other_files)
  633. SET(input_dir ${CMAKE_CURRENT_SOURCE_DIR})
  634. LATEX_GET_OUTPUT_PATH(output_dir)
  635. GET_FILENAME_COMPONENT(extension "${input_file}" EXT)
  636. STRING(REGEX REPLACE "\\.[^.]*\$" ${output_extension} output_file
  637. "${input_file}")
  638. LATEX_LIST_CONTAINS(is_type ${extension} ${output_extensions})
  639. IF (is_type)
  640. IF (convert_flags)
  641. LATEX_ADD_CONVERT_COMMAND(${output_dir}/${output_file}
  642. ${input_dir}/${input_file} ${output_extension} ${extension}
  643. "${convert_flags}")
  644. SET(${output_files} ${${output_files}} ${output_dir}/${output_file})
  645. ELSE (convert_flags)
  646. # As a shortcut, we can just copy the file.
  647. ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${input_file}
  648. COMMAND ${CMAKE_COMMAND}
  649. ARGS -E copy ${input_dir}/${input_file} ${output_dir}/${input_file}
  650. DEPENDS ${input_dir}/${input_file}
  651. )
  652. SET(${output_files} ${${output_files}} ${output_dir}/${input_file})
  653. ENDIF (convert_flags)
  654. ELSE (is_type)
  655. SET(do_convert TRUE)
  656. # Check to see if there is another input file of the appropriate type.
  657. FOREACH(valid_extension ${output_extensions})
  658. STRING(REGEX REPLACE "\\.[^.]*\$" ${output_extension} try_file
  659. "${input_file}")
  660. LATEX_LIST_CONTAINS(has_native_file "${try_file}" ${other_files})
  661. IF (has_native_file)
  662. SET(do_convert FALSE)
  663. ENDIF (has_native_file)
  664. ENDFOREACH(valid_extension)
  665. # If we still need to convert, do it.
  666. IF (do_convert)
  667. LATEX_ADD_CONVERT_COMMAND(${output_dir}/${output_file}
  668. ${input_dir}/${input_file} ${output_extension} ${extension}
  669. "${convert_flags}")
  670. SET(${output_files} ${${output_files}} ${output_dir}/${output_file})
  671. ENDIF (do_convert)
  672. ENDIF (is_type)
  673. ENDMACRO(LATEX_CONVERT_IMAGE)
  674. # Adds custom commands to process the given files for dvi and pdf builds.
  675. # Adds the output files to the given variables (does not replace).
  676. MACRO(LATEX_PROCESS_IMAGES dvi_outputs pdf_outputs)
  677. LATEX_GET_OUTPUT_PATH(output_dir)
  678. FOREACH(file ${ARGN})
  679. IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
  680. GET_FILENAME_COMPONENT(extension "${file}" EXT)
  681. SET(convert_flags)
  682. # Check to see if we need to downsample the image.
  683. LATEX_LIST_CONTAINS(is_raster "${extension}"
  684. ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS}
  685. ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS})
  686. IF (LATEX_SMALL_IMAGES)
  687. IF (is_raster)
  688. SET(convert_flags -resize ${LATEX_RASTER_SCALE}%)
  689. ENDIF (is_raster)
  690. ENDIF (LATEX_SMALL_IMAGES)
  691. # Make sure the output directory exists.
  692. GET_FILENAME_COMPONENT(path "${output_dir}/${file}" PATH)
  693. MAKE_DIRECTORY("${path}")
  694. # Do conversions for dvi.
  695. LATEX_CONVERT_IMAGE(${dvi_outputs} "${file}" .eps "${convert_flags}"
  696. "${LATEX_DVI_IMAGE_EXTENSIONS}" "${ARGN}")
  697. # Do conversions for pdf.
  698. IF (is_raster)
  699. LATEX_CONVERT_IMAGE(${pdf_outputs} "${file}" .png "${convert_flags}"
  700. "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}")
  701. ELSE (is_raster)
  702. LATEX_CONVERT_IMAGE(${pdf_outputs} "${file}" .pdf "${convert_flags}"
  703. "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}")
  704. ENDIF (is_raster)
  705. ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
  706. MESSAGE(WARNING "Could not find file ${CMAKE_CURRENT_SOURCE_DIR}/${file}. Are you sure you gave relative paths to IMAGES?")
  707. ENDIF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
  708. ENDFOREACH(file)
  709. ENDMACRO(LATEX_PROCESS_IMAGES)
  710. MACRO(ADD_LATEX_IMAGES)
  711. MESSAGE("The ADD_LATEX_IMAGES macro is deprecated. Image directories are specified with LATEX_ADD_DOCUMENT.")
  712. ENDMACRO(ADD_LATEX_IMAGES)
  713. MACRO(LATEX_COPY_INPUT_FILE file)
  714. LATEX_GET_OUTPUT_PATH(output_dir)
  715. IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file})
  716. GET_FILENAME_COMPONENT(path ${file} PATH)
  717. FILE(MAKE_DIRECTORY ${output_dir}/${path})
  718. LATEX_LIST_CONTAINS(use_config ${file} ${LATEX_CONFIGURE})
  719. IF (use_config)
  720. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}
  721. ${output_dir}/${file}
  722. @ONLY
  723. )
  724. ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${file}
  725. COMMAND ${CMAKE_COMMAND}
  726. ARGS ${CMAKE_BINARY_DIR}
  727. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
  728. )
  729. ENDIF (use_config)
  730. ELSE (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file})
  731. IF (EXISTS ${output_dir}/${file})
  732. # Special case: output exists but input does not. Assume that it was
  733. # created elsewhere and skip the input file copy.
  734. ELSE (EXISTS ${output_dir}/${file})
  735. MESSAGE("Could not find input file ${CMAKE_CURRENT_SOURCE_DIR}/${file}")
  736. ENDIF (EXISTS ${output_dir}/${file})
  737. ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file})
  738. ENDMACRO(LATEX_COPY_INPUT_FILE)
  739. #############################################################################
  740. # Commands provided by the UseLATEX.cmake "package"
  741. #############################################################################
  742. MACRO(LATEX_USAGE command message)
  743. MESSAGE(SEND_ERROR
  744. "${message}\nUsage: ${command}(<tex_file>\n [BIBFILES <bib_file> <bib_file> ...]\n [INPUTS <tex_file> <tex_file> ...]\n [IMAGE_DIRS <directory1> <directory2> ...]\n [IMAGES <image_file1> <image_file2>\n [CONFIGURE <tex_file> <tex_file> ...]\n [DEPENDS <tex_file> <tex_file> ...]\n [MULTIBIB_NEWCITES] <suffix_list>\n [USE_INDEX] [USE_GLOSSARY] [USE_NOMENCL]\n [DEFAULT_PDF] [DEFAULT_SAFEPDF]\n [MANGLE_TARGET_NAMES])"
  745. )
  746. ENDMACRO(LATEX_USAGE command message)
  747. # Parses arguments to ADD_LATEX_DOCUMENT and ADD_LATEX_TARGETS and sets the
  748. # variables LATEX_TARGET, LATEX_IMAGE_DIR, LATEX_BIBFILES, LATEX_DEPENDS, and
  749. # LATEX_INPUTS.
  750. MACRO(PARSE_ADD_LATEX_ARGUMENTS command)
  751. LATEX_PARSE_ARGUMENTS(
  752. LATEX
  753. "BIBFILES;MULTIBIB_NEWCITES;INPUTS;IMAGE_DIRS;IMAGES;CONFIGURE;DEPENDS"
  754. "USE_INDEX;USE_GLOSSARY;USE_GLOSSARIES;USE_NOMENCL;DEFAULT_PDF;DEFAULT_SAFEPDF;MANGLE_TARGET_NAMES"
  755. ${ARGN}
  756. )
  757. # The first argument is the target latex file.
  758. IF (LATEX_DEFAULT_ARGS)
  759. LATEX_CAR(LATEX_MAIN_INPUT ${LATEX_DEFAULT_ARGS})
  760. LATEX_CDR(LATEX_DEFAULT_ARGS ${LATEX_DEFAULT_ARGS})
  761. GET_FILENAME_COMPONENT(LATEX_TARGET ${LATEX_MAIN_INPUT} NAME_WE)
  762. ELSE (LATEX_DEFAULT_ARGS)
  763. LATEX_USAGE(${command} "No tex file target given to ${command}.")
  764. ENDIF (LATEX_DEFAULT_ARGS)
  765. IF (LATEX_DEFAULT_ARGS)
  766. LATEX_USAGE(${command} "Invalid or depricated arguments: ${LATEX_DEFAULT_ARGS}")
  767. ENDIF (LATEX_DEFAULT_ARGS)
  768. # Backward compatibility between 1.6.0 and 1.6.1.
  769. IF (LATEX_USE_GLOSSARIES)
  770. SET(LATEX_USE_GLOSSARY TRUE)
  771. ENDIF (LATEX_USE_GLOSSARIES)
  772. ENDMACRO(PARSE_ADD_LATEX_ARGUMENTS)
  773. MACRO(ADD_LATEX_TARGETS)
  774. LATEX_GET_OUTPUT_PATH(output_dir)
  775. PARSE_ADD_LATEX_ARGUMENTS(ADD_LATEX_TARGETS ${ARGV})
  776. IF (LATEX_USE_SYNCTEX)
  777. SET(synctex_flags ${LATEX_SYNCTEX_FLAGS})
  778. ELSE (LATEX_USE_SYNCTEX)
  779. SET(synctex_flags)
  780. ENDIF (LATEX_USE_SYNCTEX)
  781. # The commands to run LaTeX. They are repeated multiple times.
  782. SET(latex_build_command
  783. ${LATEX_COMPILER} ${LATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT}
  784. )
  785. SET(pdflatex_build_command
  786. ${PDFLATEX_COMPILER} ${PDFLATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT}
  787. )
  788. # Set up target names.
  789. IF (LATEX_MANGLE_TARGET_NAMES)
  790. SET(dvi_target ${LATEX_TARGET}_dvi)
  791. SET(pdf_target ${LATEX_TARGET}_pdf)
  792. SET(ps_target ${LATEX_TARGET}_ps)
  793. SET(safepdf_target ${LATEX_TARGET}_safepdf)
  794. SET(html_target ${LATEX_TARGET}_html)
  795. SET(auxclean_target ${LATEX_TARGET}_auxclean)
  796. ELSE (LATEX_MANGLE_TARGET_NAMES)
  797. SET(dvi_target dvi)
  798. SET(pdf_target pdf)
  799. SET(ps_target ps)
  800. SET(safepdf_target safepdf)
  801. SET(html_target html)
  802. SET(auxclean_target auxclean)
  803. ENDIF (LATEX_MANGLE_TARGET_NAMES)
  804. # Probably not all of these will be generated, but they could be.
  805. # Note that the aux file is added later.
  806. SET(auxiliary_clean_files
  807. ${output_dir}/${LATEX_TARGET}.bbl
  808. ${output_dir}/${LATEX_TARGET}.blg
  809. ${output_dir}/${LATEX_TARGET}-blx.bib
  810. ${output_dir}/${LATEX_TARGET}.glg
  811. ${output_dir}/${LATEX_TARGET}.glo
  812. ${output_dir}/${LATEX_TARGET}.gls
  813. ${output_dir}/${LATEX_TARGET}.idx
  814. ${output_dir}/${LATEX_TARGET}.ilg
  815. ${output_dir}/${LATEX_TARGET}.ind
  816. ${output_dir}/${LATEX_TARGET}.ist
  817. ${output_dir}/${LATEX_TARGET}.log
  818. ${output_dir}/${LATEX_TARGET}.out
  819. ${output_dir}/${LATEX_TARGET}.toc
  820. ${output_dir}/${LATEX_TARGET}.lof
  821. ${output_dir}/${LATEX_TARGET}.xdy
  822. ${output_dir}/${LATEX_TARGET}.synctex.gz
  823. ${output_dir}/${LATEX_TARGET}.synctex.bak.gz
  824. ${output_dir}/${LATEX_TARGET}.dvi
  825. ${output_dir}/${LATEX_TARGET}.ps
  826. ${output_dir}/${LATEX_TARGET}.pdf
  827. )
  828. # For each directory in LATEX_IMAGE_DIRS, glob all the image files and
  829. # place them in LATEX_IMAGES.
  830. FOREACH(dir ${LATEX_IMAGE_DIRS})
  831. FOREACH(extension ${LATEX_IMAGE_EXTENSIONS})
  832. IF (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  833. MESSAGE(WARNING "Image directory ${CMAKE_CURRENT_SOURCE_DIR}/${dir} does not exist. Are you sure you gave relative directories to IMAGE_DIRS?")
  834. ENDIF (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  835. FILE(GLOB files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*${extension})
  836. FOREACH(file ${files})
  837. GET_FILENAME_COMPONENT(filename ${file} NAME)
  838. SET(LATEX_IMAGES ${LATEX_IMAGES} ${dir}/${filename})
  839. ENDFOREACH(file)
  840. ENDFOREACH(extension)
  841. ENDFOREACH(dir)
  842. SET(dvi_images)
  843. SET(pdf_images)
  844. LATEX_PROCESS_IMAGES(dvi_images pdf_images ${LATEX_IMAGES})
  845. SET(make_dvi_command
  846. ${CMAKE_COMMAND} -E chdir ${output_dir}
  847. ${latex_build_command})
  848. SET(make_pdf_command
  849. ${CMAKE_COMMAND}
  850. -D LATEX_BUILD_COMMAND=run_tex_command
  851. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  852. -D TEX_COMMAND="${pdflatex_build_command}"
  853. -D WORKING_DIR=${output_dir}
  854. -P ${LATEX_USE_LATEX_LOCATION}
  855. )
  856. SET(make_dvi_depends ${LATEX_DEPENDS} ${dvi_images})
  857. SET(make_pdf_depends ${LATEX_DEPENDS} ${pdf_images})
  858. FOREACH(input ${LATEX_MAIN_INPUT} ${LATEX_INPUTS})
  859. SET(make_dvi_depends ${make_dvi_depends} ${output_dir}/${input})
  860. SET(make_pdf_depends ${make_pdf_depends} ${input})
  861. IF (${input} MATCHES "\\.tex$")
  862. STRING(REGEX REPLACE "\\.tex$" "" input_we ${input})
  863. SET(auxiliary_clean_files ${auxiliary_clean_files}
  864. ${output_dir}/${input_we}.aux
  865. ${output_dir}/${input}.aux
  866. )
  867. ENDIF (${input} MATCHES "\\.tex$")
  868. ENDFOREACH(input)
  869. IF (LATEX_USE_GLOSSARY)
  870. FOREACH(dummy 0 1) # Repeat these commands twice.
  871. SET(make_dvi_command ${make_dvi_command}
  872. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  873. ${CMAKE_COMMAND}
  874. -D LATEX_BUILD_COMMAND=makeglossaries
  875. -D LATEX_TARGET=${LATEX_TARGET}
  876. -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER}
  877. -D XINDY_COMPILER=${XINDY_COMPILER}
  878. -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS}
  879. -P ${LATEX_USE_LATEX_LOCATION}
  880. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  881. ${latex_build_command}
  882. )
  883. SET(make_pdf_command ${make_pdf_command}
  884. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  885. ${CMAKE_COMMAND}
  886. -D LATEX_BUILD_COMMAND=makeglossaries
  887. -D LATEX_TARGET=${LATEX_TARGET}
  888. -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER}
  889. -D XINDY_COMPILER=${XINDY_COMPILER}
  890. -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS}
  891. -P ${LATEX_USE_LATEX_LOCATION}
  892. COMMAND ${CMAKE_COMMAND}
  893. -D LATEX_BUILD_COMMAND=run_tex_command
  894. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  895. -D TEX_COMMAND="${pdflatex_build_command}"
  896. -D WORKING_DIR=${output_dir}
  897. -P ${LATEX_USE_LATEX_LOCATION}
  898. )
  899. ENDFOREACH(dummy)
  900. ENDIF (LATEX_USE_GLOSSARY)
  901. IF (LATEX_USE_NOMENCL)
  902. FOREACH(dummy 0 1) # Repeat these commands twice.
  903. SET(make_dvi_command ${make_dvi_command}
  904. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  905. ${CMAKE_COMMAND}
  906. -D LATEX_BUILD_COMMAND=makenomenclature
  907. -D LATEX_TARGET=${LATEX_TARGET}
  908. -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER}
  909. -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS}
  910. -P ${LATEX_USE_LATEX_LOCATION}
  911. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  912. ${latex_build_command}
  913. )
  914. SET(make_pdf_command ${make_pdf_command}
  915. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  916. ${CMAKE_COMMAND}
  917. -D LATEX_BUILD_COMMAND=makenomenclature
  918. -D LATEX_TARGET=${LATEX_TARGET}
  919. -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER}
  920. -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS}
  921. -P ${LATEX_USE_LATEX_LOCATION}
  922. COMMAND ${CMAKE_COMMAND}
  923. -D LATEX_BUILD_COMMAND=run_tex_command
  924. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  925. -D TEX_COMMAND="${pdflatex_build_command}"
  926. -D WORKING_DIR=${output_dir}
  927. -P ${LATEX_USE_LATEX_LOCATION}
  928. )
  929. ENDFOREACH(dummy)
  930. ENDIF (LATEX_USE_NOMENCL)
  931. IF (LATEX_BIBFILES)
  932. IF (LATEX_MULTIBIB_NEWCITES)
  933. FOREACH (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES})
  934. GET_FILENAME_COMPONENT(multibib_target ${multibib_auxfile} NAME_WE)
  935. SET(make_dvi_command ${make_dvi_command}
  936. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  937. ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${multibib_target})
  938. SET(make_pdf_command ${make_pdf_command}
  939. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  940. ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${multibib_target})
  941. SET(auxiliary_clean_files ${auxiliary_clean_files}
  942. ${output_dir}/${multibib_target}.aux)
  943. ENDFOREACH (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES})
  944. ELSE (LATEX_MULTIBIB_NEWCITES)
  945. SET(make_dvi_command ${make_dvi_command}
  946. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  947. ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${LATEX_TARGET})
  948. SET(make_pdf_command ${make_pdf_command}
  949. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  950. ${BIBTEX_COMPILER} ${BIBTEX_COMPILER_FLAGS} ${LATEX_TARGET})
  951. ENDIF (LATEX_MULTIBIB_NEWCITES)
  952. FOREACH (bibfile ${LATEX_BIBFILES})
  953. SET(make_dvi_depends ${make_dvi_depends} ${output_dir}/${bibfile})
  954. SET(make_pdf_depends ${make_pdf_depends} ${bibfile})
  955. ENDFOREACH (bibfile ${LATEX_BIBFILES})
  956. ELSE (LATEX_BIBFILES)
  957. IF (LATEX_MULTIBIB_NEWCITES)
  958. MESSAGE(WARNING "MULTIBIB_NEWCITES has no effect without BIBFILES option.")
  959. ENDIF (LATEX_MULTIBIB_NEWCITES)
  960. ENDIF (LATEX_BIBFILES)
  961. IF (LATEX_USE_INDEX)
  962. SET(make_dvi_command ${make_dvi_command}
  963. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  964. ${latex_build_command}
  965. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  966. ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${LATEX_TARGET}.idx)
  967. SET(make_pdf_command ${make_pdf_command}
  968. COMMAND ${CMAKE_COMMAND}
  969. -D LATEX_BUILD_COMMAND=run_tex_command
  970. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  971. -D TEX_COMMAND="${pdflatex_build_command}"
  972. -D WORKING_DIR=${output_dir}
  973. -P ${LATEX_USE_LATEX_LOCATION}
  974. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  975. ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${LATEX_TARGET}.idx)
  976. ENDIF (LATEX_USE_INDEX)
  977. SET(make_dvi_command ${make_dvi_command}
  978. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  979. ${latex_build_command}
  980. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  981. ${latex_build_command})
  982. SET(make_pdf_command ${make_pdf_command}
  983. COMMAND ${CMAKE_COMMAND}
  984. -D LATEX_BUILD_COMMAND=run_tex_command
  985. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  986. -D TEX_COMMAND="${pdflatex_build_command}"
  987. -D WORKING_DIR=${output_dir}
  988. -P ${LATEX_USE_LATEX_LOCATION}
  989. COMMAND ${CMAKE_COMMAND}
  990. -D LATEX_BUILD_COMMAND=run_tex_command
  991. -D TEX_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
  992. -D TEX_COMMAND="${pdflatex_build_command}"
  993. -D WORKING_DIR=${output_dir}
  994. -P ${LATEX_USE_LATEX_LOCATION})
  995. IF (LATEX_USE_SYNCTEX)
  996. IF (NOT GZIP)
  997. MESSAGE(SEND_ERROR "UseLATEX.cmake: USE_SYNTEX option requires gzip program. Set GZIP variable.")
  998. ENDIF (NOT GZIP)
  999. SET(make_dvi_command ${make_dvi_command}
  1000. COMMAND ${CMAKE_COMMAND}
  1001. -D LATEX_BUILD_COMMAND=correct_synctex
  1002. -D LATEX_TARGET=${LATEX_TARGET}
  1003. -D GZIP=${GZIP}
  1004. -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}"
  1005. -D "LATEX_BINARY_DIRECTORY=${output_dir}"
  1006. -P ${LATEX_USE_LATEX_LOCATION}
  1007. )
  1008. SET(make_pdf_command ${make_pdf_command}
  1009. COMMAND ${CMAKE_COMMAND}
  1010. -D LATEX_BUILD_COMMAND=correct_synctex
  1011. -D LATEX_TARGET=${LATEX_TARGET}
  1012. -D GZIP=${GZIP}
  1013. -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}"
  1014. -D "LATEX_BINARY_DIRECTORY=${output_dir}"
  1015. -P ${LATEX_USE_LATEX_LOCATION}
  1016. )
  1017. ENDIF (LATEX_USE_SYNCTEX)
  1018. # Add commands and targets for building dvi outputs.
  1019. ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.dvi
  1020. COMMAND ${make_dvi_command}
  1021. DEPENDS ${make_dvi_depends}
  1022. )
  1023. IF (LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF)
  1024. ADD_CUSTOM_TARGET(${dvi_target}
  1025. DEPENDS ${output_dir}/${LATEX_TARGET}.dvi)
  1026. ELSE (LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF)
  1027. ADD_CUSTOM_TARGET(${dvi_target}
  1028. DEPENDS ${output_dir}/${LATEX_TARGET}.dvi)
  1029. ENDIF (LATEX_DEFAULT_PDF OR LATEX_DEFAULT_SAFEPDF)
  1030. # Add commands and targets for building pdf outputs (with pdflatex).
  1031. IF (PDFLATEX_COMPILER)
  1032. ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.pdf
  1033. COMMAND ${make_pdf_command}
  1034. DEPENDS ${make_pdf_depends}
  1035. )
  1036. IF (LATEX_DEFAULT_PDF)
  1037. ADD_CUSTOM_TARGET(${pdf_target}
  1038. DEPENDS ${output_dir}/${LATEX_TARGET}.pdf)
  1039. ELSE (LATEX_DEFAULT_PDF)
  1040. ADD_CUSTOM_TARGET(${pdf_target}
  1041. DEPENDS ${output_dir}/${LATEX_TARGET}.pdf)
  1042. ENDIF (LATEX_DEFAULT_PDF)
  1043. ENDIF (PDFLATEX_COMPILER)
  1044. IF (DVIPS_CONVERTER)
  1045. ADD_CUSTOM_COMMAND(OUTPUT ${output_dir}/${LATEX_TARGET}.ps
  1046. COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir}
  1047. ${DVIPS_CONVERTER} ${DVIPS_CONVERTER_FLAGS} -o ${LATEX_TARGET}.ps ${LATEX_TARGET}.dvi
  1048. DEPENDS ${output_dir}/${LATEX_TARGET}.dvi)
  1049. ADD_CUSTOM_TARGET(${ps_target}
  1050. DEPENDS ${output_dir}/${LATEX_TARGET}.ps)
  1051. IF (PS2PDF_CONVERTER)
  1052. # Since both the pdf and safepdf targets have the same output, we
  1053. # cannot properly do the dependencies for both. When selecting safepdf,
  1054. # simply force a recompile every time.
  1055. IF (LATEX_DEFAULT_SAFEPDF)
  1056. ADD_CUSTOM_TARGET(${safepdf_target}
  1057. ${CMAKE_COMMAND} -E chdir ${output_dir}
  1058. ${PS2PDF_CONVERTER} ${PS2PDF_CONVERTER_FLAGS} ${LATEX_TARGET}.ps ${LATEX_TARGET}.pdf
  1059. )
  1060. ELSE (LATEX_DEFAULT_SAFEPDF)
  1061. ADD_CUSTOM_TARGET(${safepdf_target}
  1062. ${CMAKE_COMMAND} -E chdir ${output_dir}
  1063. ${PS2PDF_CONVERTER} ${PS2PDF_CONVERTER_FLAGS} ${LATEX_TARGET}.ps ${LATEX_TARGET}.pdf
  1064. )
  1065. ENDIF (LATEX_DEFAULT_SAFEPDF)
  1066. ADD_DEPENDENCIES(${safepdf_target} ${ps_target})
  1067. ENDIF (PS2PDF_CONVERTER)
  1068. ENDIF (DVIPS_CONVERTER)
  1069. IF (LATEX2HTML_CONVERTER)
  1070. ADD_CUSTOM_TARGET(${html_target}
  1071. ${CMAKE_COMMAND} -E chdir ${output_dir}
  1072. ${LATEX2HTML_CONVERTER} ${LATEX2HTML_CONVERTER_FLAGS} ${LATEX_MAIN_INPUT}
  1073. )
  1074. ADD_DEPENDENCIES(${html_target} ${LATEX_MAIN_INPUT} ${LATEX_INPUTS})
  1075. ENDIF (LATEX2HTML_CONVERTER)
  1076. SET_DIRECTORY_PROPERTIES(.
  1077. ADDITIONAL_MAKE_CLEAN_FILES "${auxiliary_clean_files}"
  1078. )
  1079. ADD_CUSTOM_TARGET(${auxclean_target}
  1080. COMMENT "Cleaning auxiliary LaTeX files."
  1081. COMMAND ${CMAKE_COMMAND} -E remove ${auxiliary_clean_files}
  1082. )
  1083. ENDMACRO(ADD_LATEX_TARGETS)
  1084. MACRO(ADD_LATEX_DOCUMENT)
  1085. LATEX_GET_OUTPUT_PATH(output_dir)
  1086. IF (output_dir)
  1087. PARSE_ADD_LATEX_ARGUMENTS(ADD_LATEX_DOCUMENT ${ARGV})
  1088. LATEX_COPY_INPUT_FILE(${LATEX_MAIN_INPUT})
  1089. FOREACH (input ${LATEX_INPUTS})
  1090. LATEX_COPY_INPUT_FILE(${input})
  1091. ENDFOREACH(input)
  1092. ADD_LATEX_TARGETS(${ARGV})
  1093. ENDIF (output_dir)
  1094. ENDMACRO(ADD_LATEX_DOCUMENT)
  1095. #############################################################################
  1096. # Actually do stuff
  1097. #############################################################################
  1098. IF (LATEX_BUILD_COMMAND)
  1099. SET(command_handled)
  1100. IF ("${LATEX_BUILD_COMMAND}" STREQUAL makeglossaries)
  1101. LATEX_MAKEGLOSSARIES()
  1102. SET(command_handled TRUE)
  1103. ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL makeglossaries)
  1104. IF ("${LATEX_BUILD_COMMAND}" STREQUAL makenomenclature)
  1105. LATEX_MAKENOMENCLATURE()
  1106. SET(command_handled TRUE)
  1107. ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL makenomenclature)
  1108. IF ("${LATEX_BUILD_COMMAND}" STREQUAL correct_synctex)
  1109. LATEX_CORRECT_SYNCTEX()
  1110. SET(command_handled TRUE)
  1111. ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL correct_synctex)
  1112. IF ("${LATEX_BUILD_COMMAND}" STREQUAL run_tex_command)
  1113. LATEX_RUN_TEX_COMMAND()
  1114. SET(command_handled TRUE)
  1115. ENDIF ("${LATEX_BUILD_COMMAND}" STREQUAL run_tex_command)
  1116. IF (NOT command_handled)
  1117. MESSAGE(SEND_ERROR "Unknown command: ${LATEX_BUILD_COMMAND}")
  1118. ENDIF (NOT command_handled)
  1119. ELSE (LATEX_BUILD_COMMAND)
  1120. # Must be part of the actual configure (included from CMakeLists.txt).
  1121. LATEX_SETUP_VARIABLES()
  1122. ENDIF (LATEX_BUILD_COMMAND)
  1123. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...