]> Creatis software - bbtk.git/blob - kernel/cmake/BBTKCreatePackageIncludeScript.cmake
Allow user to always forget .bbs
[bbtk.git] / kernel / cmake / BBTKCreatePackageIncludeScript.cmake
1
2
3 MACRO(BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT    BBTK_PACKAGE_NAME    BBTK_PACKAGE_BBS_BOXES    BBTK_PACKAGE_BBS_APPLI )
4
5   SET(OUTPUT_PATH ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME})
6   SET(OUTPUT_FILE ${PROJECT_BINARY_DIR}/${OUTPUT_PATH}/${BBTK_PACKAGE_NAME}.bbs)
7   
8  # MESSAGE(ERROR "${BBTK_PACKAGE_BBS_BOXES} - ${BBTK_PACKAGE_BBS_APPLI}")
9
10   # Creates the file ${BBTK_PACKAGE_NAME}.bbs
11   FILE(WRITE 
12     "${OUTPUT_FILE}" 
13     "#-----------------------------------------\n"
14     "# Include script for bbtk package '${BBTK_PACKAGE_NAME}'\n"
15     "# Automatically generated by cmake (macro BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT)\n")
16   FILE(APPEND 
17     "${OUTPUT_FILE}"
18     "#-----------------------------------------\n"
19     "load ${BBTK_PACKAGE_NAME}\n"
20     "#-----------------------------------------\n"
21     "package ${BBTK_PACKAGE_NAME}\n"
22     )
23   FOREACH(bbs ${BBTK_PACKAGE_BBS_BOXES})  
24     FILE(APPEND 
25       "${OUTPUT_FILE}"
26       "#-----------------------------------------\n"
27       "include ${bbs}\n"
28       )
29   ENDFOREACH(bbs)
30   FOREACH(bbs ${BBTK_PACKAGE_BBS_APPLI})  
31     GET_FILENAME_COMPONENT(filename "${bbs}" NAME_WE) 
32     FILE(APPEND 
33       "${OUTPUT_FILE}"
34       "#-----------------------------------------\n"
35       "define ${filename}\n"
36       "include ${bbs}\n"
37       "endefine\n"
38       )
39   ENDFOREACH(bbs)
40   FILE(APPEND 
41     "${OUTPUT_FILE}"
42       "#-----------------------------------------\n"
43       "endpackage\n"
44       "#-- EOF ----------------------------------\n"
45     )
46
47 #  ADD_CUSTOM_TARGET(${BBTK_PACKAGE_NAME}.bbs ALL
48 #    DEPENDS  ${OUTPUT_FILE}
49 #    )
50
51   INSTALL(
52     FILES ${OUTPUT_FILE}
53     DESTINATION ${OUTPUT_PATH}
54     )
55
56 ENDMACRO(BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT)