【问题标题】:How do I get CMake to check for TeXLive in Pandoc?如何让 CMake 在 Pandoc 中检查 TeXLive?
【发布时间】:2020-10-21 04:01:21
【问题描述】:

在 PerfectTIN (https://github.com/phma/perfecttin) 中,我使用此 CMakeLists 文件构建文档:

find_program(PANDOC pandoc)

if (PANDOC)
execute_process(COMMAND ${PANDOC} "--resource-path=/" INPUT_FILE /dev/null ERROR_FILE /dev/null RESULT_VARIABLE pandoc_exit)
endif ()

if (PANDOC AND NOT pandoc_exit)
add_custom_command(OUTPUT perfecttin.pdf MAIN_DEPENDENCY perfecttin.xml COMMAND pandoc -f docbook -o perfecttin.pdf -V papersize=a4 -V margin-left=15mm -V margin-right=15mm -V margin-top=15mm -V margin-bottom=20mm --resource-path=${PROJECT_SOURCE_DIR}/doc ${PROJECT_SOURCE_DIR}/doc/perfecttin.xml)
add_custom_command(OUTPUT fileformat.pdf MAIN_DEPENDENCY fileformat.xml COMMAND pandoc -f docbook -o fileformat.pdf -V papersize=a4 -V margin-left=15mm -V margin-right=15mm -V margin-top=15mm -V margin-bottom=20mm --resource-path=${PROJECT_SOURCE_DIR}/doc ${PROJECT_SOURCE_DIR}/doc/fileformat.xml)
add_custom_target(perfecttin-doc ALL DEPENDS perfecttin.pdf fileformat.pdf)
install(FILES ${PROJECT_BINARY_DIR}/doc/fileformat.pdf ${PROJECT_BINARY_DIR}/doc/perfecttin.pdf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/perfecttin)
endif ()

如果 Pandoc 不存在,它不会构建文档。如果 Pandoc 和 TeXLive 都存在,它会构建文档。但是如果 Pandoc 存在但 TeXLive 不存在,则构建失败。在尝试构建文档之前,如何检查 Pandoc 是否具备所需的功能?

我试过"--resource-path=/ -f docbook -o /dev/zero";它没有解决它。

【问题讨论】:

    标签: cmake pandoc tex-live


    【解决方案1】:

    Pandoc 使用的程序是 pdflatex(在 Ubuntu 的 texlive-latex-base 包中)。所以我在 CMakeLists.txt 中添加了对 pdflatex 的搜索:

    find_program(PANDOC pandoc)
    find_program(PDFLATEX pdflatex)
    
    if (PANDOC AND PDFLATEX)
    execute_process(COMMAND ${PANDOC} "--resource-path=/" INPUT_FILE /dev/null ERROR_FILE /dev/null RESULT_VARIABLE pandoc_exit)
    endif ()
    
    if (PANDOC AND PDFLATEX AND NOT pandoc_exit)
    add_custom_command(OUTPUT perfecttin.pdf MAIN_DEPENDENCY perfecttin.xml COMMAND pandoc -f docbook -o perfecttin.pdf -V papersize=a4 -V margin-left=15mm -V margin-right=15mm -V margin-top=15mm -V margin-bottom=20mm --resource-path=${PROJECT_SOURCE_DIR}/doc ${PROJECT_SOURCE_DIR}/doc/perfecttin.xml)
    add_custom_command(OUTPUT fileformat.pdf MAIN_DEPENDENCY fileformat.xml COMMAND pandoc -f docbook -o fileformat.pdf -V papersize=a4 -V margin-left=15mm -V margin-right=15mm -V margin-top=15mm -V margin-bottom=20mm --resource-path=${PROJECT_SOURCE_DIR}/doc ${PROJECT_SOURCE_DIR}/doc/fileformat.xml)
    add_custom_target(perfecttin-doc ALL DEPENDS perfecttin.pdf fileformat.pdf)
    install(FILES ${PROJECT_BINARY_DIR}/doc/fileformat.pdf ${PROJECT_BINARY_DIR}/doc/perfecttin.pdf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/perfecttin)
    endif ()
    

    【讨论】:

      猜你喜欢
      • 2013-05-12
      • 1970-01-01
      • 2021-09-14
      • 2012-10-08
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      • 2017-10-07
      • 1970-01-01
      相关资源
      最近更新 更多