macro(add_additional_pdf_outputs filename_base num_times_to_call_pdflatex compiler)
# ARGN can be used to specify additional dependencies
foreach (DUMMY_VAR RANGE 1 ${num_times_to_call_pdflatex})
list(APPEND COMMAND_ARGS COMMAND ${compiler} ${ASY_DOC_DIR}/${filename_base}.tex)
endforeach()
# there are unfortunately still some issues with out-of-source builds
# with pdflatex, hence we have to copy the files to the build root first
add_custom_command(
OUTPUT ${PDFLATEX_OUTPUT_PREFIX}.tex
DEPENDS ${ASY_DOC_DIR}/${filename_base}.tex
COMMAND ${CMAKE_COPY_ASY_FILE_TO_DOCBUILD_BASE_ARGS} ${ASY_DOC_DIR}/${filename_base}.tex
)
# the following files are only used with docgen, hence they are not added if
# ENABLE_ASYMPTOTE_PDF_DOCGEN is not used
if (ENABLE_ASYMPTOTE_PDF_DOCGEN)
# asy files
set(ASY_DOC_FILE_PREFIXES
axis3 basealign bezier bigdiagonal binarytreetest Bode brokenaxis
colons colors cube cylinderskeleton datagraph diagonal dots
eetomumu elliptic errorbars exp fillcontour flow flowchartdemo
GaussianSurface generalaxis generalaxis3 graphmarkers graphwithderiv grid3xyz
hatch helix HermiteSpline histogram Hobbycontrol Hobbydir icon image imagecontour
irregularcontour join join3 knots labelsquare legend lineargraph lineargraph0
linetype log2graph loggraph loggrid logimage logticks makepen markers1 markers2 mexicanhat
monthaxis multicontour onecontour parametricgraph penfunctionimage penimage planes quartercircle
saddle scaledgraph shadedtiling slopefield1 square subpictures superpath tile
triangulate unitcircle3 vectorfield
)
# independent asymptote files that can be generated with any other files
foreach(ASY_DOC_FILE_PREFIX ${ASY_DOC_FILE_PREFIXES})
add_asy_pdf_dependency_basic(${ASY_DOC_FILE_PREFIX})
endforeach()
macro(add_asy_file_with_extension asy_file extra_ext)
set(ASY_DOC_FILE_OUTPUT ${ASY_TEX_BUILD_ROOT}/${asy_file}.pdf)
set(ASY_AUX_FILE_NAME ${asy_file}.${extra_ext})
# asymptote has some problems (currently as writing this) with asy files involving tex
# and output directory not matching, so a workaround is to copy to the doc build root
add_custom_command(
OUTPUT ${ASY_DOC_FILE_OUTPUT}
DEPENDS
${ASY_DOC_DIR}/${asy_file}.asy
${ASY_DOC_DIR}/${ASY_AUX_FILE_NAME}
asy ${ASY_OUTPUT_BASE_FILES}
COMMAND ${CMAKE_COPY_ASY_FILE_TO_DOCBUILD_BASE_ARGS}
${ASY_DOC_DIR}/${asy_file}.asy
${ASY_DOC_DIR}/${ASY_AUX_FILE_NAME}
COMMAND ${ASY_BASE_ARGUMENTS} -fpdf ${ASY_DOC_FILE_PREFIX}.asy
COMMAND ${CMAKE_RM_BASE_ARGUMENTS}
${ASY_TEX_BUILD_ROOT}/${asy_file}.asy
${ASY_TEX_BUILD_ROOT}/${ASY_AUX_FILE_NAME}
COMMAND ${CMAKE_RM_BASE_ARGUMENTS} -f
${ASY_TEX_BUILD_ROOT}/${asy_file}_.tex
WORKING_DIRECTORY ${ASY_TEX_BUILD_ROOT}
)
list(APPEND ASY_DOC_PDF_FILES ${ASY_DOC_FILE_OUTPUT})
endmacro()
macro(add_asy_file_from_docbuild_root asyfile)
# does not copy from doc root to docbuild root; have to do manually
add_custom_command(
OUTPUT ${ASY_TEX_BUILD_ROOT}/${asyfile}.pdf
COMMAND ${ASY_BASE_ARGUMENTS} -fpdf ${asyfile}.asy
DEPENDS ${ASY_TEX_BUILD_ROOT}/${asyfile}.asy
BYPRODUCTS ${ASY_TEX_BUILD_ROOT}/${asyfile}_.tex ${ASY_TEX_BUILD_ROOT}/${asyfile}_.eps
WORKING_DIRECTORY ${ASY_TEX_BUILD_ROOT}
)
endmacro()
# CDlabel + logo
copy_doc_asy_file_to_docbuild_root(logo)
add_asy_file_from_docbuild_root(logo)
add_asy_file_with_asy_dependency(CDlabel logo)