1 # Copyright (C) 2012-2016 CEA/DEN, EDF R&D
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
21 ## This module is dedicated to the generation of specific SWIG files (".i") containing
22 ## the docstrings built from the C++ doxygen documentation.
25 SET(_DOXY2SWIG ${PROJECT_SOURCE_DIR}/doc/user/doxygen/doxy2swig/doxy2swig.py)
26 SET(_SWIG_DOC_SUFFIX "doc_class_")
29 # MEDCoupling classes to include
31 SET(_classes_MEDCoupling
32 MEDCoupling_1_1MEDCouplingPointSet
33 MEDCoupling_1_1MEDCouplingUMesh
34 MEDCoupling_1_1MEDCouplingCMesh
35 MEDCoupling_1_1MEDCouplingRemapper
36 MEDCoupling_1_1DataArray
37 MEDCoupling_1_1DataArrayInt
38 MEDCoupling_1_1DataArrayDouble
42 # MEDLoader classes to include
44 SET(_classes_MEDLoader
45 MEDCoupling_1_1MEDFileMeshes
46 MEDCoupling_1_1MEDFileMesh
47 MEDCoupling_1_1MEDFileUMesh
48 MEDCoupling_1_1MEDFileCMesh
52 ## Generates the ".i" files from a list of C++ classes.
54 ## \param[in] target_doc main target for the stantard doxygen generation
55 ## \param[in] target_swig dummy target encompassing the final build of all SWIG files
56 ## \param[in] cls_list list of classes for which to generate SWIG files
57 ## \param[in] swig_main_file main SWIG file including the other generated SWIG files
58 ## \param[out] swig_files list of generated SWIG files
60 MACRO(MEDCOUPLING_SWIG_DOCSTRING_GENERATE target_doc target_swig cls_list swig_main_file swig_files)
61 # List of generated SWIG files (.i) for doc purposes only:
63 FOREACH(_cls IN LISTS ${cls_list})
64 SET(_xml_file "${CMAKE_CURRENT_BINARY_DIR}/../doxygen/doc_ref_user/xml/class${_cls}.xml")
65 SET(_swig_file_base "${_SWIG_DOC_SUFFIX}${_cls}.i")
66 SET(_swig_file "${PROJECT_BINARY_DIR}/doc/${_swig_file_base}" )
68 # SWIG doc files will always be generated *after* Doxygen is run:
69 ### WARNING: ADD_CUSTOM_COMMAND(TARGET xxx POST_BUILD ...) command
70 ### must be in exactly the same subdir as the initial target construction command.
71 ### That's why this file is included with an INCLUDE() rather than using ADD_SUBDIRECTORY
72 # Note: we touch the main .i file to be sure to retrigger swig when the doc in a included
74 ADD_CUSTOM_COMMAND(OUTPUT ${_swig_file}
75 COMMAND ${PYTHON_EXECUTABLE} ${_DOXY2SWIG} "-n" ${_xml_file} ${_swig_file}
76 COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${swig_main_file}
78 COMMENT "Generating docstring SWIG file (from Doxygen's XML): ${_swig_file_base}"
81 ADD_CUSTOM_TARGET(${_swig_file_base} DEPENDS ${_swig_file})
82 # The doxy2swig script is executed once the doxygen documentation has been generated ...
83 ADD_DEPENDENCIES(${_swig_file_base} ${target_doc})
84 # ... and the meta target 'swig_ready' (here ${target_swig}) is ready when all .i files
85 # have been generated:
86 ADD_DEPENDENCIES(${target_swig} ${_swig_file_base})
88 LIST(APPEND ${swig_files} ${_swig_file_base})
90 ENDMACRO(MEDCOUPLING_SWIG_DOCSTRING_GENERATE)
94 ## Configures the MEDCoupling_doc.i or MEDLoader_doc.i file so that they include
95 ## the list of SWIG files generated by the macro above.
97 ## \param[in] target_doc main target for the stantard doxygen generation
98 ## \param[in] target_swig dummy target encompassing the final build of all SWIG files
99 ## \param[in] root_name either 'MEDCoupling' or 'MEDLoader'
101 MACRO(MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE target_doc target_swig root_name)
103 SET(_swig_include_set)
104 SET(_in_file doxy2swig/${root_name}_doc.i.in)
105 SET(_out_file ${PROJECT_BINARY_DIR}/doc/${root_name}_doc.i)
106 MEDCOUPLING_SWIG_DOCSTRING_GENERATE(${target_doc} ${target_swig} _classes_${root_name} ${_out_file} _all_swig_docs)
107 FOREACH(f IN LISTS _all_swig_docs)
108 SET(_swig_include_set "${_swig_include_set}\n%include \"${f}\"")
110 CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
111 ENDMACRO(MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE)