Hi Brad,
please find attached a patch that introduces components handling for
optional LaTeX executable. FPHSA's components handling feature is pretty
cool. I first wrote the components handling myself, but the built-in
version is more elegant. I am the first one to use this feature in an
official test. Yeah!

Maybe we should deprecate the old variables name? I don't know and its
not a big deal to keep them.

Bye and thanks for your constructive feedback,
Christoph
>From 9dee2386ba4399c326df47e9e40ab308c28d43d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <[email protected]>
Date: Mon, 22 Dec 2014 08:37:34 +0100
Subject: [PATCH] FindLATEX: Add components handling

---
 Modules/FindLATEX.cmake | 60 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 45 insertions(+), 15 deletions(-)

diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake
index a935f00..db97a61 100644
--- a/Modules/FindLATEX.cmake
+++ b/Modules/FindLATEX.cmake
@@ -6,17 +6,42 @@
 #
 # This module finds an installed Latex and determines the location
 # of the compiler.  Additionally the module looks for Latex-related
-# software like BibTeX.  This code sets the following variables:
+# software like BibTeX.
+#
+# This module sets the following result variables:
 #
 # ::
 #
+#   LATEX_FOUND:          whether found Latex and requested components
+#   LATEX_<component>_FOUND:  whether found <component>
 #   LATEX_COMPILER:       path to the LaTeX compiler
 #   PDFLATEX_COMPILER:    path to the PdfLaTeX compiler
 #   BIBTEX_COMPILER:      path to the BibTeX compiler
 #   MAKEINDEX_COMPILER:   path to the MakeIndex compiler
 #   DVIPS_CONVERTER:      path to the DVIPS converter
+#   DVIPDF_CONVERTER:     path to the DVIPDF converter
 #   PS2PDF_CONVERTER:     path to the PS2PDF converter
 #   LATEX2HTML_CONVERTER: path to the LaTeX2Html converter
+#
+# Possible components are:
+#
+# ::
+#
+#  PDFLATEX
+#  BIBTEX
+#  MAKEINDEX
+#  DVIPS
+#  DVIPDF
+#  PS2PDF
+#  LATEX2HTML
+#
+# Example Usages:
+#
+# ::
+#
+#   find_package(LATEX)
+#   find_package(LATEX COMPONENTS PDFLATEX)
+#   find_package(LATEX COMPONENTS BIBTEX PS2PDF)
 
 #=============================================================================
 # Copyright 2002-2014 Kitware, Inc.
@@ -32,9 +57,7 @@
 #  License text for the above reference.)
 
 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
@@ -43,7 +66,6 @@ if (WIN32)
   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
   )
@@ -64,63 +86,69 @@ if (WIN32)
     DOC "Path to the GhostScript library directory."
   )
   mark_as_advanced(GHOSTSCRIPT_LIBRARY_PATH)
-
 endif ()
 
+# try to find Latex and the related programs
 find_program(LATEX_COMPILER
   NAMES latex
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
 
-find_program(PDFLATEX_COMPILER
+find_program(LATEX_PDFLATEX_FOUND
   NAMES pdflatex
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
+set(PDFLATEX_COMPILER LATEX_PDFLATEX_FOUND)
 
-find_program(BIBTEX_COMPILER
+find_program(LATEX_BIBTEX_FOUND
   NAMES bibtex
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
+set(BIBTEX_COMPILER LATEX_BIBTEX_FOUND)
 
-find_program(MAKEINDEX_COMPILER
+find_program(LATEX_MAKEINDEX_FOUND
   NAMES makeindex
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
+set(MAKEINDEX_COMPILER LATEX_MAKEINDEX_FOUND)
 
-find_program(DVIPS_CONVERTER
+find_program(LATEX_DVIPS_FOUND
   NAMES dvips
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
+set(DVIPS_CONVERTER LATEX_DVIPS_FOUND)
 
-find_program(DVIPDF_CONVERTER
+find_program(LATEX_DVIPDF_FOUND
   NAMES dvipdfm dvipdft dvipdf
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
+set(DVIPDF_CONVERTER LATEX_DVIPDF_FOUND)
 
 if (WIN32)
-  find_program(PS2PDF_CONVERTER
+  find_program(LATEX_PS2PDF_FOUND
     NAMES ps2pdf14.bat ps2pdf14 ps2pdf
     PATHS ${GHOSTSCRIPT_LIBRARY_PATH}
           ${MIKTEX_BINARY_PATH}
   )
 else ()
-  find_program(PS2PDF_CONVERTER
+  find_program(LATEX_PS2PDF_FOUND
     NAMES ps2pdf14 ps2pdf
   )
 endif ()
+set(PS2PDF_CONVERTER LATEX_PS2PDF_FOUND)
 
-find_program(LATEX2HTML_CONVERTER
+find_program(LATEX_LATEX2HTML_FOUND
   NAMES latex2html
   PATHS ${MIKTEX_BINARY_PATH}
         /usr/bin
 )
-
+set(LATEX2HTML_CONVERTER LATEX_LATEX2HTML_FOUND)
 
 mark_as_advanced(
   LATEX_COMPILER
@@ -133,7 +161,9 @@ mark_as_advanced(
   LATEX2HTML_CONVERTER
 )
 
+# handle variables for found Latex and its components
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(Latex
+find_package_handle_standard_args(LATEX
   REQUIRED_VARS LATEX_COMPILER
+  HANDLE_COMPONENTS
 )
-- 
2.1.2

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to