Salome HOME
Synchronize adm files
[modules/med.git] / doc / doxygen / CMakeLists.txt
1 # Copyright (C) 2012-2014  CEA/DEN, EDF R&D, OPEN CASCADE
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(SALOME_MED_ENABLE_PYTHON)
25   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/tmp/medcouplingexamples.in" input)
26   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/BuildPyExamplesFromCPP.py" pythondocexamplesgenerator)
27   FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" output)
28   
29   # :TRICKY: For ease of maintenance, documentation for code examples is
30   # splitted in several files. We here splice to a single file before running
31   # Doxygen.
32
33   SET(EXAMPLE_FILES # files to concatenate: order is important!
34     doxfiles/examples/medcouplingexamplesheader.doxy
35     doxfiles/examples/medcouplingexamplesfields.doxy
36     doxfiles/examples/medcouplingexamplesmeshes.doxy
37     doxfiles/examples/medcouplingexamplesarrays.doxy
38     doxfiles/examples/medcouplingexamplesother.doxy
39     doxfiles/examples/medcouplingexamplesfooter.doxy
40   )
41
42   # This function adds IN_FILE contents to the end of OUT_FILE
43   FUNCTION(concat IN_FILE OUT_FILE)
44     FILE(READ ${IN_FILE} CONTENTS)
45     FILE(APPEND ${OUT_FILE} ${CONTENTS})
46   ENDFUNCTION()
47
48   # Prepare a temporary file to "concat" to:
49   FILE(WRITE ${input} "")
50   # Call the "concat" function for each example file
51   FOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
52     concat(${EXAMPLE_FILE} ${input})
53   ENDFOREACH()
54   # Note: The reason for writing to a temporary is so the real target file only
55   # gets updated if its content has changed.
56
57   # Here is the "standard" procedure, as if ${input} was hand-written.
58   ADD_CUSTOM_TARGET(usr_docs ALL
59     COMMAND ${PYTHON_EXECUTABLE} ${pythondocexamplesgenerator} ${input} ${output}
60     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
61     VERBATIM
62     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
63   )
64   
65   SET(doxyfile_med_user ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_med_user)
66   FILE(STRINGS ${doxyfile_med_user} enabled_sections REGEX "ENABLED_SECTIONS")
67   IF(enabled_sections)
68     FILE(READ ${doxyfile_med_user} doxy_file)
69     STRING(REPLACE ${enabled_sections} "${enabled_sections} ENABLE_EXAMPLES" new_doxy_file ${doxy_file})
70     FILE(WRITE ${doxyfile_med_user} ${new_doxy_file})
71   ELSE()
72     FILE(APPEND ${doxyfile_med_user} 
73       "#Temporary variable to enable python documentation sections\nENABLED_SECTIONS = ENABLE_EXAMPLES")
74   ENDIF()
75   
76 ELSE()
77   ADD_CUSTOM_TARGET(usr_docs ALL
78     COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile_med_user
79     VERBATIM
80     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
81   )
82 ENDIF()
83  
84 INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
85 INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html/ DESTINATION ${SALOME_INSTALL_DOC}/gui/MED)
86 INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/MED) 
87
88 SET(MAKE_CLEAN_FILES doc_ref_user tmp)
89 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MAKE_CLEAN_FILES}")