1# - Find Latex
2# This module finds if Latex is installed and determines where the
3# executables are. This code sets the following variables:
4#
5#  LATEX_COMPILER:       path to the LaTeX compiler
6#  PDFLATEX_COMPILER:    path to the PdfLaTeX compiler
7#  BIBTEX_COMPILER:      path to the BibTeX compiler
8#  MAKEINDEX_COMPILER:   path to the MakeIndex compiler
9#  DVIPS_CONVERTER:      path to the DVIPS converter
10#  PS2PDF_CONVERTER:     path to the PS2PDF converter
11#  LATEX2HTML_CONVERTER: path to the LaTeX2Html converter
12#
13
14IF (WIN32)
15
16  # Try to find the MikTex binary path (look for its package manager).
17
18  FIND_PATH(MIKTEX_BINARY_PATH mpm.exe
19    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MiK\\MiKTeX\\CurrentVersion\\MiKTeX;Install Root]/miktex/bin"
20    DOC
21    "Path to the MikTex binary directory."
22  )
23  MARK_AS_ADVANCED(MIKTEX_BINARY_PATH)
24
25  # Try to find the GhostScript binary path (look for gswin32).
26
27  GET_FILENAME_COMPONENT(GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_8_00
28     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\AFPL Ghostscript\\8.00;GS_DLL]" PATH
29  )
30
31  GET_FILENAME_COMPONENT(GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_7_04
32     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\AFPL Ghostscript\\7.04;GS_DLL]" PATH
33  )
34
35  FIND_PATH(GHOSTSCRIPT_BINARY_PATH gswin32.exe
36    ${GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_8_00}
37    ${GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_7_04}
38    DOC "Path to the GhostScript binary directory."
39  )
40  MARK_AS_ADVANCED(GHOSTSCRIPT_BINARY_PATH)
41
42  FIND_PATH(GHOSTSCRIPT_LIBRARY_PATH ps2pdf13.bat
43    "${GHOSTSCRIPT_BINARY_PATH}/../lib"
44    DOC "Path to the GhostScript library directory."
45  )
46  MARK_AS_ADVANCED(GHOSTSCRIPT_LIBRARY_PATH)
47
48ENDIF (WIN32)
49
50FIND_HOST_PROGRAM(LATEX_COMPILER
51  NAMES latex
52  PATHS ${MIKTEX_BINARY_PATH}
53        /usr/bin /usr/texbin
54)
55
56FIND_HOST_PROGRAM(PDFLATEX_COMPILER
57  NAMES pdflatex
58  PATHS ${MIKTEX_BINARY_PATH}
59        /usr/bin /usr/texbin
60)
61
62FIND_HOST_PROGRAM(BIBTEX_COMPILER
63  NAMES bibtex
64  PATHS ${MIKTEX_BINARY_PATH}
65        /usr/bin /usr/texbin
66)
67
68FIND_HOST_PROGRAM(MAKEINDEX_COMPILER
69  NAMES makeindex
70  PATHS ${MIKTEX_BINARY_PATH}
71        /usr/bin /usr/texbin
72)
73
74FIND_HOST_PROGRAM(DVIPS_CONVERTER
75  NAMES dvips
76  PATHS ${MIKTEX_BINARY_PATH}
77        /usr/bin /usr/texbin
78)
79
80FIND_HOST_PROGRAM(DVIPDF_CONVERTER
81  NAMES dvipdfm dvipdft dvipdf
82  PATHS ${MIKTEX_BINARY_PATH}
83        /usr/bin /usr/texbin
84)
85
86IF (WIN32)
87  FIND_HOST_PROGRAM(PS2PDF_CONVERTER
88    NAMES ps2pdf14.bat
89    PATHS ${GHOSTSCRIPT_LIBRARY_PATH}
90  )
91ELSE (WIN32)
92  FIND_HOST_PROGRAM(PS2PDF_CONVERTER
93    NAMES ps2pdf14 ps2pdf
94    PATHS /usr/bin /usr/texbin
95  )
96ENDIF (WIN32)
97
98FIND_HOST_PROGRAM(LATEX2HTML_CONVERTER
99  NAMES latex2html
100  PATHS ${MIKTEX_BINARY_PATH}
101        /usr/bin /usr/texbin
102)
103
104
105MARK_AS_ADVANCED(
106  LATEX_COMPILER
107  PDFLATEX_COMPILER
108  BIBTEX_COMPILER
109  MAKEINDEX_COMPILER
110  DVIPS_CONVERTER
111  DVIPDF_CONVERTER
112  PS2PDF_CONVERTER
113  LATEX2HTML_CONVERTER
114)
115