Salome HOME
Update copyrights
[tools/configuration.git] / cmake / SalomeDocumentationMacros.cmake
1 # Copyright (C) 2013-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Author: Roman NIKOLAEV
20 #
21
22 #----------------------------------------------------------------------------
23 # SALOME_ADD_SPHINX_DOC is a macro useful for generating sphinx documentation
24 #
25 # USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type sphinx_name src_dir cfg_dir)
26 #
27 # ARGUMENTS:
28 #
29 # sphinx_type: IN - type of the sphinx generator, use one of the following  types: 
30 #
31 #                       html       - to make standalone HTML files
32 #                       dirhtml    - to make HTML files named index.html in directories
33 #                       singlehtml - to make a single large HTML file
34 #                       pickle     - to make pickle files
35 #                       json       - to make JSON files
36 #                       htmlhelp   - to make HTML files and a HTML help project
37 #                       qthelp     - to make HTML files and a qthelp project"
38 #                       devhelp    to make HTML files and a Devhelp project"
39 #                       epub       to make an epub"
40 #                       latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
41 #                       latexpdf   to make LaTeX files and run them through pdflatex"
42 #                       text       to make text files"
43 #                       man        to make manual pages"
44 #                       texinfo    to make Texinfo files"
45 #                       info       to make Texinfo files and run them through makeinfo
46 #                       gettext    to make PO message catalogs"
47 #                       changes    to make an overview of all changed/added/deprecated items
48 #                       linkcheck  to check all external links for integrity"
49 #                       doctest    to run all doctests embedded in the documentation (if enabled)\
50
51 # sphinx_name: IN - documentation target name
52 #
53 # src_dir : IN - path to directory that contains the sphinx source files
54
55 # cfg_dir : IN - path to directory that contains sphinx configuration file (if not specified,
56 #           it is considered equal to src_dir)
57 #
58 # ADDITIONAL SETTINGS:
59 #
60 # Also you can set these variables to define additional sphinx settings:
61 #
62 #                        SPHINXOPTS    - sphinx executable options
63 #                        PAPER         - LaTeX paper type          ("a4" by default)
64 #                        BUILDDIR      - local sphinx build directory  ("_build" by default)
65 #----------------------------------------------------------------------------
66
67 MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name src_dir cfg_dir)
68
69   # Get type and additional settings
70   SET(SPHINX_TYPE ${sphinx_type})
71   IF(${SPHINX_TYPE} STREQUAL "")
72     SET(SPHINX_TYPE html)
73   ENDIF(${SPHINX_TYPE} STREQUAL "")
74
75   IF("${PAPER}" STREQUAL "")
76     SET(PAPER a4)
77   ENDIF()
78  
79   IF("${BUILDDIR}" STREQUAL "")
80     SET(BUILDDIR _build)
81   ENDIF()
82
83   SET(SPHINX_CFG ${cfg_dir})
84   IF("${SPHINX_CFG}" STREQUAL "")
85     SET(SPHINX_CFG ${src_dir})
86   ENDIF()
87
88   # Initialize internal variables
89   SET(PAPEROPT_a4 -D latex_paper_size=a4)
90   SET(PAPEROPT_letter -D latex_paper_size=letter)
91   SET(ALLSPHINXOPTS  -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS})
92   SET(I18NSPHINXOPTS  ${PAPEROPT_${PAPER}} ${SPHINXOPTS})
93
94   SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${src_dir})
95   SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${src_dir})
96
97   # Set internal out directory
98   SET(_OUT_DIR ${SPHINX_TYPE}) 
99   IF(${SPHINX_TYPE} STREQUAL "gettext")
100     SET(_OUT_DIR gettext)
101     SET(ALLSPHINXOPTS ${I18NSPHINXOPTS})
102   ENDIF(${SPHINX_TYPE} STREQUAL "gettext")
103
104   # Build sphinx command
105   SET(_CMD_OPTIONS -b ${SPHINX_TYPE} -c ${SPHINX_CFG} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR})
106
107   # This macro mainly prepares the environment in which sphinx should run:
108   # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ...
109   SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}")
110   ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd})
111
112 ENDMACRO(SALOME_ADD_SPHINX_DOC)