[Cmake] FindLATEX minor corrections and question related to ADD_CUSTOM_COMMAND

Anton Deguet anton at cs . jhu . edu
Mon, 02 Jun 2003 18:32:22 -0400


This is a multi-part message in MIME format.
--------------040703050504010207050302
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I am currently trying to use CMake to compile some LaTeX documents.  I 
am using a three days old CVS version.

-1- There is a minor inconsistency in FindLATEX.cmake regarding the 
cached variables.  All are cached except DVIPDF_CONVERTER.

-2- I am using pdflatex (much better than a ps2pdf I believe) as well as 
html2latex.  Both are pretty standard therefore I added them in my 
FindLATEX.cmake (file attached).

Finally, I am running in a minor problem with my tables of content in 
the LaTeX files.  I need an undetermind number of passes to converge on 
my dvi file (or pdf with pdflatex).  The first pass compile the toc and 
the second insert it and recompute the page numbers.  I used an 
ADD_CUSTOM_COMMAND which works fine with latex2html:

   ADD_CUSTOM_TARGET (${file}Html ALL)
   ADD_CUSTOM_COMMAND(
     SOURCE    ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     COMMAND   ${LATEX2HTML_COMPILER}
     ARGS      -split 0
               -show_section_numbers
               -dir ${CMAKE_CURRENT_BINARY_DIR}
               ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     TARGET    ${file}Html
     OUTPUTS   ${file}.html
   )
   ADD_CUSTOM_COMMAND(
     SOURCE    ${file}Html
     TARGET    ${file}Html
     DEPENDS   ${file}.html
   )


For my postscript, I use a cumbersome dependency which indead breaks the 
dependencies by including two bogus files which are never created.  As 
for the LaTeX document, it's not perfect since I compile it only twice, 
but it is better than a single compilation.

  ADD_CUSTOM_TARGET (${file}DviPassOne ALL)
   ADD_CUSTOM_COMMAND(
     SOURCE    ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     COMMAND   ${LATEX_COMPILER}
     ARGS      ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     TARGET    ${file}DviPassOne
     OUTPUTS   ${file}.dvi.pass1
   )
   ADD_CUSTOM_COMMAND(
     SOURCE    ${file}DviPassOne
     TARGET    ${file}DviPassOne
     DEPENDS   ${file}.dvi.pass1
   )

   ADD_CUSTOM_TARGET (${file}DviPassTwo ALL)
   ADD_CUSTOM_COMMAND(
     SOURCE    ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     COMMAND   ${LATEX_COMPILER}
     ARGS      ${CMAKE_CURRENT_SOURCE_DIR}/${file}.tex
     TARGET    ${file}DviPassTwo
     OUTPUTS   ${file}.dvi.pass2
   )
   ADD_CUSTOM_COMMAND(
     SOURCE    ${file}DviPassTwo
     TARGET    ${file}DviPassTwo
     DEPENDS   ${file}.dvi.pass2
   )

   INSTALL_FILES(/latex "*.dvi" ${file}.dvi)

   ADD_CUSTOM_TARGET (${file}Ps ALL)
   ADD_CUSTOM_COMMAND(
     SOURCE    ${CMAKE_CURRENT_BINARY_DIR}/${file}.dvi
     COMMAND   ${DVIPS_CONVERTER}
     ARGS      ${CMAKE_CURRENT_BINARY_DIR}/${file}.dvi
               -o ${file}.ps
     DEPENDS   ${file}DviPassOne ${file}DviPassTwo
     TARGET    ${file}Ps
     OUTPUTS   ${file}.ps
   )
   ADD_CUSTOM_COMMAND(
     SOURCE    ${file}Ps
     TARGET    ${file}Ps
     DEPENDS   ${file}.ps

That's pretty ugly.  Anyone has a better solution, i.e. recompiling with 
LaTeX only when necessary?

Thanks,

Anton


-- 
Anton Deguet - Email anton<at>cs.jhu.edu
Office NEB B26 - Phone 410 516 5261 - Fax 410 516 3332
http://cisstweb . cs . jhu . edu

--------------040703050504010207050302
Content-Type: text/plain;
 name="FindLATEX.cmake"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="FindLATEX.cmake"

#
# This module finds if Latex is installed and determines where the
# executables are. This code sets the following variables:
#
#  LATEX_COMPILER        = the full path to the LaTeX compiler
#  BIBTEX_COMPILER       = the full path to the BibTeX compiler
#  MAKEINDEX_COMPILER    = the full path to the MakeIndex compiler
#  DVIPS_CONVERTER       = the full path to the DVIPS converter
#  PS2PDF_CONVERTER      = the full path to the PS2PDF converter
#  PDFLATEX_COMPILER     = the full path to the PdfLaTeX compiler
#  LATEX2HTML_COMPILER   = the full path to the LaTeX2Html compiler

IF (WIN32)

  # Try to find the MikTex binary path (look for its package manager).

  FIND_PATH(MIKTEX_BINARY_PATH mpm.exe
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MiK\\MiKTeX\\CurrentVersion\\MiKTeX;Install Root]/miktex/bin"
    DOC 
    "Path to the MikTex binary directory."
  )
  MARK_AS_ADVANCED(MIKTEX_BINARY_PATH)

  # Try to find the GhostScript binary path (look for gswin32).

  GET_FILENAME_COMPONENT(GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_8_00
     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\AFPL Ghostscript\\8.00;GS_DLL]" PATH
  )

  GET_FILENAME_COMPONENT(GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_7_04
     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\AFPL Ghostscript\\7.04;GS_DLL]" PATH
  )

  FIND_PATH(GHOSTSCRIPT_BINARY_PATH gswin32.exe
    ${GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_8_00}
    ${GHOSTSCRIPT_BINARY_PATH_FROM_REGISTERY_7_04}
    DOC "Path to the GhostScript binary directory."
  )
  MARK_AS_ADVANCED(GHOSTSCRIPT_BINARY_PATH)

  FIND_PATH(GHOSTSCRIPT_LIBRARY_PATH ps2pdf13.bat
    "${GHOSTSCRIPT_BINARY_PATH}/../lib"
    DOC "Path to the GhostScript library directory."
  )
  MARK_AS_ADVANCED(GHOSTSCRIPT_LIBRARY_PATH)

ENDIF (WIN32)

FIND_PROGRAM(LATEX_COMPILER
  NAMES latex
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(BIBTEX_COMPILER
  NAMES bibtex
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(MAKEINDEX_COMPILER
  NAMES makeindex
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(DVIPS_CONVERTER
  NAMES dvips
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(DVIPDF_CONVERTER
  NAMES dvipdfm dvipdft dvipdf
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(PDFLATEX_COMPILER
  NAMES pdflatex
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

FIND_PROGRAM(LATEX2HTML_COMPILER
  NAMES latex2html
  PATHS ${MIKTEX_BINARY_PATH}
        /usr/bin
)

IF (WIN32)
  FIND_PROGRAM(PS2PDF_CONVERTER
    NAMES ps2pdf14.bat
    PATHS ${GHOSTSCRIPT_LIBRARY_PATH}
  )
ELSE (WIN32)
  FIND_PROGRAM(PS2PDF_CONVERTER
    NAMES ps2pdf14 psd2pdf
  )
ENDIF (WIN32)

MARK_AS_ADVANCED(
  LATEX_COMPILER
  BIBTEX_COMPILER
  MAKEINDEX_COMPILER
  DVIPS_CONVERTER
  DVIPDF_CONVERTER
  PS2PDF_CONVERTER
  PDFLATEX_COMPILER
  LATEX2HTML_COMPILER
)

--------------040703050504010207050302--