Skip to content
Snippets Groups Projects
Commit f1186cb2 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Switch dune-pdelab-tutorials to using UseLatexMk.cmake

parent b278a531
No related branches found
No related tags found
1 merge request!24Switch dune-pdelab-tutorials to using UseLatexMk.cmake
Showing
with 204 additions and 105 deletions
......@@ -23,6 +23,8 @@ dune_require_cxx_standard(MODULE "dune-pdelab-tutorials" VERSION 14)
dune_enable_all_packages()
add_subdirectory(cmake/modules)
add_subdirectory(overview)
add_subdirectory(c++)
add_subdirectory(gridinterface)
......
add_latex_document(exercise_cpp1.tex TARGET_NAME exercise_cpp1_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise_cpp1.tex)
include(UseLatexMk)
# Find module for LatexMk
#
# This module honors the following input variables:
# LATEXMK_ROOT
# Directory to take the latexmk executable from
# LATEXMK_DIR
# Alternative variable instead of LATEXMK_ROOT
#
# The module checks for the presence of the LatexMk executable
# and sets the following variables:
#
# LATEXMK_FOUND
# Whether the latexmk executable was found on the system
# LATEXMK_EXECUTABLE
# The full path of the found latexmk executable
# LATEXMK_VERSION_STRING
# A well readable string of the latexmk version.
# LATEXMK_VERSION_MAJOR
# The major version of the latexmk executable
# LATEXMK_VERSION_MINOR
# The minor version of the latexmk executable
#
# Copyright (c) 2017, Dominic Kempf
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# * Neither the name of the Universität Heidelberg nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Find the actual program
find_program(LATEXMK_EXECUTABLE
latexmk
PATHS ${LATEXMK_ROOT}
${LATEXMK_DIR}
)
# If found, figure out a version
if(LATEXMK_EXECUTABLE)
execute_process(COMMAND ${LATEXMK_EXECUTABLE} --version
OUTPUT_VARIABLE LATEXMK_VERSION_LINE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCH "[0-9\\.]*$" LATEXMK_VERSION_STRING ${LATEXMK_VERSION_LINE})
string(REGEX REPLACE "[0-9]*\\." "" LATEXMK_VERSION_MINOR ${LATEXMK_VERSION_STRING})
string(REGEX REPLACE "\\.[0-9]*" "" LATEXMK_VERSION_MAJOR ${LATEXMK_VERSION_STRING})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LatexMk
FOUND_VAR LATEXMK_FOUND
REQUIRED_VARS LATEXMK_EXECUTABLE
VERSION_VAR LATEXMK_VERSION_STRING)
# UseLatexMk.cmake is a CMake module to build Latex documents
# from CMake.
#
# To use this project, just copy the cmake modules (*.cmake) from this
# project into your project and use the functions documented below.
# Please also make sure to maintain below license agreement when copying.
#
# For any further informations visit https://github.com/dokempf/UseLatexMk
#
# For usability instructions see README.md.
#
# Copyright (c) 2017, Dominic Kempf
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# * Neither the name of the Universität Heidelberg nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Find LATEX and LatexMk
find_package(LATEX)
find_package(LatexMk)
function(add_latexmk_document)
# Parse the input parameters to the function
set(OPTION REQUIRED EXCLUDE_FROM_ALL)
set(SINGLE SOURCE TARGET)
set(MULTI FATHER_TARGET)
include(CMakeParseArguments)
cmake_parse_arguments(LMK "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN})
if(LMK_UNPARSED_ARGUMENTS)
message("add_latex_document: Unparsed arguments! This often indicates typos in named arguments.")
endif()
# Apply default arguments and check for required arguments
if(NOT LMK_SOURCE)
message(FATAL_ERROR "No tex source specified for add_latex_document!")
endif()
if(NOT LMK_TARGET)
# Construct a nice target name from the source file
get_filename_component(LMK_TARGET ${LMK_SOURCE} ABSOLUTE)
file(RELATIVE_PATH LMK_TARGET ${CMAKE_SOURCE_DIR} ${LMK_TARGET})
# get_filename_component(LMK_TARGET ${LMK_TARGET} DIRECTORY)
string(REPLACE "/" "_" LMK_TARGET ${LMK_TARGET})
string(REPLACE "." "_" LMK_TARGET ${LMK_TARGET})
endif()
if(LMK_FATHER_TARGET)
set(LMK_EXCLUDE_FROM_ALL TRUE)
endif()
# Check the existence of the latexmk executable and skip/fail if not present
if(NOT (LATEXMK_FOUND AND PDFLATEX_COMPILER))
if(LMK_REQUIRED)
message(FATAL_ERROR "Some Latex documents were required by the project, but LATEX or LatexMk were not found!")
else()
return()
endif()
endif()
# Inspect the EXCLUDE_FROM_ALL option
if(LMK_EXCLUDE_FROM_ALL)
set(ALL_OPTION "")
else()
set(ALL_OPTION "ALL")
endif()
# Call the latexmk executable
add_custom_target(${LMK_TARGET}
${ALL_OPTION}
COMMAND ${LATEXMK_EXECUTABLE}
-pdflatex=\"${PDFLATEX_COMPILER} -shell-escape -interaction=nonstopmode %O %S\"
-pdf
-outdir=\"${CMAKE_CURRENT_BINARY_DIR}\"
${LMK_SOURCE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
# Add dependencies to father targets
foreach(father ${LMK_FATHER_TARGET})
if(NOT TARGET ${father})
message(FATAL_ERROR "The target given to add_latex_documents FATHER_TARGET parameter does not exist")
endif()
add_dependencies(${father} ${LMK_TARGET})
endforeach()
endfunction()
add_latex_document(exercise_grid1.tex TARGET_NAME exercise_grid1_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise_grid1.tex)
add_latex_document(exercise_grid2.tex TARGET_NAME exercise_grid2_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise_grid2.tex)
add_latex_document(abstractions.tex TARGET_NAME abstractions_pdf
BIBFILES abstractions.bib
FORCE_PDF
)
add_latexmk_document(SOURCE abstractions.tex)
add_latex_document(overview.tex TARGET_NAME overview_pdf
FORCE_PDF
)
add_latexmk_document(SOURCE overview.tex)
add_latex_document(exercise-workflow.tex TARGET_NAME exercise-workflow_pdf
FORCE_PDF
)
dune_symlink_to_source_files(FILES debug.opts release.opts)
add_latexmk_document(SOURCE exercise-workflow.tex)
dune_symlink_to_source_files(FILES ../src/tutorial00.cc
../src/tutorial00.ini
../src/driver.hh
../src/poissonp1.hh)
add_latex_document(tutorial00.tex TARGET_NAME tutorial00_pdf
BIBFILES tutorial00.bib
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE tutorial00.tex)
add_latex_document(exercise00.tex TARGET_NAME exercise00_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise00.tex)
add_latex_document(slides00.tex TARGET_NAME slides00_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE slides00.tex)
dune_symlink_to_source_files(FILES ../src/tutorial01.cc
../src/driver.hh
../src/problem.hh
../src/nonlinearpoissonfem.hh
../src/tutorial01.ini )
add_latex_document(tutorial01.tex TARGET_NAME tutorial01_pdf
BIBFILES tutorial01.bib
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE tutorial01.tex)
add_latex_document(exercise01.tex TARGET_NAME exercise01_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise01.tex)
add_latex_document(slides01.tex TARGET_NAME slides01_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE slides01.tex)
dune_symlink_to_source_files(FILES ../src/driver.hh
../src/nonlinearpoissonfv.hh
../src/problem.hh
../src/tutorial02.cc
../src/tutorial02.ini)
add_latex_document(tutorial02.tex TARGET_NAME tutorial02_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE tutorial02.tex)
add_latex_document(slides02.tex TARGET_NAME slides02_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE slides02.tex)
dune_symlink_to_source_files(FILES ../src/tutorial03.cc
../src/driver.hh
../src/nonlinearheatfem.hh
../src/problem.hh
../src/tutorial03.ini
)
add_latex_document(tutorial03.tex TARGET_NAME tutorial03_pdf
BIBFILES tutorial03.bib
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE tutorial03.tex)
add_latex_document(exercise03.tex TARGET_NAME exercise03_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE exercise03.tex)
add_latex_document(slides03.tex TARGET_NAME slides03_pdf
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE slides03.tex)
dune_symlink_to_source_files(FILES ../src/tutorial04.cc
../src/driver.hh
../src/wavefem.hh
../src/tutorial04.ini
)
add_latex_document(tutorial04.tex TARGET_NAME tutorial04_pdf
BIBFILES tutorial04.bib
IMAGE_DIRS .
FORCE_PDF
)
add_latexmk_document(SOURCE tutorial04.tex)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment