Salome HOME
928d2a6ce133f79a23deae4168a239f5c18a0c6d
[modules/med.git] / doc / doxygen / CMakeLists.txt
1 # Copyright (C) 2012-2013  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.
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(indoxfiles Doxyfile_med_user.in static/header.html.in)
21 SET(builddir ${CMAKE_CURRENT_BINARY_DIR})
22 SET(srcdir   ${CMAKE_CURRENT_SOURCE_DIR})
23 FOREACH(indoxfile ${indoxfiles})
24   STRING(REGEX REPLACE ".in" "" baseindoxfile ${indoxfile})
25   SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${indoxfile})
26   SET(output ${CMAKE_CURRENT_BINARY_DIR}/${baseindoxfile})
27   CONFIGURE_FILE(${input} ${output})
28   MESSAGE(STATUS "Creation of ${output}")
29 ENDFOREACH(indoxfile ${indoxfiles})
30 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/medcouplingexamples.in" input)
31 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/BuildPyExamplesFromCPP.py" pythondocexamplesgenerator)
32 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" output)
33
34
35 # :TRICKY: For ease of maintenance, documentation for code examples is
36 # splitted in several files. We here splice to a single file before running
37 # Doxygen.
38
39 SET(EXAMPLE_FILES # files to concatenate: order is important!
40   doxfiles/examples/medcouplingexamplesheader.doxy
41   doxfiles/examples/medcouplingexamplesfields.doxy
42   doxfiles/examples/medcouplingexamplesmeshes.doxy
43   doxfiles/examples/medcouplingexamplesarrays.doxy
44   doxfiles/examples/medcouplingexamplesother.doxy
45   doxfiles/examples/medcouplingexamplesfooter.doxy
46   )
47
48 # This function adds IN_FILE contents to the end of OUT_FILE
49 FUNCTION(concat IN_FILE OUT_FILE)
50   FILE(READ ${IN_FILE} CONTENTS)
51   FILE(APPEND ${OUT_FILE} ${CONTENTS})
52 ENDFUNCTION()
53
54 # Prepare a temporary file to "concat" to:
55 FILE(WRITE medcouplingexamples.in "")
56 # Call the "concat" function for each example file
57 FOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
58   concat(${EXAMPLE_FILE} medcouplingexamples.in)
59 ENDFOREACH()
60 # Copy the temporary file to the final location
61 CONFIGURE_FILE(medcouplingexamples.in ${CMAKE_CURRENT_BINARY_DIR}/medcouplingexamples.dox)
62 # Note: The reason for writing to a temporary is so the real target file only
63 # gets updated if its content has changed.
64
65
66 # Here is the "standard" procedure, as if ${input} was hand-written.
67 ADD_CUSTOM_TARGET(usr_docs ALL
68   COMMAND ${PYTHON_EXECUTABLE} ${pythondocexamplesgenerator} ${input} ${output}
69   COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
70   COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/MED''', True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html''', r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/MED'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/head.png''', r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/MED''')"
71   VERBATIM
72   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
73   )