Skip to content
Snippets Groups Projects

Feature/update uselatex.cmake to 2.3.0

Merged Christoph Grüninger requested to merge feature/update-uselatex.cmake-to-2.3.0 into master
3 files
+ 1025
836
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 67
72
@@ -34,97 +34,92 @@
# shadows all options provided by the base implementation
# :code:`add_latex_document`.
#
# .. cmake_function:: create_doc_install
#
# TODO doc me
# What are use cases for this function?
#
FIND_PACKAGE(LATEX)
FIND_PROGRAM(IMAGEMAGICK_CONVERT convert
find_package(LATEX)
find_program(IMAGEMAGICK_CONVERT convert
DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)."
)
set(LATEX_USABLE "ON")
set(LATEX_USABLE TRUE)
# UseLATEX.cmake does only work in out-of-source builds
if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
message(WARNING "In-source detected, disabling LaTeX documentation. Use an out-of-source build to generate documentation.")
set(LATEX_USABLE FALSE)
endif()
# check needed LaTeX executables
if(NOT LATEX_COMPILER)
message(WARNING " Need latex to create documentation!")
set(LATEX_USABLE)
endif(NOT LATEX_COMPILER)
set(LATEX_USABLE FALSE)
endif()
if(NOT BIBTEX_COMPILER)
message(WARNING " Need bibtex to create documentation!")
set(LATEX_USABLE)
endif(NOT BIBTEX_COMPILER)
set(LATEX_USABLE FALSE)
endif()
if(NOT MAKEINDEX_COMPILER)
message(WARNING " Need makeindex to create documentation!")
set(LATEX_USABLE)
endif(NOT MAKEINDEX_COMPILER)
set(LATEX_USABLE FALSE)
endif()
if(NOT IMAGEMAGICK_CONVERT)
message(WARNING " Need imagemagick to create latex documentation!")
set(LATEX_USABLE)
endif(NOT IMAGEMAGICK_CONVERT)
set(LATEX_USABLE FALSE)
endif()
if(LATEX_USABLE)
set(LATEX_MANGLE_TARGET_NAMES "ON" CACHE INTERNAL "Mangle target names to allow multiple latex documents")
include(UseLATEX)
endif(LATEX_USABLE)
endif()
add_custom_target(doc)
# add the Sphinx-generated build system documentation
include(DuneSphinxCMakeDoc)
# Support building documentation with doxygen.
include(DuneDoxygen)
macro(dune_add_latex_document tex_file)
set(latex_arguments "${ARGN}")
# replace old DEFAULT_SAFEPDF by FORCE_DVI and emit warning
# this compatibility code can be removed after Dune 3.0
list(FIND latex_arguments DEFAULT_SAFEPDF position_safepdf)
if(NOT position_safepdf EQUAL -1)
list(REMOVE_AT latex_arguments ${position_safepdf})
list(APPEND latex_arguments FORCE_DVI)
message(WARNING "dune_add_latex_document's argument DEFAULT_SAFEPDF is deprecated, use FORCE_DVI instead")
endif()
# replace old DEFAULT_PDF and emit warning
# this compatibility code can be removed after Dune 3.0
list(FIND latex_arguments DEFAULT_PDF position_defaultpdf)
if(NOT position_defaultpdf EQUAL -1)
list(REMOVE_AT latex_arguments ${position_defaultpdf})
message(WARNING "dune_add_latex_document's argument DEFAULT_PDF is deprecated, just drop it")
endif()
# remove old argument FATHER_TARGET which is dropped and handled by an automatism now
# this compatibility code can be removed after Dune 3.0
list(FIND latex_arguments FATHER_TARGET position_fathertarget)
if(NOT position_fathertarget EQUAL -1)
list(REMOVE_AT latex_arguments ${position_fathertarget})
# father has an according argument trailing which is removed, too
list(REMOVE_AT latex_arguments ${position_fathertarget})
message(WARNING "dune_add_latex_document's argument FATHER_TARGET <target> is deprecated, this is handled automatically now")
endif()
MACRO(create_doc_install filename targetdir)
dune_module_path(MODULE dune-common RESULT scriptdir SCRIPT_DIR)
get_filename_component(targetfile ${filename} NAME)
# The doc file might be in CMAKE_CURRENT_<SOURCE|BINARY>_DIR
# Depending on whether this is a tarball or not
set(_src_file _src_file-NOTFOUND)
find_file(_src_file ${targetfile} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT _src_file)
set(_src_file ${filename})
set(_need_to_generate TRUE)
endif(NOT _src_file)
set(install_command ${CMAKE_COMMAND} -D FILES=${_src_file} -D DIR=${CMAKE_INSTALL_PREFIX}/${targetdir} -P ${scriptdir}/InstallFile.cmake)
# create a custom target for the installation
if("${ARGC}" EQUAL "3" AND _need_to_generate)
set(_depends ${ARGV2})
else("${ARGC}" EQUAL "3" AND _need_to_generate)
set(_depends ${_src_file})
endif("${ARGC}" EQUAL "3" AND _need_to_generate)
add_custom_target(install_${targetfile} ${install_command}
COMMENT "Installing ${filename} to ${targetdir}"
DEPENDS ${_depends})
# When installing, call cmake install with the above install target and add the file to install_manifest.txt
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target install_${targetfile} )
LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_PREFIX}/${targetdir}/${targetfile})")
ENDMACRO(create_doc_install)
MACRO(dune_add_latex_document tex_file)
# We assume that we always generate a PDF file.
# If the corresponding pdf file already exists in the source tree
# we do not add a rule to build it.
string(REGEX REPLACE "(.+).tex" "\\1.pdf" file ${tex_file})
string(REGEX REPLACE "/" "_" "${CMAKE_CURRENT_SOURCE_DIR}/${file}" filevar ${file})
set(filevar "filevar-NOTFOUND")
find_file(filevar ${tex_file} ${CMAKE_CURRENT_SOURCE_DIR})
if(filevar)
if(LATEX_USABLE)
# add rule to create latex document
add_latex_document(${tex_file} ${ARGN} MANGLE_TARGET_NAMES)
else(LATEX_USABLE)
message(WARNING "Not adding rule to create ${file} as LaTeX is not usable!")
endif(LATEX_USABLE)
else(filevar)
# Check for the pdf file
set(pdffilevar "pdffilevar-NOTFOUND")
find_file(pdffilevar ${file} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT pdffilevar)
message(SEND_ERROR "No tex source ${tex_file} and no generated ${file} found!")
endif(NOT pdffilevar)
endif(filevar)
ENDMACRO(dune_add_latex_document tex_file)
if(LATEX_USABLE)
# add rule to create latex document
add_latex_document(${tex_file} ${latex_arguments}
EXCLUDE_FROM_ALL
EXCLUDE_FROM_DEFAULTS)
# add tependency for target doc, but first construct document's target name
string(REGEX REPLACE "(.+).tex" "\\1" tex_file_base_name ${tex_file})
list(FIND latex_arguments FORCE_DVI has_forcedvi)
if(has_forcedvi EQUAL -1)
add_dependencies(doc "${tex_file_base_name}")
else()
add_dependencies(doc "${tex_file_base_name}_safepdf")
endif()
else()
message(WARNING "Not adding rule to create ${file} as LaTeX is not usable!")
endif()
endmacro(dune_add_latex_document tex_file)
# Support building documentation with doxygen.
include(DuneDoxygen)
# this compatibility code can be removed after Dune 3.0
macro(create_doc_install)
message(WARNING "create_doc_install is no longer needed, you can install these files directly")
endmacro(create_doc_install)
Loading