CMakeLists.txt 1.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
SET(USERGUIDESRC ${CMAKE_CURRENT_SOURCE_DIR})
SET(USERGUIDE ${CMAKE_BINARY_DIR}/docs/developers-guide)

FILE(MAKE_DIRECTORY ${USERGUIDE}/html)

FIND_PROGRAM(HTLATEX htlatex)
MARK_AS_ADVANCED(HTLATEX)
ADD_CUSTOM_TARGET(developers-guide-html
    export TEXINPUTS=${CMAKE_SOURCE_DIR}//:${USERGUIDESRC}//: &&
    ${HTLATEX} ${USERGUIDESRC}/developers-guide.tex 
    "${USERGUIDESRC}/styling.cfg,html,3,next,NoFonts"
    WORKING_DIRECTORY ${USERGUIDE}/html
)

# If tex4ht successful, create img dir and copy images across
FILE(GLOB_RECURSE imgfiles "img/*.png" "img/*.jpg" "*/img/*.png" "*/img/*.jpg")
ADD_CUSTOM_COMMAND(TARGET developers-guide-html
    POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${USERGUIDE}/html/img)
FOREACH(img ${imgfiles})
    ADD_CUSTOM_COMMAND(TARGET developers-guide-html
        POST_BUILD COMMAND 
            ${CMAKE_COMMAND} -E copy ${img} ${USERGUIDE}/html/img)
ENDFOREACH()

FILE(GLOB_RECURSE pdffiles "*/img/*.pdf")
FIND_PROGRAM(CONVERT convert)
FOREACH(pdf ${pdffiles})
    GET_FILENAME_COMPONENT(BASENAME ${pdf} NAME_WE)
    ADD_CUSTOM_COMMAND(TARGET developers-guide-html
        POST_BUILD COMMAND
        ${CONVERT} ${pdf} ${USERGUIDE}/html/img/${BASENAME}.png)
ENDFOREACH()


FIND_PROGRAM(PDFLATEX pdflatex)
MARK_AS_ADVANCED(PDFLATEX)
FIND_PROGRAM(BIBTEX bibtex)
MARK_AS_ADVANCED(BIBTEX)
FIND_PROGRAM(MAKEINDEX makeindex)
MARK_AS_ADVANCED(MAKEINDEX)

ADD_CUSTOM_TARGET(developers-guide-pdf
    export TEXINPUTS=${CMAKE_SOURCE_DIR}//: && 
    ${PDFLATEX} --output-directory ${USERGUIDE} ${USERGUIDESRC}/developers-guide.tex
    COMMAND TEXMFOUTPUT=${USERGUIDE} ${BIBTEX} ${USERGUIDE}/developers-guide.aux
    COMMAND TEXMFOUTPUT=${USERGUIDE} ${MAKEINDEX} ${USERGUIDE}/developers-guide.idx
    COMMAND TEXINPUTS=${CMAKE_SOURCE_DIR}//:  
    ${PDFLATEX} --output-directory ${USERGUIDE} ${USERGUIDESRC}/developers-guide.tex
    COMMAND TEXINPUTS=${CMAKE_SOURCE_DIR}//:  
    ${PDFLATEX} --output-directory ${USERGUIDE} ${USERGUIDESRC}/developers-guide.tex
    WORKING_DIRECTORY ${USERGUIDESRC}
)