Last active
October 30, 2020 13:47
-
-
Save voldien/445f4c5fc0ea7678f0e24069eb839320 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROJECT(LatexProject NONE) | |
CMAKE_MINIMUM_REQUIRED(VERSION 3.11) | |
FIND_PACKAGE(LATEX) | |
# The directory where the final build data will be stored. | |
SET(LATEX_OUTPUT_PATH build) | |
SET(OUT_DIRECTORY "${CMAKE_SOURCE_DIR}/${LATEX_OUTPUT_PATH}") | |
# Directory where the source files are located. | |
SET( WORKINGDIR "${CMAKE_SOURCE_DIR}/src" ) | |
# Latex source file. | |
SET( MAIN_TEX_BASE_FILENAME "main") | |
SET( MAIN_TEX "${CMAKE_SOURCE_DIR}/src/${MAIN_TEX_BASE_FILENAME}.tex") | |
IF(LATEX_FOUND AND LATEX_PDFLATEX_FOUND) | |
# First pass. | |
ADD_CUSTOM_TARGET( latex-prebuild | |
COMMAND ${PDFLATEX_COMPILER} -output-directory ${OUT_DIRECTORY} -draftmode -interaction=nonstopmode ${MAIN_TEX} | |
COMMENT "Starting Prebuild." | |
WORKING_DIRECTORY ${WORKINGDIR} | |
DEPENDS ${MAIN_TEX}) | |
# Second pass - generate the final pdf. | |
ADD_CUSTOM_TARGET( latex-pdf | |
COMMAND ${PDFLATEX_COMPILER} -output-directory ${OUT_DIRECTORY} ${MAIN_TEX} | |
WORKING_DIRECTORY ${WORKINGDIR} | |
COMMENT "Assembling the final pdf file." | |
DEPENDS ${MAIN_TEX}) | |
ADD_CUSTOM_TARGET(all-formats ALL) # Entry point of execution. | |
ADD_DEPENDENCIES( all-formats latex-pdf) | |
ELSE() | |
MESSAGE(ERROR "No latex tools found!") | |
ENDIF() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment