Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/medcoupling
[tools/medcoupling.git] / doc / developer / doxygen / CMakeLists.txt
1 # Copyright (C) 2012-2020  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 # Set MEDCOUPLING_SERVER_BASED_SEARCH=ON when building docs for putting on www.salome-platform.org
21 # MEDCOUPLING_SERVER_BASED_SEARCH is used in Doxyfile_med_dev
22 #
23 IF(MEDCOUPLING_SERVER_BASED_SEARCH)
24   SET(MEDCOUPLING_SERVER_BASED_SEARCH "YES")
25 ELSE()
26   SET(MEDCOUPLING_SERVER_BASED_SEARCH "NO")
27 ENDIF()
28
29 SALOME_CONFIGURE_FILE(Doxyfile_med_dev.in Doxyfile_med_dev)
30 SALOME_CONFIGURE_FILE(static/header.html.in static/header.html)
31
32
33 IF(MEDCOUPLING_ENABLE_PYTHON)
34   INCLUDE(doxy2swig/doxy2swig.cmake)
35
36   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/tmp/medcouplingexamples.in" input)
37   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/BuildPyExamplesFromCPP.py" pythondocexamplesgenerator)
38   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" output)
39
40   # :TRICKY: For ease of maintenance, documentation for code examples is
41   # splitted in several files. We here splice to a single file before running
42   # Doxygen.
43
44   SET(EXAMPLE_FILES # files to concatenate: order is important!
45     doxfiles/examples/medcouplingexamplesheader.doxy
46     doxfiles/examples/medcouplingexamplesfields.doxy
47     doxfiles/examples/medcouplingexamplesmeshes.doxy
48     doxfiles/examples/medcouplingexamplesarrays.doxy
49     doxfiles/examples/medcouplingexamplesother.doxy
50     doxfiles/examples/medcouplingexamplesfooter.doxy
51     )
52
53   # This function adds IN_FILE contents to the end of OUT_FILE
54   FUNCTION(concat IN_FILE OUT_FILE)
55     FILE(READ ${IN_FILE} CONTENTS)
56     FILE(APPEND ${OUT_FILE} ${CONTENTS})
57   ENDFUNCTION()
58
59   # Prepare a temporary file to "concat" to:
60   FILE(WRITE ${input} "")
61   # Call the "concat" function for each example file
62   FOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
63     concat(${EXAMPLE_FILE} ${input})
64   ENDFOREACH()
65   # Note: The reason for writing to a temporary is so the real target file only
66   # gets updated if its content has changed.
67
68   # Here is the "standard" procedure, as if ${input} was hand-written.
69   ADD_CUSTOM_TARGET(dev_docs ALL
70     COMMAND ${PYTHON_EXECUTABLE} ${pythondocexamplesgenerator} ${input} ${output}
71     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_dev
72     VERBATIM
73     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
74   )
75
76   # Create dummy target gathering the generation of all .i files:
77   ADD_CUSTOM_TARGET(swig_ready)
78   ADD_DEPENDENCIES(swig_ready dev_docs)
79
80   MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE(dev_docs swig_ready MEDCoupling)
81   MEDCOUPLING_SWIG_DOCSTRING_CONFIGURE(dev_docs swig_ready MEDLoader)
82
83   SET(doxyfile_med_dev ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_med_dev)
84   FILE(STRINGS ${doxyfile_med_dev} enabled_sections REGEX "ENABLED_SECTIONS")
85   IF(enabled_sections)
86     FILE(READ ${doxyfile_med_dev} doxy_file)
87     STRING(REPLACE ${enabled_sections} "${enabled_sections} ENABLE_EXAMPLES" new_doxy_file ${doxy_file})
88     FILE(WRITE ${doxyfile_med_dev} ${new_doxy_file})
89   ELSE()
90     FILE(APPEND ${doxyfile_med_dev}
91       "#Temporary variable to enable python documentation sections\nENABLED_SECTIONS = ENABLE_EXAMPLES")
92   ENDIF()
93
94   # Swig generation to have docstrings correctly populated:
95   INCLUDE(doxy2swig/doxy2swig.cmake)
96
97 ELSE()
98   ADD_CUSTOM_TARGET(dev_docs ALL
99     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_dev
100     VERBATIM
101     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
102   )
103 ENDIF()
104
105 #INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target dev_docs)")
106 INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc_ref_dev/html/ DESTINATION ${MEDCOUPLING_INSTALL_DOC}/developer)
107 INSTALL(FILES images/head.png DESTINATION ${MEDCOUPLING_INSTALL_DOC}/developer)
108
109 SET(MAKE_CLEAN_FILES doc_ref_dev tmp)
110 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MAKE_CLEAN_FILES}")