]> Creatis software - bbtkGEditor.git/blob - cmake/UserBuildLatexDoc.cmake
#feature 1359
[bbtkGEditor.git] / cmake / UserBuildLatexDoc.cmake
1
2
3 MACRO(USER_BUILD_LATEX_DOC TEX_FILE OUTPUT_REL_PATH)
4   # Need LaTeX
5   SET(USE_LATEX ON CACHE BOOL "" FORCE)
6   # Construct absolute build path
7   SET(BUILD_PATH ${${PROJECT_NAME}_DOC_BUILD_PATH}/${OUTPUT_REL_PATH})
8   #MESSAGE(STATUS "Tex file : ${TEX_FILE}")
9   #---------------------------------------------------------------------------
10   CONFIGURE_FILE(
11     ${CMAKE_CURRENT_SOURCE_DIR}/${TEX_FILE}.tex
12     ${BUILD_PATH}/${TEX_FILE}.tex
13     COPYONLY
14     )
15   CONFIGURE_FILE(
16     ${CMAKE_CURRENT_SOURCE_DIR}/../config.tex
17     ${BUILD_PATH}/config.tex
18     @ONLY
19     )
20   CONFIGURE_FILE(
21     ${CMAKE_CURRENT_SOURCE_DIR}/../config.tex
22     ${CMAKE_CURRENT_BINARY_DIR}/config.tex
23     @ONLY
24     )
25   #---------------------------------------------------------------------------
26  FILE(TO_NATIVE_PATH ${BUILD_PATH} THE_BUILD_PATH)
27
28   # Have to run latex twice to get references, toc, etc.
29  #message("ADD_CUSTOM_COMMAND(OUTPUT ${BUILD_PATH}/${TEX_FILE}.aux   MACRO(USER_BUILD_LATEX_DOC")
30       
31 ADD_CUSTOM_COMMAND(
32     OUTPUT ${BUILD_PATH}/${TEX_FILE}.aux 
33     COMMAND 
34     # latex
35     cd ${THE_BUILD_PATH} && ${LATEX_COMPILER}
36     ARGS
37     -interaction=batchmode ${BUILD_PATH}/${TEX_FILE} -output-directory=${BUILD_PATH}/
38     
39     DEPENDS 
40     ${CMAKE_CURRENT_SOURCE_DIR}/${TEX_FILE}.tex
41     ${CMAKE_CURRENT_SOURCE_DIR}/../config.tex
42     )
43
44 #message("LATEX_COMPILER = ${LATEX_COMPILER}")
45 ADD_CUSTOM_COMMAND(
46     OUTPUT ${BUILD_PATH}/${TEX_FILE}.pdf
47     COMMAND 
48     # latex
49     cd ${THE_BUILD_PATH} && ${LATEX_COMPILER}
50     ARGS
51     -interaction=batchmode ${BUILD_PATH}/${TEX_FILE} -output-directory=${BUILD_PATH}/
52   
53     DEPENDS ${BUILD_PATH}/${TEX_FILE}.aux 
54     )
55   
56   # pdf target
57   ADD_CUSTOM_TARGET(${TEX_FILE}.pdf ALL
58     DEPENDS ${BUILD_PATH}/${TEX_FILE}.pdf)
59
60   # Install
61   INSTALL( 
62     FILES ${BUILD_PATH}/${TEX_FILE}.pdf
63     DESTINATION ${${PROJECT_NAME}_DOC_INSTALL_PATH}/${OUTPUT_REL_PATH}
64     )
65
66 ENDMACRO(USER_BUILD_LATEX_DOC)