]> Creatis software - creaRigidRegistration.git/blob - cmake/UserBuildLatexDoc.cmake
*** empty log message ***
[creaRigidRegistration.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   ADD_CUSTOM_COMMAND(
30     OUTPUT ${BUILD_PATH}/${TEX_FILE}.aux 
31     COMMAND 
32     # latex
33     cd ${THE_BUILD_PATH} && ${LATEX_COMPILER}
34     ARGS
35     -interaction=batchmode ${BUILD_PATH}/${TEX_FILE} -output-directory=${BUILD_PATH}/
36     
37     DEPENDS 
38     ${CMAKE_CURRENT_SOURCE_DIR}/${TEX_FILE}.tex
39     ${CMAKE_CURRENT_SOURCE_DIR}/../config.tex
40     )
41   ADD_CUSTOM_COMMAND(
42     OUTPUT ${BUILD_PATH}/${TEX_FILE}.pdf
43     COMMAND 
44     # latex
45     cd ${THE_BUILD_PATH} && ${LATEX_COMPILER}
46     ARGS
47     -interaction=batchmode ${BUILD_PATH}/${TEX_FILE} -output-directory=${BUILD_PATH}/
48   
49     DEPENDS ${BUILD_PATH}/${TEX_FILE}.aux 
50     )
51   
52   # pdf target
53   ADD_CUSTOM_TARGET(${TEX_FILE}.pdf ALL
54     DEPENDS ${BUILD_PATH}/${TEX_FILE}.pdf)
55
56   # Install
57   INSTALL( 
58     FILES ${BUILD_PATH}/${TEX_FILE}.pdf
59     DESTINATION ${${PROJECT_NAME}_DOC_INSTALL_PATH}/${OUTPUT_REL_PATH}
60     )  
61
62
63 ENDMACRO(USER_BUILD_LATEX_DOC)