Mercurial > projects > qtd
annotate generator/CMakeLists.txt @ 27:a9626891eca6
CMake: generator will work only for needed packages.
CMake: check for depends packages.
CMake: add options 'QT_BUILD_PACKAGE'. Now you can build only needed packages.
author | SokoL_SD |
---|---|
date | Fri, 15 May 2009 16:42:02 +0000 |
parents | 907d517d37c6 |
children | 10baf869635a |
rev | line source |
---|---|
4 | 1 PROJECT(generator CXX C) |
2 cmake_minimum_required(VERSION 2.6) | |
3 FIND_PACKAGE(Qt4 REQUIRED) | |
4 | |
5 ## Sources | |
6 set(srcs | |
7 classlistgenerator.cpp | |
8 cppgenerator.cpp | |
9 cppheadergenerator.cpp | |
10 cppimplgenerator.cpp | |
11 docparser.cpp | |
12 generatorsetd.cpp | |
13 dgenerator.cpp | |
14 jumptable.cpp | |
15 metainfogenerator.cpp | |
16 metajavabuilder.cpp | |
17 qdocgenerator.cpp | |
18 uiconverter.cpp | |
19 containergenerator.cpp | |
20 | |
21 generator.cpp | |
22 main.cpp | |
23 reporthandler.cpp | |
24 typeparser.cpp | |
25 typesystem.cpp | |
26 asttoxml.cpp | |
27 fileout.cpp | |
28 generatorset.cpp | |
29 metajava.cpp | |
30 customtypes.cpp | |
31 abstractmetabuilder.cpp | |
32 abstractmetalang.cpp | |
33 prigenerator.cpp | |
34 | |
35 # rxx | |
36 parser/ast.cpp | |
37 parser/lexer.cpp | |
38 parser/list.cpp | |
39 parser/parser.cpp | |
40 parser/smallobject.cpp | |
41 parser/control.cpp | |
42 parser/visitor.cpp | |
43 parser/default_visitor.cpp | |
44 parser/dumptree.cpp | |
45 parser/tokens.cpp | |
46 parser/binder.cpp | |
47 parser/codemodel.cpp | |
48 parser/type_compiler.cpp | |
49 parser/name_compiler.cpp | |
50 parser/declarator_compiler.cpp | |
51 parser/class_compiler.cpp | |
52 parser/codemodel_finder.cpp | |
53 parser/compiler_utils.cpp | |
54 | |
55 ## rpp | |
56 parser/rpp/preprocessor.cpp | |
57 ) | |
58 ## Moc headers | |
59 set(moc_hdrs | |
60 classlistgenerator.h | |
61 cppgenerator.h | |
62 cppheadergenerator.h | |
63 cppimplgenerator.h | |
64 docparser.h | |
65 generatorsetd.h | |
66 dgenerator.h | |
67 jumptable.h | |
68 metainfogenerator.h | |
69 metajavabuilder.h | |
70 qdocgenerator.h | |
71 uiconverter.h | |
72 containergenerator.h | |
73 generator.h | |
74 main.h | |
75 reporthandler.h | |
76 typeparser.h | |
77 typesystem.h | |
78 asttoxml.h | |
79 fileout.h | |
80 generatorset.h | |
81 metajava.h | |
82 customtypes.h | |
83 abstractmetabuilder.h | |
84 abstractmetalang.h | |
85 prigenerator.h | |
86 | |
87 ## rxx | |
88 parser/ast.h | |
89 parser/lexer.h | |
90 parser/list.h | |
91 parser/parser.h | |
92 parser/rxx_allocator.h | |
93 parser/rpp-allocator.h | |
94 parser/smallobject.h | |
95 parser/tokens.h | |
96 parser/symbol.h | |
97 parser/control.h | |
98 parser/visitor.h | |
99 parser/default_visitor.h | |
100 parser/dumptree.h | |
101 parser/binder.h | |
102 parser/codemodel.h | |
103 parser/codemodel_pointer.h | |
104 parser/codemodel_fwd.h | |
105 parser/type_compiler.h | |
106 parser/name_compiler.h | |
107 parser/declarator_compiler.h | |
108 parser/class_compiler.h | |
109 parser/codemodel_finder.h | |
110 parser/compiler_utils.h | |
111 | |
112 # rpp | |
113 parser/rpp/pp-cctype.h | |
114 parser/rpp/pp-engine-bits.h | |
115 parser/rpp/pp-engine.h | |
116 parser/rpp/pp-environment.h | |
117 parser/rpp/pp-fwd.h | |
118 parser/rpp/pp-internal.h | |
119 parser/rpp/pp-iterator.h | |
120 parser/rpp/pp-macro-expander.h | |
121 parser/rpp/pp-macro.h | |
122 parser/rpp/pp-scanner.h | |
123 parser/rpp/pp-string.h | |
124 parser/rpp/pp-symbol.h | |
125 parser/rpp/pp.h | |
126 parser/rpp/preprocessor.h | |
127 | |
128 ) | |
129 | |
130 ## Resources. | |
131 set(res_files | |
132 generator.qrc | |
133 ) | |
134 | |
135 #win32-msvc2005:{ | |
136 # QMAKE_CXXFLAGS += -wd4996 | |
137 # QMAKE_CFLAGS += -wd4996 | |
138 #} | |
139 | |
140 #win32-msvc.net { | |
141 # QMAKE_CXXFLAGS += /Zm500 | |
142 # QMAKE_CXXFLAGS -= -Zm200 | |
143 # QMAKE_CFLAGS -= -Zm200 | |
144 #} | |
145 | |
146 ## Includes path. | |
147 set(inc_paths | |
23 | 148 ${CMAKE_CURRENT_SOURCE_DIR}/../common |
4 | 149 ${CMAKE_CURRENT_SOURCE_DIR}/parser |
23 | 150 ${CMAKE_CURRENT_SOURCE_DIR} |
151 ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp | |
152 #${CMAKE_CURRENT_SOURCE_DIR}/parser/include | |
4 | 153 ) |
154 | |
155 add_definitions(-DRXX_ALLOCATOR_INIT_0) | |
156 | |
157 ## Build project | |
158 find_package (Qt4 REQUIRED) | |
159 set (QT_USE_QTMAIN true) | |
160 set (QT_USE_QTGUI false) | |
161 set (QT_USE_QTXML true) | |
162 include(${QT_USE_FILE} ${CMAKE_CURRENT_SOURCE_DIR}) | |
163 | |
164 set(inc_paths | |
165 ${inc_paths} | |
166 ${QT_INCLUDES} | |
167 ) | |
168 set(lib_paths | |
169 ${lib_paths} | |
170 ${QT_LIBRARY_DIR} | |
171 ) | |
172 set(libs | |
173 ${QT_LIBRARIES} | |
174 ) | |
175 | |
176 qt4_wrap_cpp(moc_srcs ${moc_hdrs}) | |
177 qt4_add_resources(res_wrapped_files ${res_files}) | |
178 | |
179 set (all_srcs | |
180 ${srcs} ${moc_srcs} | |
181 ${res_wrapped_files}) | |
182 include_directories(${inc_paths}) | |
183 add_executable(generator ${all_srcs} ) | |
184 target_link_libraries(generator ${libs}) | |
185 | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
186 macro(add_dgen_target package) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
187 string(TOLOWER ${package} package) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
188 set(dgen_build_conf ${CMAKE_BINARY_DIR}/CMakeFiles/built_${package}.txt) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
189 set(dgen_build_conf_req ${CMAKE_BINARY_DIR}/CMakeFiles/built_${package}_with_req.txt) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
190 file(REMOVE ${dgen_build_conf}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
191 file(REMOVE ${dgen_build_conf_req}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
192 file(APPEND ${dgen_build_conf} "<typesystem>\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
193 file(APPEND ${dgen_build_conf_req} "<typesystem>\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
194 foreach(req ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
195 string(TOLOWER ${req} req_lower) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
196 file(APPEND ${dgen_build_conf} " <load-typesystem name=\"typesystem_${req_lower}.xml\" generate=\"no\" />\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
197 file(APPEND ${dgen_build_conf_req} " <load-typesystem name=\"typesystem_${req_lower}.xml\" generate=\"yes\" />\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
198 endforeach(req ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
199 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
200 if(${package} STREQUAL "all") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
201 foreach(pack ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
202 set(dgen_impl ${CMAKE_BINARY_DIR}/cpp/qt_${pack}/metainfo.cpp) ## Temporary |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
203 break(pack ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
204 endforeach(pack ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
205 else(${package} STREQUAL "all") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
206 set(dgen_impl ${CMAKE_BINARY_DIR}/cpp/qt_${package}/qt_${package}.pri) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
207 set(gen_sources ${gen_sources} ${CMAKE_SOURCE_DIR}/generator/typesystem_${package}.xml |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
208 ${CMAKE_SOURCE_DIR}/generator/typesystem_${package}-java.java) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
209 file(APPEND ${dgen_build_conf} " <load-typesystem name=\"typesystem_${package}.xml\" generate=\"yes\" />\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
210 file(APPEND ${dgen_build_conf_req} " <load-typesystem name=\"typesystem_${package}.xml\" generate=\"yes\" />\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
211 endif(${package} STREQUAL "all") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
212 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
213 file(APPEND ${dgen_build_conf} "</typesystem>\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
214 file(APPEND ${dgen_build_conf_req} "</typesystem>\n") |
4 | 215 |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
216 foreach(pack ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
217 string(TOLOWER ${pack} pack_lower) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
218 set(gen_sources ${gen_sources} ${CMAKE_SOURCE_DIR}/generator/typesystem_${pack_lower}.xml |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
219 ${CMAKE_SOURCE_DIR}/generator/typesystem_${pack_lower}-java.java) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
220 endforeach(pack ${ARGN}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
221 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
222 add_custom_command(OUTPUT ${dgen_impl} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
223 COMMAND ${CMAKE_COMMAND} -E remove -f ${dgen_impl} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
224 COMMAND "generator" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
225 ARGS ${GEN_OPT} --no-repreprocess --qt-include-directory=${QT_INCLUDE_DIR} --output-directory=./ |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
226 --source-directory=${CMAKE_SOURCE_DIR}/generator |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
227 qtjambi_masterinclude.h |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
228 ${dgen_build_conf} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
229 COMMENT "Generating binding..." |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
230 DEPENDS generator ${gen_sources} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
231 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
232 add_custom_target(dgen_${package} DEPENDS ${dgen_impl} COMMENT "") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
233 endmacro(add_dgen_target target package required) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
234 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
235 foreach(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
236 set(dgen_impl ${CMAKE_BINARY_DIR}/cpp/qt_${pack}/qt_${pack}.pri) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
237 break(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
238 endforeach(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
239 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
240 foreach(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
241 set(gen_typesystem ${gen_typesystem} ${CMAKE_SOURCE_DIR}/generator/typesystem_${pack}.xml) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
242 set(gen_sources ${gen_sources} ${CMAKE_SOURCE_DIR}/generator/typesystem_${pack}-java.java) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
243 endforeach(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
244 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
245 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
246 set(dgen_build_conf ${CMAKE_BINARY_DIR}/CMakeFiles/built.txt) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
247 file(REMOVE ${dgen_build_conf}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
248 file(APPEND ${dgen_build_conf} "<typesystem>\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
249 foreach(package ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
250 file(APPEND ${dgen_build_conf} " <load-typesystem name=\"typesystem_${package}.xml\" generate=\"yes\" />\n") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
251 endforeach(package ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
252 file(APPEND ${dgen_build_conf} "</typesystem>\n") |
4 | 253 |
254 add_custom_command(OUTPUT ${dgen_impl} | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
255 COMMAND ${CMAKE_COMMAND} -E remove -f ${dgen_impl} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
256 COMMAND "generator" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
257 ARGS ${GEN_OPT} --qt-include-directory=${QT_INCLUDE_DIR} --output-directory=${CMAKE_BINARY_DIR} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
258 --source-directory=${CMAKE_SOURCE_DIR}/generator |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
259 qtjambi_masterinclude.h |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
260 ${dgen_build_conf} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
261 COMMENT "Generating binding..." |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
262 DEPENDS generator ${gen_typesystem} ${gen_sources} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
23
diff
changeset
|
263 ) |
4 | 264 add_custom_target(dgen DEPENDS ${dgen_impl} COMMENT "") |
265 | |
266 macro(add_sources_for_generating) | |
267 foreach(source ${ARGN}) | |
268 add_custom_command(OUTPUT "${source}" | |
269 COMMAND "" | |
270 ARGS "" | |
271 DEPENDS ${dgen_impl} | |
272 COMMENT "" | |
273 ) | |
274 endforeach(source ${allcppsources}) | |
275 endmacro(add_sources_for_generating) |