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
20 SALOME_CONFIGURE_FILE(Doxyfile_med_user.in Doxyfile_med_user)
21 SALOME_CONFIGURE_FILE(static/header.html.in static/header.html)
24 IF(MEDCOUPLING_ENABLE_PYTHON)
25 INCLUDE(doxy2swig/doxy2swig.cmake)
27 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/tmp/medcouplingexamples.in" input)
28 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/BuildPyExamplesFromCPP.py" pythondocexamplesgenerator)
29 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" output)
31 # :TRICKY: For ease of maintenance, documentation for code examples is
32 # splitted in several files. We here splice to a single file before running
35 SET(EXAMPLE_FILES # files to concatenate: order is important!
36 doxfiles/examples/medcouplingexamplesheader.doxy
37 doxfiles/examples/medcouplingexamplesfields.doxy
38 doxfiles/examples/medcouplingexamplesmeshes.doxy
39 doxfiles/examples/medcouplingexamplesarrays.doxy
40 doxfiles/examples/medcouplingexamplesother.doxy
41 doxfiles/examples/medcouplingexamplesfooter.doxy
44 # This function adds IN_FILE contents to the end of OUT_FILE
45 FUNCTION(concat IN_FILE OUT_FILE)
46 FILE(READ ${IN_FILE} CONTENTS)
47 FILE(APPEND ${OUT_FILE} ${CONTENTS})
50 # Prepare a temporary file to "concat" to:
51 FILE(WRITE ${input} "")
52 # Call the "concat" function for each example file
53 FOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
54 concat(${EXAMPLE_FILE} ${input})
56 # Note: The reason for writing to a temporary is so the real target file only
57 # gets updated if its content has changed.
59 # Here is the "standard" procedure, as if ${input} was hand-written.
60 ADD_CUSTOM_TARGET(usr_docs ALL
61 COMMAND ${PYTHON_EXECUTABLE} ${pythondocexamplesgenerator} ${input} ${output}
62 COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
64 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
67 # Create dummy target gathering the generation of all .i files:
68 ADD_CUSTOM_TARGET(swig_ready)
69 ADD_DEPENDENCIES(swig_ready usr_docs)
71 MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE(usr_docs swig_ready MEDCoupling)
72 MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE(usr_docs swig_ready MEDLoader)
74 SET(doxyfile_med_user ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_med_user)
75 FILE(STRINGS ${doxyfile_med_user} enabled_sections REGEX "ENABLED_SECTIONS")
77 FILE(READ ${doxyfile_med_user} doxy_file)
78 STRING(REPLACE ${enabled_sections} "${enabled_sections} ENABLE_EXAMPLES" new_doxy_file ${doxy_file})
79 FILE(WRITE ${doxyfile_med_user} ${new_doxy_file})
81 FILE(APPEND ${doxyfile_med_user}
82 "#Temporary variable to enable python documentation sections\nENABLED_SECTIONS = ENABLE_EXAMPLES")
85 # Swig generation to have docstrings correctly populated:
86 INCLUDE(doxy2swig/doxy2swig.cmake)
89 ADD_CUSTOM_TARGET(usr_docs ALL
90 COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
92 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
96 #INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
97 INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html/ DESTINATION ${MEDCOUPLING_INSTALL_DOC})
98 INSTALL(FILES images/head.png DESTINATION ${MEDCOUPLING_INSTALL_DOC})
100 SET(MAKE_CLEAN_FILES doc_ref_user tmp)
101 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MAKE_CLEAN_FILES}")