Mercurial > projects > qtd
comparison CMakeLists.txt @ 59:17165763b300
CMake: build QtD tools.
author | SokoL_SD |
---|---|
date | Tue, 19 May 2009 08:30:31 +0000 |
parents | 63c31e221118 |
children | fbf7881c8b0f |
comparison
equal
deleted
inserted
replaced
58:423e4afb245c | 59:17165763b300 |
---|---|
8 | 8 |
9 include_directories(${QT_INCLUDES} include ${CMAKE_CURRENT_BINARY_DIR}/include) | 9 include_directories(${QT_INCLUDES} include ${CMAKE_CURRENT_BINARY_DIR}/include) |
10 | 10 |
11 ## Options. | 11 ## Options. |
12 option(BUILD_EXAMPLES "Build examples" "ON") | 12 option(BUILD_EXAMPLES "Build examples" "ON") |
13 option(BUILD_TOOLS "Build tools" "ON") | |
13 option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") | 14 option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") |
14 | 15 |
15 set(all_packages Core Gui OpenGL Xml Svg Network WebKit) ## TODO: Loading. | 16 set(all_packages Core Gui OpenGL Xml Svg Network WebKit) ## TODO: Loading. |
16 | 17 |
17 | 18 |
154 set(D_OBJECT_SUFFIX .o) | 155 set(D_OBJECT_SUFFIX .o) |
155 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | 156 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
156 | 157 |
157 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) | 158 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) |
158 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) | 159 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) |
160 | |
161 ## Bootstrap settings for tools. | |
162 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc) | |
159 | 163 |
160 ##-------------------------------------------- | 164 ##-------------------------------------------- |
161 ## Macroses and functions. | 165 ## Macroses and functions. |
162 ##-------------------------------------------- | 166 ##-------------------------------------------- |
163 | 167 |
264 ) | 268 ) |
265 endif(NOT SINGLE_D_OBJECT) | 269 endif(NOT SINGLE_D_OBJECT) |
266 add_custom_target(${target} DEPENDS "${${objects_list}}") | 270 add_custom_target(${target} DEPENDS "${${objects_list}}") |
267 endmacro(compile_d_files objects_list) | 271 endmacro(compile_d_files objects_list) |
268 | 272 |
273 macro(qtd_add_resource name output) | |
274 set(${output}) | |
275 foreach(res "${ARGN}") | |
276 ## Test input file exists. | |
277 get_filename_component(res_path ${res} PATH) | |
278 get_filename_component(res_name ${res} NAME_WE) | |
279 get_filename_component(res_ext ${res} EXT) | |
280 #if(NOT ${req_ext} STREQUAL "qrc") | |
281 # get_filename_component(res_name ${res} NAME_WE) | |
282 #endif(NOT ${req_ext} STREQUAL "qrc") | |
283 set(out ${CMAKE_CURRENT_BINARY_DIR}/${res_path}qrc_${res_name}.d) | |
284 add_custom_command(OUTPUT "${out}" | |
285 COMMAND "${DRCC}" | |
286 ARGS -name ${name} ${res} -o ${out} | |
287 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
288 DEPENDS ${res} | |
289 COMMENT "Compile QtD resource ${res}" | |
290 ) | |
291 set(${output} ${${output}} ${out}) | |
292 endforeach(res "${ARGN}") | |
293 endmacro(qtd_add_resource output) | |
294 | |
269 ## Build example macro. | 295 ## Build example macro. |
270 ## name -- example name. | 296 ## name -- example name. |
271 ## Options: | 297 ## Options: |
272 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL). | 298 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL). |
273 ## Default value is "QtCore QtGui". | 299 ## Default value is "QtCore QtGui". |
274 ## params -- sources d files. | 300 ## params -- sources d files. |
275 ## Usage: | 301 ## Usage: |
276 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) | 302 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) |
277 macro(build_example name) | 303 macro(build_example name) |
278 set(is_sources) | |
279 set(is_libs) | |
280 set(qtd_libs ${core_lib_param} ${gui_lib_param}) | 304 set(qtd_libs ${core_lib_param} ${gui_lib_param}) |
281 set(reqs Core Gui) | 305 set(type_dat SOURCES) |
282 foreach(param ${ARGN}) | 306 set(RESOURCES) |
283 if(is_libs) | 307 set(SOURCES) |
284 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" param_package "${param}") | 308 set(PACKAGES) |
285 if(${param_package} STREQUAL ${param}) | 309 ## Parse parameters list. |
286 set(is_libs) | 310 set(params_dat RESOURCES SOURCES PACKAGES) |
287 set(is_sources 1) | 311 foreach(arg_dat ${ARGN}) |
288 else(${param_package} STREQUAL ${param}) | 312 set(founded_type_dat) |
289 set(reqs ${reqs} ${param_package}) | 313 foreach(param_dat ${params_dat}) |
290 endif(${param_package} STREQUAL ${param}) | 314 if(${arg_dat} STREQUAL ${param_dat}) |
291 endif(is_libs) | 315 set(type_dat ${param_dat}) |
292 if(NOT is_libs) | 316 set(founded_type_dat 1) |
293 if(NOT is_sources) | 317 break(${arg_dat} STREQUAL ${param_dat}) |
294 if(${param} STREQUAL PACKAGES) | 318 endif(${arg_dat} STREQUAL ${param_dat}) |
295 set(is_libs 1) | 319 endforeach(param_dat ${params_dat}) |
296 set(reqs) | 320 if(NOT founded_type_dat) |
297 else(${param} STREQUAL PACKAGES) | 321 set(${type_dat} ${${type_dat}} ${arg_dat}) |
298 set(is_sources 1) | 322 endif(NOT founded_type_dat) |
299 endif(${param} STREQUAL PACKAGES) | 323 endforeach(arg_dat ${ARGN}) |
300 endif(NOT is_sources) | 324 if(NOT PACKAGES) |
301 if(is_sources) | 325 set(PACKAGES QtCore QtGui) |
302 set(sources ${sources} ${param}) | 326 endif(NOT PACKAGES) |
303 endif(is_sources) | 327 ## TODO: Tools building is acitve??? |
304 endif(NOT is_libs) | 328 if(RESOURCES) |
305 endforeach(param ${ARGN}) | 329 if(NOT BUILD_TOOLS) |
306 compile_d_files(${name}_dobjs objects ${sources} ) | 330 message(STATUS "Example '${name}' required drcc. Example will not build") |
331 return(build_example name) | |
332 endif(NOT BUILD_TOOLS) | |
333 qtd_add_resource(${name} res_sources ${RESOURCES}) | |
334 endif(RESOURCES) | |
335 compile_d_files(${name}_dobjs objects ${SOURCES} ${res_sources}) | |
307 set(output ${CMAKE_CURRENT_BINARY_DIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}) | 336 set(output ${CMAKE_CURRENT_BINARY_DIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}) |
308 set(output_native ${output}) | 337 set(output_native ${output}) |
309 make_native_path(output_native) | 338 make_native_path(output_native) |
310 foreach(req ${reqs}) | 339 foreach(package ${PACKAGES}) |
340 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") | |
311 set(is_founded) | 341 set(is_founded) |
312 foreach(package_big ${packages_big}) | 342 foreach(package_big ${packages_big}) |
313 string(TOLOWER ${package_big} package) | 343 string(TOLOWER ${package_big} package) |
314 if(${req} STREQUAL ${package_big}) | 344 if(${req} STREQUAL ${package_big}) |
315 set(is_founded 1) | 345 set(is_founded 1) |
320 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build") | 350 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build") |
321 return(build_example name) | 351 return(build_example name) |
322 else(NOT is_founded) | 352 else(NOT is_founded) |
323 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) | 353 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) |
324 endif(NOT is_founded) | 354 endif(NOT is_founded) |
325 endforeach(req ${reqs}) | 355 endforeach(package ${PACKAGES}) |
326 add_custom_command(OUTPUT "${output}" | 356 add_custom_command(OUTPUT "${output}" |
327 COMMAND "${DC}" | 357 COMMAND "${DC}" |
328 ARGS ${D_FLAGS} ${libs_path} ${qtd_libs} ${objects} | 358 ARGS ${D_FLAGS} ${libs_path} ${qtd_libs} ${objects} |
329 -of${output_native} | 359 -of${output_native} |
330 DEPENDS ${objects} | 360 DEPENDS ${objects} |
342 ##-------------------------------------------- | 372 ##-------------------------------------------- |
343 ## Build and install library. | 373 ## Build and install library. |
344 ##-------------------------------------------- | 374 ##-------------------------------------------- |
345 | 375 |
346 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | 376 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
347 add_custom_target(allpackages ALL) | 377 add_custom_target(allpackages) |
348 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | 378 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) |
349 | 379 |
350 foreach(package_big ${all_packages}) | 380 foreach(package_big ${all_packages}) |
351 string(TOLOWER ${package_big} package) | 381 string(TOLOWER ${package_big} package) |
352 ## Loading settings for package. | 382 ## Loading settings for package. |
587 | 617 |
588 | 618 |
589 ##-------------------------------------------- | 619 ##-------------------------------------------- |
590 ## Build other parts of the QtD. | 620 ## Build other parts of the QtD. |
591 ##-------------------------------------------- | 621 ##-------------------------------------------- |
622 add_custom_target(tools ALL) | |
623 if(BUILD_TOOLS) | |
624 add_subdirectory(tools) | |
625 add_dependencies(tools drcc duic) | |
626 endif(BUILD_TOOLS) | |
627 | |
592 if(BUILD_EXAMPLES) | 628 if(BUILD_EXAMPLES) |
593 add_subdirectory(demos) | 629 add_subdirectory(demos) |
594 add_subdirectory(examples) | 630 add_subdirectory(examples) |
595 endif(BUILD_EXAMPLES) | 631 endif(BUILD_EXAMPLES) |
596 | 632 |