comparison CMakeLists.txt @ 344:96a75b1e5b26

project structure changes
author Max Samukha <maxter@spambox.com>
date Fri, 14 May 2010 12:14:37 +0300
parents baaf74652f4c
children 9784459f0750
comparison
equal deleted inserted replaced
343:552647ec0f82 344:96a75b1e5b26
1 cmake_minimum_required(VERSION 2.6) 1 cmake_minimum_required(VERSION 2.6)
2 PROJECT(qtd CXX C) 2 PROJECT(qtd CXX C)
3
4 ##########################################################
5 ## Build generator.
6 ##########################################################
7 if(NOT SECOND_RUN)
8
9 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF")
10 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
11 message(FATAL_ERROR "In-source builds are not allowed.
12 Please create a directory and run cmake from there, passing the path
13 to this source directory as the last argument.
14 This process created the file `CMakeCache.txt` and the directory `CMakeFiles'.
15 Please delete them.
16
17 Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not
18 recommended.
19 ")
20 endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
21
22 FIND_PACKAGE(Qt4 REQUIRED)
23 set (QT_USE_QTMAIN false)
24 set (QT_USE_QTGUI false)
25
26 ##--------------------------------------------
27 ## Settings.
28 ##--------------------------------------------
29
30 ## Options.
31 option(BUILD_EXAMPLES "Build examples" "OFF")
32 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF")
33 option(BUILD_TOOLS "Build tools" "ON")
34 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF")
35 set(GENERATE_DI_FILES OFF) ## Very experemental option. Temporary disabled.
36 option(VERBOSE_DEBUG "Verbose debug" "OFF")
37
38 set(all_packages Core Gui OpenGL Xml Svg Network WebKit CACHE INTERNAL "")
39
40 ## Init D toolkit.
41 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
42 FIND_PACKAGE(D REQUIRED)
43
44 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
45 set(CMAKE_INSTALL_PREFIX
46 ${DC_PATH} CACHE PATH "QtD install prefix"
47 )
48 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
49
50 # Check D compiler version
51 if(D_VERSION EQUAL "1")
52 if (D_FRONTEND LESS "050")
53 message(STATUS "Minimum required version of D compiler is 1.050 (or compiler based on this version)")
54 endif(D_FRONTEND LESS "050")
55 set(D_TARGET d1-tango CACHE INTERNAL "")
56 elseif(D_VERSION EQUAL "2")
57 set(D_TARGET d2-phobos CACHE INTERNAL "")
58 endif(D_VERSION EQUAL "1")
59 3
60 # Debug and release flags. 4 # Debug and release flags.
61 if (NOT CMAKE_BUILD_TYPE) 5 if (NOT CMAKE_BUILD_TYPE)
62 set(CMAKE_BUILD_TYPE Release) 6 set(CMAKE_BUILD_TYPE Release)
63 endif (NOT CMAKE_BUILD_TYPE) 7 endif (NOT CMAKE_BUILD_TYPE)
8
64 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 9 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
65 set(CMAKE_BUILD_TYPE Debug) 10 set(CMAKE_BUILD_TYPE Debug)
66 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) 11 #set( SUFFIXLIB "${SUFFIXLIB}-debug" )
67 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) 12 #set( SUFFIXBIN "${SUFFIXBIN}-debug" )
68 add_definitions(-DDEBUG) 13 add_definitions(-DDEBUG)
69 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) 14 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
70 message(STATUS "Only debug and release configurations are supproted. The configuration is changed to 'Release'") 15 message(STATUS "Only debug and release configurations are supproted. The configuration is changed to 'Release'")
71 set(CMAKE_BUILD_TYPE Release) 16 set(CMAKE_BUILD_TYPE Release)
72 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 17 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
18
73 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) 19 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
74 #add_definitions(-UNO_DEBUG) 20 #add_definitions(-UNO_DEBUG)
75 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] ) 21 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] )
22
23 ##########################################################
24 ## Build generator.
25 ##########################################################
26 if (NOT SECOND_RUN)
27
28 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF")
29 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
30 message(FATAL_ERROR "In-source builds are not allowed. "
31 "Please create a directory and run cmake from there, passing the path"
32 "to this source directory as the last argument. "
33 "This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. Please delete them. "
34 "Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not recommended."
35 )
36 endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
37
38 FIND_PACKAGE(Qt4 REQUIRED)
39 set(QT_USE_QTMAIN false)
40 set(QT_USE_QTGUI false)
41
42 ##--------------------------------------------
43 ## Settings.
44 ##--------------------------------------------
45
46 ## Options.
47 option(BUILD_EXAMPLES "Build examples" "OFF")
48 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF")
49 option(BUILD_TOOLS "Build tools" "ON")
50 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF")
51 set(GENERATE_DI_FILES OFF) ## Very experimental option. Temporarily disabled.
52 option(VERBOSE_DEBUG "Verbose debug" "OFF")
53
54 set(all_packages Core Gui OpenGL Xml Svg Network WebKit CACHE INTERNAL "")
55
56 ## Init D toolkit.
57 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
58 FIND_PACKAGE(D REQUIRED)
59
60 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
61 set(CMAKE_INSTALL_PREFIX
62 ${DC_PATH} CACHE PATH "QtD install prefix"
63 )
64 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
65
66 # Check D compiler version
67 if(D_VERSION EQUAL "1")
68 if (D_FRONTEND LESS "050")
69 message(STATUS "Minimum required version of D compiler is 1.050 (or compiler based on this version)")
70 endif(D_FRONTEND LESS "050")
71 set(D_TARGET d1-tango CACHE INTERNAL "")
72 elseif(D_VERSION EQUAL "2")
73 set(D_TARGET d2-phobos CACHE INTERNAL "")
74 endif(D_VERSION EQUAL "1")
76 75
77 # System specific settings. 76 # System specific settings.
78 if(CMAKE_HOST_WIN32) 77 if(CMAKE_HOST_WIN32)
79 set(implib implib) 78 set(implib implib)
80 find_program(IMPLIB ${implib}) 79 find_program(IMPLIB ${implib})
81 if (NOT IMPLIB) 80 if (NOT IMPLIB)
82 message(FATAL_ERROR "implib is not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") 81 message(FATAL_ERROR "implib is not found. You can donwload it from http://ftp.digitalmars.com/bup.zip")
83 endif (NOT IMPLIB) 82 endif (NOT IMPLIB)
84 if(D_IS_MARS) 83 if(D_IS_MARS)
85 set(GEN_OPT ${GEN_OPT} --cpp_shared) 84 set(GEN_OPT ${GEN_OPT} --cpp_shared)
86 add_definitions(-DCPP_SHARED) 85 add_definitions(-DCPP_SHARED)
87 endif(D_IS_MARS) 86 endif(D_IS_MARS)
88 endif(CMAKE_HOST_WIN32) 87 endif(CMAKE_HOST_WIN32)
89 88
90 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) 89 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./)
91 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) 90 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET})
92 91
93 set(packages CACHE INTERNAL "") 92 set(packages CACHE INTERNAL "")
94 foreach(package_big ${all_packages}) 93 foreach(package_big ${all_packages})
95 string(TOLOWER ${package_big} package) 94 string(TOLOWER ${package_big} package)
96 string(TOUPPER ${package_big} package_upper) 95 string(TOUPPER ${package_big} package_upper)
97 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON") 96 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON")
98 if(BUILD_QT_${package_upper}) 97 if(BUILD_QT_${package_upper})
99 set(packages ${packages} ${package_big}) 98 set(packages ${packages} ${package_big})
100 endif(BUILD_QT_${package_upper}) 99 endif(BUILD_QT_${package_upper})
101 endforeach(package_big ${all_packages}) 100 endforeach(package_big ${all_packages})
102 101
103 add_subdirectory(generator) 102 add_subdirectory(generator)
104 103
119 else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) 118 else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
120 set(cd_path ${CMAKE_BINARY_DIR}/build) 119 set(cd_path ${CMAKE_BINARY_DIR}/build)
121 endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) 120 endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
122 121
123 make_native_path(cd_path) 122 make_native_path(cd_path)
124 add_custom_command(TARGET main POST_BUILD 123 add_custom_command(TARGET main POST_BUILD
125 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build 124 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build
126 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} 125 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util}
127 COMMENT "" 126 COMMENT ""
128 ) 127 )
129 128
130 ## "Make install" command. 129 ## "Make install" command.
131 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) 130 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build)
132 add_custom_target(install 131 add_custom_target(install
133 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install 132 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install
134 COMMENT "" 133 COMMENT ""
135 ) 134 )
136 add_dependencies(install preinstall) 135 add_dependencies(install preinstall)
137 136
138 ##-------------------------------------------- 137 ##--------------------------------------------
139 ## CPack. 138 ## CPack.
140 ##-------------------------------------------- 139 ##--------------------------------------------
141 set(CPACK_PACKAGE_VERSION_PATCH 1) 140 set(CPACK_PACKAGE_VERSION_PATCH 1)
142 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework. 141 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework.
143 This package installs binding and static library for qt port on D programming language. 142 This package installs binding and static library for qt port on D programming language.
144 ") 143 ")
145 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") 144 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt")
146 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") 145 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt")
147 set(CPACK_PACKAGE_VENDOR "QtD team") 146 set(CPACK_PACKAGE_VENDOR "QtD team")
176 include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) 175 include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
177 176
178 # System specifc settings. 177 # System specifc settings.
179 if(CMAKE_HOST_WIN32) 178 if(CMAKE_HOST_WIN32)
180 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") 179 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
181 endif(CMAKE_HOST_WIN32) 180 endif(CMAKE_HOST_WIN32)
182 181
183 if(CMAKE_HOST_WIN32 AND D_IS_MARS) 182 if(CMAKE_HOST_WIN32 AND D_IS_MARS)
184 set(CPP_SHARED 1 CACHE INTERNAL "") 183 set(CPP_SHARED 1 CACHE INTERNAL "")
185 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) 184 endif(CMAKE_HOST_WIN32 AND D_IS_MARS)
186 185
187 if(D_IS_MARS) 186 if(D_IS_MARS)
188 set(D_FLAGS -version=cpp_shared) 187 set(D_FLAGS -version=cpp_shared)
189 add_definitions(-DCPP_SHARED) 188 add_definitions(-DCPP_SHARED)
190 endif(D_IS_MARS) 189 endif(D_IS_MARS)
191 190
192 if(UNITTEST) 191 if(UNITTEST)
193 add_d_versions(QtdUnittest) 192 add_d_versions(QtdUnittest)
193 set(D_FLAGS ${D_FLAGS} -unittest)
194 endif(UNITTEST) 194 endif(UNITTEST)
195 195
196 if(VERBOSE_DEBUG) 196 if(VERBOSE_DEBUG)
197 add_d_debugs(QtdVerbose) 197 add_d_debugs(QtdVerbose)
198 endif(VERBOSE_DEBUG) 198 endif(VERBOSE_DEBUG)
199 199
200 if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
201 add_d_debugs(QtdDebug)
202 endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
203
200 ## Bootstrap settings for QtD. 204 ## Bootstrap settings for QtD.
201 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc CACHE INTERNAL "") 205 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc CACHE INTERNAL "")
202 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "") 206 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "")
203 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION} CACHE INTERNAL "") 207 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/d${D_VERSION} CACHE INTERNAL "")
204 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "") 208 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "")
205 209
206 ##-------------------------------------------- 210 ##--------------------------------------------
207 ## Macros and functions. 211 ## Macros and functions.
208 ##-------------------------------------------- 212 ##--------------------------------------------
213 217
214 macro(qtd_add_resource output) 218 macro(qtd_add_resource output)
215 set (params NAME OPTIONS) 219 set (params NAME OPTIONS)
216 qtd_parse_params (RESOURCES params ${ARGN}) 220 qtd_parse_params (RESOURCES params ${ARGN})
217 if(NAME_tmp) 221 if(NAME_tmp)
218 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp}) 222 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp})
219 endif(NAME_tmp) 223 endif(NAME_tmp)
220 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" 224 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_"
221 "Generate" ${RESOURCES_tmp}) 225 "Generate" ${RESOURCES_tmp})
222 endmacro(qtd_add_resource output) 226 endmacro(qtd_add_resource output)
223 227
224 macro(qtd_wrap_ui output) 228 macro(qtd_wrap_ui output)
225 set (params OPTIONS) 229 set (params OPTIONS)
226 qtd_parse_params (UI params ${ARGN}) 230 qtd_parse_params (UI params ${ARGN})
227 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" 231 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_"
228 "Generate" ${UI_tmp}) 232 "Generate" ${UI_tmp})
229 endmacro(qtd_wrap_ui output) 233 endmacro(qtd_wrap_ui output)
230 234
231 macro(qtd_command output command options prefix comment) 235 macro(qtd_command output command options prefix comment)
232 foreach(file "${ARGN}") 236 foreach(file "${ARGN}")
233 ## Test an exist of the input file. 237 ## Test if the input file exists
234 get_filename_component(file_path ${file} PATH) 238 get_filename_component(file_path ${file} PATH)
235 get_filename_component(file_name ${file} NAME_WE) 239 get_filename_component(file_name ${file} NAME_WE)
236 get_filename_component(file_ext ${file} EXT) 240 get_filename_component(file_ext ${file} EXT)
237 241
238 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) 242 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d)
239 add_custom_command(OUTPUT "${out}" 243 add_custom_command(OUTPUT "${out}"
240 COMMAND "${command}" 244 COMMAND "${command}"
241 ARGS ${options} ${file} -o ${out} 245 ARGS ${options} ${file} -o ${out}
242 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 246 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
243 DEPENDS ${file} 247 DEPENDS ${file}
244 COMMENT "${comment} ${file}" 248 COMMENT "${comment} ${file}"
245 ) 249 )
246 set(${output} ${${output}} ${out}) 250 set(${output} ${${output}} ${out})
247 endforeach(file "${ARGN}") 251 endforeach(file "${ARGN}")
248 endmacro(qtd_command output command options files prefix comment) 252 endmacro(qtd_command output command options files prefix comment)
249 253
250 ## Parses the parameters list. 254 ## Parses the parameters list.
251 macro(qtd_parse_params default params) 255 macro(qtd_parse_params default params)
252 set(type_tmp ${default}) 256 set(type_tmp ${default})
253 set(params_tmp ${default} ${${params}}) 257 set(params_tmp ${default} ${${params}})
254 foreach(param_tmp ${params_tmp}) 258 foreach(param_tmp ${params_tmp})
255 set(${param_tmp}_tmp ) 259 set(${param_tmp}_tmp )
256 endforeach(param_tmp ${params_tmp}) 260 endforeach(param_tmp ${params_tmp})
257 foreach(arg_tmp ${ARGN}) 261 foreach(arg_tmp ${ARGN})
258 set(found_type_tmp) 262 set(found_type_tmp)
259 if(NOT found_type_tmp) 263 if(NOT found_type_tmp)
260 foreach(param_tmp ${params_tmp}) 264 foreach(param_tmp ${params_tmp})
261 if(arg_tmp STREQUAL param_tmp) 265 if(arg_tmp STREQUAL param_tmp)
262 set(type_tmp ${param_tmp}) 266 set(type_tmp ${param_tmp})
263 set(found_type_tmp 1) 267 set(found_type_tmp 1)
264 break(param_tmp ${params_tmp}) 268 break(param_tmp ${params_tmp})
265 endif(arg_tmp STREQUAL param_tmp) 269 endif(arg_tmp STREQUAL param_tmp)
266 endforeach(param_tmp ${params_tmp}) 270 endforeach(param_tmp ${params_tmp})
267 endif(NOT found_type_tmp) 271 endif(NOT found_type_tmp)
268 if(NOT found_type_tmp) 272 if(NOT found_type_tmp)
269 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) 273 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
270 endif(NOT found_type_tmp) 274 endif(NOT found_type_tmp)
271 endforeach(arg_tmp ${ARGN}) 275 endforeach(arg_tmp ${ARGN})
272 endmacro(qtd_parse_params default) 276 endmacro(qtd_parse_params default)
273 277
274 ## Adds a new example. 278 ## Adds a new example.
275 ## name -- example name. 279 ## name -- example name.
276 ## Options: 280 ## Options:
277 ## PACKAGES -- list of packages for link to example (for example, QtCore QtGui QtOpenGL). 281 ## PACKAGES -- list of packages for link to example (for example, QtCore QtGui QtOpenGL).
278 ## Default value is "QtCore QtGui". 282 ## Default value is "QtCore QtGui".
279 ## params -- sources d files. 283 ## params -- sources d files.
280 ## Usage: 284 ## Usage:
281 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) 285 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d)
282 macro(build_example name) 286 macro(build_example name)
283 set (params UIC RESOURCES PACKAGES) 287 set (params UIC RESOURCES PACKAGES)
284 qtd_parse_params (SOURCES params ${ARGN}) 288 qtd_parse_params (SOURCES params ${ARGN})
285 289
286 if(NOT PACKAGES_tmp) 290 if(NOT PACKAGES_tmp)
287 set(PACKAGES_tmp QtCore QtGui) 291 set(PACKAGES_tmp QtCore QtGui)
288 endif(NOT PACKAGES_tmp) 292 endif(NOT PACKAGES_tmp)
289 293
290 if(RESOURCES_tmp) 294 if(RESOURCES_tmp)
291 if(NOT BUILD_TOOLS) 295 if(NOT BUILD_TOOLS)
292 message(STATUS "Example '${name}' requires drcc. Example will not be built") 296 message(STATUS "Example '${name}' requires drcc. Example will not be built")
293 return(build_example name) 297 return(build_example name)
294 endif(NOT BUILD_TOOLS) 298 endif(NOT BUILD_TOOLS)
295 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) 299 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} )
296 endif(RESOURCES_tmp) 300 endif(RESOURCES_tmp)
297 301
298 if(UIC_tmp) 302 if(UIC_tmp)
299 if(NOT BUILD_TOOLS) 303 if(NOT BUILD_TOOLS)
300 message(STATUS "Example '${name}' requires drcc. Example will not be built") 304 message(STATUS "Example '${name}' requires drcc. Example will not be built")
301 return(build_example name) 305 return(build_example name)
302 endif(NOT BUILD_TOOLS) 306 endif(NOT BUILD_TOOLS)
303 qtd_wrap_ui(uic_sources ${UIC_tmp}) 307 qtd_wrap_ui(uic_sources ${UIC_tmp})
304 endif(UIC_tmp) 308 endif(UIC_tmp)
305 309
306 foreach(package ${PACKAGES_tmp}) 310 foreach(package ${PACKAGES_tmp})
307 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") 311 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}")
308 set(is_founded) 312 set(is_found)
309 foreach(package_big ${packages_big}) 313 foreach(package_big ${packages_big})
310 string(TOLOWER ${package_big} package) 314 string(TOLOWER ${package_big} package)
311 if(${req} STREQUAL ${package_big}) 315 if(${req} STREQUAL ${package_big})
312 set(is_founded 1) 316 set(is_found 1)
313 break(package_big ${packages_big}) 317 break(package_big ${packages_big})
314 endif(${req} STREQUAL ${package_big}) 318 endif(${req} STREQUAL ${package_big})
315 endforeach(package_big ${packages_big}) 319 endforeach(package_big ${packages_big})
316 if(NOT is_founded) 320 if(NOT is_found)
317 message(STATUS "Example '${name}' requires the package '${req}', but it is not active. Example will not be built") 321 message(STATUS "Example '${name}' requires the package '${req}', but it is not active. Example will not be built")
318 return(build_example name) 322 return(build_example name)
319 else(NOT is_founded) 323 else(NOT is_found)
320 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) 324 set(qtd_libs ${${package}_lib_param} ${qtd_libs})
321 endif(NOT is_founded) 325 endif(NOT is_found)
322 endforeach(package ${PACKAGES_tmp}) 326 endforeach(package ${PACKAGES_tmp})
323 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} 327 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources}
324 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} 328 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR}
325 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib ${QT_LIBRARY_DIR} LIBS ${qtd_libs}) 329 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib ${QT_LIBRARY_DIR} LIBS ${qtd_libs})
326 ## TODO: Uncomment. 330 ## TODO: Uncomment.
327 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## 331 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ##
328 # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") 332 # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}")
329 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) 333 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX)
330 add_dependencies(examples ${name}) 334 add_dependencies(examples ${name})
331 add_dependencies(${name} allpackages tools) 335 add_dependencies(${name} allpackages tools)
332 endmacro(build_example sources) 336 endmacro(build_example sources)
333 337
338 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 342 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
339 add_custom_target(allpackages) 343 add_custom_target(allpackages)
340 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) 344 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles)
341 345
342 foreach(package_big ${all_packages}) 346 foreach(package_big ${all_packages})
343 string(TOLOWER ${package_big} package) 347 string(TOLOWER ${package_big} package)
344 string(TOUPPER ${package} package_upper) 348 string(TOUPPER ${package} package_upper)
345 ## Load settings for the package. 349 ## Load settings for the package.
346 set(required) 350 set(required)
347 set(d_objs) 351 set(d_objs)
348 set(cpp_objs) 352 set(cpp_objs)
351 set(lib_name) 355 set(lib_name)
352 set(link_cpp) 356 set(link_cpp)
353 set(link_d) 357 set(link_d)
354 set(cpp_files) 358 set(cpp_files)
355 set(cpp_generated_files) 359 set(cpp_generated_files)
356 set(d_files) 360 set(d_qt_files)
361 set(d_qtd_files)
357 set(classes) 362 set(classes)
358 set(d_generated_files) 363 set(d_generated_files)
359 set(d_version_files)
360 set(link_example) 364 set(link_example)
361 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) 365 include (${CMAKE_SOURCE_DIR}/build/${package}.txt)
362 366
363 set(all_req_found 1) 367 set(all_req_found 1)
364 if(BUILD_QT_${package_upper}) 368 if(BUILD_QT_${package_upper})
365 foreach(req ${required}) 369 foreach(req ${required})
366 set(req_found) 370 set(req_found)
367 foreach(pack ${packages_big}) 371 foreach(pack ${packages_big})
368 if(${pack} STREQUAL ${req}) 372 if(${pack} STREQUAL ${req})
369 set(req_found 1) 373 set(req_found 1)
370 endif(${pack} STREQUAL ${req}) 374 endif(${pack} STREQUAL ${req})
371 endforeach(pack ${packages}) 375 endforeach(pack ${packages})
372 if(NOT req_found) 376 if(NOT req_found)
373 set(req_found) 377 set(req_found)
374 foreach(pack ${all_packages}) 378 foreach(pack ${all_packages})
375 if(${pack} STREQUAL ${req}) 379 if(${pack} STREQUAL ${req})
376 set(req_found 1) 380 set(req_found 1)
377 endif(${pack} STREQUAL ${req}) 381 endif(${pack} STREQUAL ${req})
378 endforeach(pack ${all_packages}) 382 endforeach(pack ${all_packages})
379 if(req_found) 383 if(req_found)
380 message(STATUS "Package '${package_big}' requires '${req}', but it is not active") 384 message(STATUS "Package '${package_big}' requires '${req}', but it is not active")
381 else(req_found) 385 else(req_found)
382 message(STATUS "Package '${package_big}' requires '${req}', but it is not found") 386 message(STATUS "Package '${package_big}' requires '${req}', but it is not found")
383 endif(req_found) 387 endif(req_found)
384 set(all_req_found) 388 set(all_req_found)
385 endif(NOT req_found) 389 endif(NOT req_found)
386 endforeach(req ${required}) 390 endforeach(req ${required})
387 else(BUILD_QT_${package_upper}) 391 else(BUILD_QT_${package_upper})
388 set(all_req_found) 392 set(all_req_found)
389 endif(BUILD_QT_${package_upper}) 393 endif(BUILD_QT_${package_upper})
390 394
391 if("${all_req_found}" EQUAL 1) 395 if("${all_req_found}" EQUAL 1)
392 set(packages_big ${packages_big} ${package_big}) 396 set(packages_big ${packages_big} ${package_big})
393 set(packages ${packages} ${package}) 397 set(packages ${packages} ${package})
394 ## Load a package sources list. 398 ## Load a package sources list.
395 foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) 399 foreach(d_source ${package}/ArrayOps2 ${d_generated_files})
396 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) 400 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d)
397 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) 401 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d)
398 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) 402 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d)
399 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) 403 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d)
400 endforeach(d_source ${d_generated_files}) 404 endforeach(d_source ${d_generated_files})
401 set(classes ArrayOps ${classes}) 405 set(classes ArrayOps ${classes})
402 foreach(class ${classes}) 406 foreach(class ${classes})
403 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) 407 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d)
404 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) 408 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp)
405 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) 409 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d)
406 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) 410 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d)
407 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) 411 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d)
408 endforeach(class ${classes}) 412 endforeach(class ${classes})
409 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) 413 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources})
410 414
411 foreach (cpp_source ${cpp_files}) 415 foreach (cpp_source ${cpp_files})
412 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) 416 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp)
413 endforeach(cpp_source ${cpp_files}) 417 endforeach(cpp_source ${cpp_files})
414 foreach (cpp_source ${cpp_generated_files}) 418 foreach (cpp_source ${cpp_generated_files})
415 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp) 419 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp)
416 endforeach(cpp_source ${cpp_generated_files}) 420 endforeach(cpp_source ${cpp_generated_files})
417 foreach(d_source ${d_version_files}) 421 foreach(d_source ${d_qt_files})
418 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d) 422 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qt/${d_source}.d)
419 endforeach(d_source ${d_version_files}) 423 endforeach(d_source ${d_qt_files})
420 foreach(d_source ${d_files}) 424 foreach(d_source ${d_qtd_files})
421 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d) 425 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qtd/${d_source}.d)
422 endforeach(d_source ${d_files}) 426 endforeach(d_source ${d_qtd_files})
423 427
424 if(NOT GENERATE_DI_FILES) 428 if(NOT GENERATE_DI_FILES)
425 foreach(d_source ${d_sources}) 429 foreach(d_source ${d_sources})
426 get_filename_component(path ${d_source} PATH) 430 get_filename_component(path ${d_source} PATH)
427 get_filename_component(name ${d_source} NAME_WE) 431 get_filename_component(name ${d_source} NAME_WE)
428 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) 432 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR})
429 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}) 433 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR})
430 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/qt/d${D_VERSION}) 434 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/qt/d${D_VERSION})
431 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") 435 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)")
432 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") 436 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}")
433 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) 437 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di)
434 endforeach(d_source ${d_sources}) 438 endforeach(d_source ${d_sources})
435 endif(NOT GENERATE_DI_FILES) 439 endif(NOT GENERATE_DI_FILES)
436 440
437 ## Build the CPP part. 441 ## Build the CPP part.
438 if(CPP_SHARED) 442 if(CPP_SHARED)
439 set(cpp_method SHARED) 443 set(cpp_method SHARED)
440 else(CPP_SHARED) 444 else(CPP_SHARED)
441 set(cpp_method STATIC) 445 set(cpp_method STATIC)
442 endif(CPP_SHARED) 446 endif(CPP_SHARED)
443 add_library(cpp_${package} ${cpp_method} ${cpp_sources}) 447 add_library(cpp_${package} ${cpp_method} ${cpp_sources})
444 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) 448 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)
445 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) 449 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
446 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) 450 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY})
447 if(CPP_SHARED) 451 if(CPP_SHARED)
448 else(CPP_SHARED) 452 else(CPP_SHARED)
449 ## Get an objects list. It will be used in building the D part. 453 ## Get an objects list. It will be used in building the D part.
450 foreach(cpp_source ${cpp_sources}) 454 foreach(cpp_source ${cpp_sources})
451 set(cpp_source ${cpp_source}) 455 set(cpp_source ${cpp_source})
452 obj_path(cpp_source) 456 obj_path(cpp_source)
453 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) 457 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION})
454 endforeach(cpp_source ${cpp_sources}) 458 endforeach(cpp_source ${cpp_sources})
455 endif(CPP_SHARED) 459 endif(CPP_SHARED)
456 460
457 ## Settings for the D part. 461 ## Settings for the D part.
458 set(lib_name qtd${package}) 462 set(lib_name qtd${package})
459 if(BUILD_SHARED_LIBRARIES) 463 if(BUILD_SHARED_LIBRARIES)
460 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) 464 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
461 set(build_type SHARED) 465 set(build_type SHARED)
462 else(BUILD_SHARED_LIBRARIES) 466 else(BUILD_SHARED_LIBRARIES)
463 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) 467 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX})
464 set(build_type STATIC) 468 set(build_type STATIC)
465 endif(BUILD_SHARED_LIBRARIES) 469 endif(BUILD_SHARED_LIBRARIES)
466 470
467 ## Package dependencies. 471 ## Package dependencies.
468 foreach(req ${required}) 472 foreach(req ${required})
469 set(is_found) 473 set(is_found)
470 foreach(pack ${packages_big}) 474 foreach(pack ${packages_big})
471 if("${pack}" STREQUAL "${req}") 475 if("${pack}" STREQUAL "${req}")
472 set(is_found 1) 476 set(is_found 1)
473 break(pack ${packages_big}) 477 break(pack ${packages_big})
474 endif("${pack}" STREQUAL "${req}") 478 endif("${pack}" STREQUAL "${req}")
475 endforeach(pack ${packages_big}) 479 endforeach(pack ${packages_big})
476 if(NOT is_found) 480 if(NOT is_found)
477 message(FATAL_ERROR "Package ${package_big} requires ${req}, but it is not found") 481 message(FATAL_ERROR "Package ${package_big} requires ${req}, but it is not found")
478 endif(NOT is_found) 482 endif(NOT is_found)
479 string(TOUPPER ${req} req_upper) 483 string(TOUPPER ${req} req_upper)
480 string(TOLOWER ${req} req_lower) 484 string(TOLOWER ${req} req_lower)
481 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) 485 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY})
482 endforeach(req ${require}) 486 endforeach(req ${require})
483 target_link_libraries(cpp_${package} ${link_cpp} ) 487 target_link_libraries(cpp_${package} ${link_cpp} )
484 set(d_objs ${d_objs} ${objects}) 488 set(d_objs ${d_objs} ${objects})
485 489
486 if(CPP_SHARED) 490 if(CPP_SHARED)
487 ## Create an implib library which will be linked to the D part. 491 ## Create an implib library which will be linked to the D part.
488 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll) 492 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll)
489 set(cpp_lib_native ${cpp_lib}) 493 set(cpp_lib_native ${cpp_lib})
490 make_native_path(cpp_lib_native) 494 make_native_path(cpp_lib_native)
491 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) 495 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib)
492 set(d_implib_native ${d_implib}) 496 set(d_implib_native ${d_implib})
493 make_native_path(d_implib_native) 497 make_native_path(d_implib_native)
494 add_custom_command( 498 add_custom_command(
495 OUTPUT "${d_implib}" 499 OUTPUT "${d_implib}"
496 COMMAND "${IMPLIB}" 500 COMMAND "${IMPLIB}"
497 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native} 501 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native}
498 DEPENDS "cpp_${package}" 502 DEPENDS "cpp_${package}"
499 COMMENT "Creating implib ${lib_name}" 503 COMMENT "Creating implib ${lib_name}"
500 ) 504 )
501 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) 505 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib)
502 else(CPP_SHARED) 506 else(CPP_SHARED)
503 set(${package}_lib_param Qt${package_big}) 507 set(${package}_lib_param Qt${package_big})
504 endif(CPP_SHARED) 508 endif(CPP_SHARED)
505 ## Link the D part. 509 ## Link the D part.
506 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} 510 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib}
507 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} ) 511 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} )
508 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) 512 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib)
509 ## Paths for the QtD libs. It is necessary for examples. 513 ## Paths for the QtD libs. It is necessary for examples.
510 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) 514 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example})
511 515
512 ## Generate dependences for make (or nmake). 516 ## Generate dependences for make (or nmake).
513 add_custom_target(${package}) 517 add_custom_target(${package})
514 add_dependencies(${package} ${lib_name}) 518 add_dependencies(${package} ${lib_name})
515 add_dependencies(${lib_name} cpp_${package}) 519 add_dependencies(${lib_name} cpp_${package})
516 foreach(depend ${required}) 520 foreach(depend ${required})
517 string(TOLOWER ${depend} depend) 521 string(TOLOWER ${depend} depend)
518 add_dependencies(cpp_${package} cpp_${depend}) 522 add_dependencies(cpp_${package} cpp_${depend})
519 add_dependencies(${package} ${depend}) 523 add_dependencies(${package} ${depend})
520 endforeach(depend ${required}) 524 endforeach(depend ${required})
521 add_dependencies(allpackages ${package}) 525 add_dependencies(allpackages ${package})
522 526
523 ## TODO: Do we need generating of *.di files? 527 ## TODO: Do we need generating of *.di files?
524 if(GENERATE_DI_FILES) 528 if(GENERATE_DI_FILES)
525 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) 529 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR})
526 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) 530 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR})
527 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") 531 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d")
528 foreach(source ${d_sources}) 532 foreach(source ${d_sources})
529 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} 533 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
530 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) 534 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
531 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") 535 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}")
532 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") 536 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}")
533 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) 537 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path})
534 set(interface_file "${interface_file_path}/${file_name}.di") 538 set(interface_file "${interface_file_path}/${file_name}.di")
535 if(NOT "${file_name}" STREQUAL "QGlobal") 539 if(NOT "${file_name}" STREQUAL "QGlobal")
536 add_custom_command(OUTPUT "${interface_file}" 540 add_custom_command(OUTPUT "${interface_file}"
537 COMMAND "${DC}" 541 COMMAND "${DC}"
538 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} 542 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source}
539 COMMENT "Generating header for ${source}" 543 COMMENT "Generating header for ${source}"
540 DEPENDS ${source} 544 DEPENDS ${source}
541 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 545 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
542 ) 546 )
543 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file. 547 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file.
544 add_custom_command(OUTPUT "${interface_file}" 548 add_custom_command(OUTPUT "${interface_file}"
545 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} 549 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path}
546 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} 550 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file}
547 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} 551 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file}
548 COMMENT "" 552 COMMENT ""
549 DEPENDS ${source} 553 DEPENDS ${source}
550 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 554 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
551 ) 555 )
552 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) 556 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES)
553 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) 557 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di)
554 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) 558 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path})
555 endforeach(source) 559 endforeach(source)
556 endif(GENERATE_DI_FILES) 560 endif(GENERATE_DI_FILES)
557 endif("${all_req_found}" EQUAL 1) 561 endif("${all_req_found}" EQUAL 1)
558 endforeach(package_big ${packages_big}) 562 endforeach(package_big ${packages_big})
559 if(GENERATE_DI_FILES) 563 if(GENERATE_DI_FILES)
560 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) 564 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list})
561 endif(GENERATE_DI_FILES) 565 endif(GENERATE_DI_FILES)
562 566
563 set(CPACK_COMPONENTS_ALL qtd qtd_tools) 567 set(CPACK_COMPONENTS_ALL qtd qtd_tools)
564 568