Salome HOME
29fdf6bb90cb1e3e3714b0e454394cd118b678ee
[tools/medcoupling.git] / doc / user / doxygen / CMakeLists.txt
1 # Copyright (C) 2012-2015  CEA/DEN, EDF R&D
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
20 SALOME_CONFIGURE_FILE(Doxyfile_med_user.in Doxyfile_med_user)
21 SALOME_CONFIGURE_FILE(static/header.html.in static/header.html)
22
23
24 IF(MEDCOUPLING_MED_ENABLE_PYTHON)
25   INCLUDE(doxy2swig/doxy2swig.cmake)
26
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)
30
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
33   # Doxygen.
34
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
42   )
43
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})
48   ENDFUNCTION()
49
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})
55   ENDFOREACH()
56   # Note: The reason for writing to a temporary is so the real target file only
57   # gets updated if its content has changed.
58
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
63     VERBATIM
64     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
65   )
66
67   # Create dummy target gathering the generation of all .i files:
68   ADD_CUSTOM_TARGET(swig_ready)
69   ADD_DEPENDENCIES(swig_ready usr_docs)
70
71   MEDCOUPLING_MED_SWIG_DOCSTRING_CONFIGURE(usr_docs swig_ready MEDCoupling)
72   MEDCOUPLING_MED_SWIG_DOCSTRING_CONFIGURE(usr_docs swig_ready MEDLoader)
73
74   SET(doxyfile_med_user ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_med_user)
75   FILE(STRINGS ${doxyfile_med_user} enabled_sections REGEX "ENABLED_SECTIONS")
76   IF(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})
80   ELSE()
81     FILE(APPEND ${doxyfile_med_user}
82       "#Temporary variable to enable python documentation sections\nENABLED_SECTIONS = ENABLE_EXAMPLES")
83   ENDIF()
84
85   # Swig generation to have docstrings correctly populated:
86   INCLUDE(doxy2swig/doxy2swig.cmake)
87
88 ELSE()
89   ADD_CUSTOM_TARGET(usr_docs ALL
90     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
91     VERBATIM
92     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
93   )
94 ENDIF()
95
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})
99
100 SET(MAKE_CLEAN_FILES doc_ref_user tmp)
101 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MAKE_CLEAN_FILES}")