ClhepBuildTex.cmake 2.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# run latex 

# clhep_latex( package main_tex_file [other tex or sty files to include] )

# for documentation
FIND_PACKAGE(LATEX)

macro( clhep_latex package main_tex_file )
IF(LATEX_COMPILER)
   FOREACH(arg ${ARGN})  
     CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/${arg} 
                     ${CMAKE_CURRENT_BINARY_DIR}/${arg}  COPYONLY)
     set( depend_list ${arg} ${depend_list} )
   ENDFOREACH(arg) 
   ##message(STATUS "${package} ${main_tex_file} depends on ${depend_list}" )
   ADD_CUSTOM_COMMAND( 
    OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.aux
    COMMAND   ${LATEX_COMPILER}
Lynn Garren's avatar
Lynn Garren committed
19
              -interaction=batchmode ${CMAKE_CURRENT_SOURCE_DIR}/${main_tex_file}
20
21
22
23
24
25
    DEPENDS   ${CMAKE_CURRENT_SOURCE_DIR}/${main_tex_file}.tex ${depend_list}
    COMMENT   "Latex - first pass"
  )
   ADD_CUSTOM_COMMAND( 
    OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.dvi
    COMMAND   ${LATEX_COMPILER}
Lynn Garren's avatar
Lynn Garren committed
26
              -interaction=batchmode ${CMAKE_CURRENT_SOURCE_DIR}/${main_tex_file}
27
28
29
30
31
32
    DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.aux
    COMMENT   "Latex - second pass"
  )
   ADD_CUSTOM_COMMAND( 
    OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.log
    COMMAND   ${LATEX_COMPILER}
Lynn Garren's avatar
Lynn Garren committed
33
              -interaction=batchmode ${CMAKE_CURRENT_SOURCE_DIR}/${main_tex_file}
34
35
36
37
38
39
40
41
42
43
44
    DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.dvi
    COMMENT   "Latex - third pass"
  )
  ADD_CUSTOM_TARGET(${main_tex_file} ALL echo
    DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.log
    )

IF(DVIPS_CONVERTER)
    ADD_CUSTOM_COMMAND( 
      OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.ps
      COMMAND   ${DVIPS_CONVERTER}
Lynn Garren's avatar
Lynn Garren committed
45
                ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.dvi
46
47
48
49
50
51
52
53
54
                -o ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.ps
      DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.dvi
      COMMENT   "dvi2ps"
   )

 IF(PS2PDF_CONVERTER)
    ADD_CUSTOM_COMMAND( 
      OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.pdf
      COMMAND   ${PS2PDF_CONVERTER}
Lynn Garren's avatar
Lynn Garren committed
55
                ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.ps
56
57
58
59
60
61
62
63
64
      DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.ps
      COMMENT   "ps2pdf"
    )

 ADD_CUSTOM_TARGET( ${package}${main_tex_file}Document ALL echo
      DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.pdf
    )
    ENDIF(PS2PDF_CONVERTER)
  ENDIF(DVIPS_CONVERTER)
65
66
67

 INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${main_tex_file}.pdf
          DESTINATION doc/${package} )
68
69
70
ENDIF(LATEX_COMPILER)

endmacro( clhep_latex )