Salome HOME
updated copyright message
[tools/yacsgen.git] / module_generator / gui_tmpl.py
1 # Copyright (C) 2009-2023  EDF
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 try:
21   from string import Template
22 except:
23   from module_generator.compat import Template,set
24
25 # SalomeApp.xml file for a python gui.
26 # template parameters:
27 #   module : module name
28 #   lmodule : module name in lower case
29 #   version : version number of the module
30 pysalomeapp="""
31 <document>
32   <section name="${module}">
33     <parameter name="name" value="${module}"/>
34     <parameter name="icon" value="${module}.png"/>
35     <parameter name="library" value="SalomePyQtGUI"/>
36     <parameter name="documentation" value="${lmodule}_help"/>
37     <parameter name="version" value="${version}"/>
38   </section>
39   <section name="resources">
40     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
41   </section>
42   <section name="${lmodule}_help" >
43     <parameter name="sub_menu"          value="%1 module"/>
44     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
45   </section>
46 </document>
47 """
48 pysalomeapp=Template(pysalomeapp)
49
50 # SalomeApp.xml file for a cpp gui.
51 # template parameters:
52 #   module : module name
53 #   lmodule : module name in lower case
54 #   version : version number of the module
55 cppsalomeapp="""
56 <document>
57   <section name="${module}">
58     <parameter name="name" value="${module}"/>
59     <parameter name="icon" value="${module}.png"/>
60     <parameter name="documentation" value="${lmodule}_help"/>
61     <parameter name="version" value="${version}"/>
62   </section>
63   <section name="resources">
64     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
65   </section>
66   <section name="${lmodule}_help" >
67     <parameter name="sub_menu"          value="%1 module"/>
68     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
69   </section>
70 </document>
71 """
72 cppsalomeapp=Template(cppsalomeapp)
73
74 # CMakeLists.txt for a c++ GUI of the module (src/{module}GUI/CMakeLists.txt)
75 # template parameters:
76 #   module : module name
77 #   include_dirs : additional include directories
78 #   libs : libraries to link to
79 #   uic_files : .ui files
80 #   moc_headers : header files - to be processed by moc
81 #   sources : .cxx
82 #   resources : resource files
83 #   ts_resources : .ts files - to be processed by lrelease
84 cmake_cpp_gui = """
85 INCLUDE(UseQtExt)
86
87 # --- options ---
88 # additional include directories
89 INCLUDE_DIRECTORIES(
90   $${QT_INCLUDES}
91   $${OMNIORB_INCLUDE_DIR}
92   $${KERNEL_INCLUDE_DIRS}
93   $${GUI_INCLUDE_DIRS}
94   $${PROJECT_BINARY_DIR}/idl
95   ${include_dirs}
96 )
97
98 # additional preprocessor / compiler flags
99 ADD_DEFINITIONS(
100   $${QT_DEFINITIONS}
101   $${OMNIORB_DEFINITIONS}
102   $${KERNEL_DEFINITIONS}
103   $${GUI_DEFINITIONS}
104 )
105
106 # libraries to link to
107 SET(_link_LIBRARIES
108   $${QT_LIBRARIES}
109   SalomeIDL${module}
110   ${libs}
111 )
112
113 # --- resources ---
114
115 # resource files / to be processed by uic
116 SET(_uic_files
117   ${uic_files}
118 )
119
120 # --- headers ---
121
122 # header files / to be processed by moc
123 SET(_moc_HEADERS
124   ${moc_headers}
125 )
126
127 # header files / uic wrappings
128 QT_WRAP_UIC(_uic_HEADERS $${_uic_files})
129
130 # --- sources ---
131
132 # sources / moc wrappings
133 QT_WRAP_MOC(_moc_SOURCES $${_moc_HEADERS})  
134
135 # sources / static
136 SET(_other_SOURCES
137   ${sources}
138 )
139
140 # sources / to compile
141 SET(${module}GUI_SOURCES 
142   $${_other_SOURCES}
143   $${_moc_SOURCES}
144   $${_uic_files}
145 )
146
147 # --- resources ---
148
149 # resource files / to be processed by lrelease
150 SET(_ts_files
151   ${ts_resources}
152
153
154 SET(_res_files
155   SalomeApp.xml
156   ${resources}
157
158
159 # --- rules ---
160
161 ADD_LIBRARY(${module} $${${module}GUI_SOURCES})
162 TARGET_LINK_LIBRARIES(${module} $${_link_LIBRARIES} )
163 INSTALL(TARGETS ${module} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS})
164
165 INSTALL(FILES $${_moc_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS})
166 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
167 QT_INSTALL_TS_RESOURCES("$${_ts_files}" "$${SALOME_${module}_INSTALL_RES_DATA}")
168 """
169 cmake_cpp_gui = Template(cmake_cpp_gui)
170
171 # CMakeLists.txt for a python GUI (src/{module}GUI/CMakeLists.txt)
172 # template parameters:
173 #   module : module name
174 #   scripts : .py files
175 #   ts_resources : .ts files - to be processed by lrelease
176 #   resources : other resource files
177 cmake_py_gui = """
178 INCLUDE(UseQtExt)
179
180 # additional include directories
181 INCLUDE_DIRECTORIES(
182   $${QT_INCLUDES}
183 )
184
185 # --- scripts ---
186
187 # scripts / static
188 SET(_bin_SCRIPTS
189   ${scripts}
190 )
191
192 # --- resources ---
193
194 # resource files / to be processed by lrelease
195 SET(_ts_RESOURCES
196   ${ts_resources}
197 )
198
199 SET(_res_files
200   SalomeApp.xml
201   ${resources}
202 )
203
204 # --- rules ---
205
206 SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON})
207 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
208 QT_INSTALL_TS_RESOURCES("$${_ts_RESOURCES}" "$${SALOME_${module}_INSTALL_RES_DATA}")
209 """
210 cmake_py_gui = Template(cmake_py_gui)