1 # Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author: Roman NIKOLAEV
22 #----------------------------------------------------------------------------
23 # SALOME_ADD_SPHINX_DOC is a macro useful for generating sphinx documentation
25 # USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type sphinx_name src_dir cfg_dir)
29 # sphinx_type: IN - type of the sphinx generator, use one of the following types:
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)\
51 # sphinx_name: IN - documentation target name
53 # src_dir : IN - path to directory that contains the sphinx source files
55 # cfg_dir : IN - path to directory that contains sphinx configuration file (if not specified,
56 # it is considered equal to src_dir)
58 # ADDITIONAL SETTINGS:
60 # Also you can set these variables to define additional sphinx settings:
62 # SPHINXOPTS - sphinx executable options
63 # PAPER - LaTeX paper type ("a4" by default)
64 # BUILDDIR - local sphinx build directory ("_build" by default)
65 #----------------------------------------------------------------------------
67 MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name src_dir cfg_dir)
69 # Get type and additional settings
70 SET(SPHINX_TYPE ${sphinx_type})
71 IF(${SPHINX_TYPE} STREQUAL "")
73 ENDIF(${SPHINX_TYPE} STREQUAL "")
75 IF("${PAPER}" STREQUAL "")
79 IF("${BUILDDIR}" STREQUAL "")
83 SET(SPHINX_CFG ${cfg_dir})
84 IF("${SPHINX_CFG}" STREQUAL "")
85 SET(SPHINX_CFG ${src_dir})
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})
94 SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${src_dir})
95 SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${src_dir})
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")
104 # Build sphinx command
105 SET(_CMD_OPTIONS -b ${SPHINX_TYPE} -c ${SPHINX_CFG} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR})
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})
112 ENDMACRO(SALOME_ADD_SPHINX_DOC)