~ubuntu-branches/ubuntu/wily/ledger/wily

« back to all changes in this revision

Viewing changes to doc/CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2014-10-08 19:20:38 UTC
  • mfrom: (1.1.3) (9.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20141008192038-py5cxm93rdt3x2uz
Tags: 3.1+dfsg1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
if (USE_DOXYGEN)
9
9
  find_package(Doxygen)
10
 
  if(NOT DOXYGEN_FOUND)
 
10
  if (NOT DOXYGEN_FOUND)
11
11
    message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.")
12
12
  endif()
13
13
 
27
27
 
28
28
########################################################################
29
29
 
30
 
if(NOT BUILD_DOCS)
31
 
  add_custom_target(doc DEPENDS doc.doxygen)
32
 
  return()
 
30
if (BUILD_DOCS)
 
31
  find_program(MAKEINFO makeinfo)
 
32
  find_program(TEXI2PDF texi2pdf)
 
33
  find_program(TEX tex)
 
34
  find_program(MAN2HTML man2html)
 
35
  find_program(GROFF groff)
 
36
  set(ledger_info_files ledger3.texi ledger-mode.texi)
 
37
 
 
38
  if (NOT MAKEINFO)
 
39
    message(WARNING "Could not find makeinfo. Info version of documentation cannot be built.")
 
40
  endif()
 
41
 
 
42
  if (NOT TEXI2PDF OR NOT TEX)
 
43
    message(WARNING "Could not find texi2pdf or tex. PDF version of documentation will not be built.")
 
44
  endif()
33
45
endif()
34
46
 
35
 
set(info_files ledger3.texi ledger-mode.texi)
36
 
 
37
 
find_program(MAKEINFO makeinfo)
38
 
find_program(TEXI2PDF texi2pdf)
39
 
find_program(MAN2HTML man2html)
40
 
 
41
47
########################################################################
42
48
 
43
 
foreach(file ${info_files})
 
49
foreach(file ${ledger_info_files})
44
50
  get_filename_component(file_base ${file} NAME_WE)
45
 
  if(BUILD_WEB_DOCS)
46
 
    if(NOT MAKEINFO)
47
 
      message(FATAL_ERROR "Could not find makeinfo. HTML version of documentation cannot be built.")
48
 
    endif()
49
 
 
 
51
 
 
52
  if (MAKEINFO)
 
53
    add_custom_command(OUTPUT ${file_base}.info
 
54
      COMMAND makeinfo --force --no-split -o ${file_base}.info ${CMAKE_CURRENT_SOURCE_DIR}/${file}
 
55
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
 
56
      VERBATIM)
 
57
    list(APPEND ledger_doc_files ${file_base}.info)
 
58
  endif()
 
59
 
 
60
  if (BUILD_WEB_DOCS AND MAKEINFO)
50
61
    add_custom_command(OUTPUT ${file_base}.html
51
62
      COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file}
52
63
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
53
64
      VERBATIM)
54
65
    list(APPEND ledger_doc_files ${file_base}.html)
55
 
  endif(BUILD_WEB_DOCS)
 
66
  endif()
56
67
 
57
 
  if(NOT TEXI2PDF)
58
 
    message(WARNING "Could not find texi2pdf. PDF version of documentation will not be built.")
59
 
  else()
 
68
  if (TEXI2PDF AND TEX)
 
69
    if (BUILD_A4_PDF)
 
70
      set(papersize --texinfo=@afourpaper)
 
71
    endif()
60
72
    add_custom_command(OUTPUT ${file_base}.pdf
61
 
      COMMAND texi2pdf -q --tidy -b  -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file}
 
73
      COMMAND texi2pdf --tidy ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file}
62
74
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
63
75
      VERBATIM)
64
76
    list(APPEND ledger_doc_files ${file_base}.pdf)
67
79
 
68
80
########################################################################
69
81
 
70
 
if(BUILD_WEB_DOCS)
 
82
if (BUILD_WEB_DOCS)
71
83
  include(FindUnixCommands)
72
 
  if(NOT BASH)
 
84
  if (NOT BASH)
73
85
    message(FATAL_ERROR "Could not find bash. Unable to build documentation.")
74
86
  endif()
75
 
  if(NOT MAN2HTML)
76
 
    message(FATAL_ERROR "Could not find man2html. HTML version of man page cannot be built.")
 
87
  if (MAN2HTML)
 
88
    add_custom_command(OUTPUT ledger.1.html
 
89
      COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html"
 
90
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
 
91
      VERBATIM)
 
92
    list(APPEND ledger_doc_files ledger.1.html)
 
93
  elseif(GROFF)
 
94
    add_custom_command(OUTPUT ledger.1.html
 
95
      COMMAND ${BASH} -c "groff -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html"
 
96
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
 
97
      VERBATIM)
 
98
    list(APPEND ledger_doc_files ledger.1.html)
 
99
  else()
 
100
    message(FATAL_ERROR "Could not find man2html or groff. HTML version of man page cannot be built.")
77
101
  endif()
78
 
 
79
 
  add_custom_command(OUTPUT ledger.1.html
80
 
    COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html"
81
 
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
82
 
    VERBATIM)
83
 
  list(APPEND ledger_doc_files ledger.1.html)
84
102
endif(BUILD_WEB_DOCS)
85
103
 
86
104
########################################################################
91
109
 
92
110
include(GNUInstallDirs)
93
111
 
94
 
if(CMAKE_INSTALL_MANDIR)
 
112
if (CMAKE_INSTALL_MANDIR)
95
113
  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
96
114
    DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
97
115
endif(CMAKE_INSTALL_MANDIR)
98
116
 
99
 
foreach(file ${info_files})
100
 
  get_filename_component(file_base ${file} NAME_WE)
 
117
foreach(file ${ledger_doc_files})
 
118
  get_filename_component(file_ext ${file} EXT)
101
119
 
102
 
  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file}
103
 
    DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc)
104
 
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file_base}.pdf
105
 
    DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc OPTIONAL)
 
120
  if(file_ext STREQUAL ".info")
 
121
    if(CMAKE_INSTALL_INFODIR)
 
122
      install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}
 
123
        DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc)
 
124
    endif()
 
125
  elseif(CMAKE_INSTALL_DOCDIR)
 
126
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}
 
127
      DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc)
 
128
  endif()
106
129
endforeach()