]> Creatis software - bbtk.git/blob - kernel/cmake/BBTKCreatePackageBBdoc.cmake
#3299 BBTK Bug New Normal wt4
[bbtk.git] / kernel / cmake / BBTKCreatePackageBBdoc.cmake
1  # ---------------------------------------------------------------------
2  #
3  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4  #                        pour la SantÈ)
5  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8  #
9  #  This software is governed by the CeCILL-B license under French law and
10  #  abiding by the rules of distribution of free software. You can  use,
11  #  modify and/ or redistribute the software under the terms of the CeCILL-B
12  #  license as circulated by CEA, CNRS and INRIA at the following URL
13  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14  #  or in the file LICENSE.txt.
15  #
16  #  As a counterpart to the access to the source code and  rights to copy,
17  #  modify and redistribute granted by the license, users are provided only
18  #  with a limited warranty  and the software's author,  the holder of the
19  #  economic rights,  and the successive licensors  have only  limited
20  #  liability.
21  #
22  #  The fact that you are presently reading this means that you have had
23  #  knowledge of the CeCILL-B license and that you accept its terms.
24  # ------------------------------------------------------------------------ */
25
26
27 MACRO(BBTK_CREATE_PACKAGE_BBDOC PACKAGE_NAME)
28   # Creates output dir if it does not exist
29   MKDIR(${BBTK_BBDOC_BUILD_PATH}/${PACKAGE_NAME})
30
31   # Create file make_doc_${PACKAGE_NAME}.bbs
32   SET(OUTPUT_PATH ${BBTK_BBS_BUILD_PATH}/${BBTK_PACKAGE_NAME}/appli)
33   SET(OUTPUT_FILE ${OUTPUT_PATH}/make_doc_${PACKAGE_NAME}.bbs)
34   SET(DOC_OUTPUT ${BBTK_BBDOC_BUILD_PATH}/${PACKAGE_NAME}/index.html)
35   FILE(WRITE 
36     "${OUTPUT_FILE}" 
37     "#-----------------------------------------\n"
38     "# Generates the html doc for package '${PACKAGE_NAME}'\n"
39     "# Automatically generated by cmake (macro BBTK_CREATE_PACKAGE_BBDOC)\n")
40   FILE(APPEND 
41     "${OUTPUT_FILE}"
42     "#-----------------------------------------\n"
43     "exec freeze\n"
44     "include ${PACKAGE_NAME}\n"
45     "include ${PACKAGE_NAME}-appli\n"
46     "#-----------------------------------------\n"
47 #    "graph ${PACKAGE_NAME} 0 0 ${DOC_OUTPUT} \"${CMAKE_CURRENT_BINARY_DIR}/header.html\" \"Package ${PACKAGE_NAME} documentation\"\n"
48     "graph ${PACKAGE_NAME} 0 0 ${DOC_OUTPUT} \"${BBTK_BBDOC_BUILD_PATH}/${BBTK_PACKAGE_NAME}/header.html\" \"Package ${PACKAGE_NAME} documentation\"\n"
49
50     )
51   IF(WIN32)
52   INSTALL(
53     FILES ${OUTPUT_FILE}
54     DESTINATION ${BBTK_BBS_REL_PATH}/${BBTK_PACKAGE_NAME}/appli
55     )
56   ELSE(WIN32)
57   INSTALL(
58     FILES ${OUTPUT_FILE}
59     DESTINATION ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/appli
60     )
61   ENDIF(WIN32)
62   
63
64   #
65   IF(WIN32)
66     SET(USE_DOT TRUE)
67     MAKE_DLL_PATH()
68 #    FILE(TO_NATIVE_PATH ${EXECUTABLE_OUTPUT_PATH}/bb${BBTK_PACKAGE_NAME}.dll  pathCommand2 )   
69     FILE(TO_NATIVE_PATH  ${BBTK_BIN_PATH}/bbtk_config.xml pathCommand2 )        
70     FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/${BBTK_BBS_REL_PATH} pathCommand1 )
71     set(command1 cd ${pathCommand1}) 
72     set(command2 copy ${pathCommand2} . )   
73     set(command3 ${BBTK_BBI} -N -q ${OUTPUT_FILE}) 
74     set(command4 echo done)
75     #del bb${BBTK_PACKAGE_NAME}.dll)
76     
77     ADD_CUSTOM_COMMAND(
78       OUTPUT ${DOC_OUTPUT}
79       COMMAND 
80       #    cd ${BBTK_BIN_PATH}/../bbs/ && ${BBTK_BBI} -n ${OUTPUT_FILE}
81       set ${DLL_PATH} && ${command1} && ${command2} && ${command3} 
82       #&& ${command4}
83       DEPENDS bb${PACKAGE_NAME} 
84       )
85   ELSE(WIN32)
86     SET(LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
87     ADD_CUSTOM_COMMAND(
88       OUTPUT ${DOC_OUTPUT}
89       COMMAND 
90       cd ${EXECUTABLE_OUTPUT_PATH} && export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} && ${BBTK_BBI} -N -q ${OUTPUT_FILE} ${BBTK_MAKE_INDEX}
91       DEPENDS bb${PACKAGE_NAME} 
92       )
93
94
95   ENDIF(WIN32)
96   ADD_CUSTOM_TARGET(bbdoc_${PACKAGE_NAME} ALL
97     DEPENDS ${DOC_OUTPUT} 
98     )
99
100   IF(WIN32)
101   INSTALL( 
102     DIRECTORY ${BBTK_BBDOC_BUILD_PATH}/${PACKAGE_NAME}
103     DESTINATION ${BBTK_BBDOC_INSTALL_PATH}
104     #DESTINATION ${BBTK_BBDOC_REL_PATH}
105     )   
106   ELSE(WIN32)
107   INSTALL( 
108     DIRECTORY ${BBTK_BBDOC_BUILD_PATH}/${PACKAGE_NAME}
109     #DESTINATION ${BBTK_BBDOC_INSTALL_PATH}
110     DESTINATION ${BBTK_BBDOC_REL_PATH}
111     )   
112   ENDIF(WIN32)
113
114   IF(NOT WIN32)
115     # runs bbtk-make-index as a post install step
116     # does not work on windaube
117     IF(NOT BBTK_CORE_PACKAGE)
118       INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${BBTK_BIN_PATH}/bbtk-make-index)")
119     ENDIF(NOT BBTK_CORE_PACKAGE)
120   ENDIF(NOT WIN32)
121
122   
123 ENDMACRO(BBTK_CREATE_PACKAGE_BBDOC NAME)
124