Mercurial > projects > qtd
annotate CMakeLists.txt @ 42:eb3b5bbffc8f
CMake: generator is not running multiple times.
generator: packages can have dependencies now (but this do not used in real code yet).
author | SokoL_SD |
---|---|
date | Sun, 17 May 2009 15:53:27 +0000 |
parents | a5cba313c924 |
children | bfc76a437a62 |
rev | line source |
---|---|
4 | 1 cmake_minimum_required(VERSION 2.6) |
1 | 2 PROJECT(qtd CXX C) |
3 FIND_PACKAGE(Qt4 REQUIRED) | |
4 | |
7 | 5 ##-------------------------------------------- |
6 ## Settings. | |
7 ##-------------------------------------------- | |
8 | |
5 | 9 include_directories(${QT_INCLUDES} include ${CMAKE_CURRENT_BINARY_DIR}/include) |
1 | 10 |
7 | 11 ## Options. |
4 | 12 option(BUILD_EXAMPLES "Build examples" "ON") |
9 | 13 option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") |
4 | 14 |
39 | 15 set(all_packages Core Gui OpenGL Xml Svg Network WebKit) ## TODO: Loading. |
4 | 16 |
17 | |
23 | 18 ## Strip utility. |
19 find_program(STRIP strip) | |
20 | |
7 | 21 ## Find D compiler and parsing its version. |
4 | 22 find_program(DC dmd ldc) |
23 if (DC) | |
24 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output) | |
25 string(REGEX MATCH "Digital Mars D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}") | |
26 if (dmd_version) | |
27 set(D_IS_MARS true) | |
16 | 28 set(D_IS_DMD true) |
4 | 29 set(D_COMPILER_NAME "Digital Mars D Compiler") |
30 string(REGEX REPLACE "Digital Mars D Compiler v([0-9])\\.[0-9]+" "\\1" D_VERSION "${dmd_version}") | |
31 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}") | |
32 else (dmd_version) | |
33 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}") | |
34 if (is_ldc) | |
35 exec_program(${DC} ARGS "--version" OUTPUT_VARIABLE d_output) | |
11
28c9f8f8f34b
Another small fix: correctly processing version of ldc based on llvm from trunk.
SokoL_SD
parents:
10
diff
changeset
|
36 string(REGEX MATCH "based on DMD v[0-9]\\.[0-9]+" ldc_version "${d_output}") |
4 | 37 set(D_IS_LLVM true) |
16 | 38 set(D_IS_LDC true) |
4 | 39 if(ldc_version) |
40 set(D_IS_LLVM true) | |
41 set(D_COMPILER_NAME "LLVM-based D Compiler") | |
11
28c9f8f8f34b
Another small fix: correctly processing version of ldc based on llvm from trunk.
SokoL_SD
parents:
10
diff
changeset
|
42 string(REGEX REPLACE "based on DMD v([0-9])\\.[0-9]+" "\\1" D_VERSION "${ldc_version}") |
28c9f8f8f34b
Another small fix: correctly processing version of ldc based on llvm from trunk.
SokoL_SD
parents:
10
diff
changeset
|
43 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${ldc_version}") |
4 | 44 else(ldc_version) |
45 message(FATAL_ERROR "LDC compiler was found, but the version can not be processed") | |
46 endif(ldc_version) | |
47 else (is_ldc) | |
48 message(FATAL_ERROR "D compliler not founded") | |
49 endif(is_ldc) | |
50 endif(dmd_version) | |
51 message(STATUS "D compiler founded -- ${D_COMPILER_NAME} v${D_VERSION}.${D_FRONTEND}") | |
52 else (DC) | |
53 message(FATAL_ERROR "D compliler not founded") | |
54 endif (DC) | |
55 | |
42 | 56 # find_program(DC_TMP ${DC}) |
57 # mark_as_advanced(DC_TMP) | |
58 # string(REGEX MATCH "([A-Za-z\\.0-9/_\\ ]+)(/bin)/[A-Za-z\\.0-9/_\\ ]+" "\\1" dc_path "${DC_PATH}") | |
59 # if(NOT "${DC_TMP}" STREQUAL "${dc_path}") | |
60 # set(CMAKE_INSTALL_PREFIX ${dc_path}) | |
61 # endif(NOT "${DC_TMP}" STREQUAL "${dc_path}") | |
62 | |
7 | 63 if(D_IS_MARS) |
9 | 64 option(SINGLE_D_OBJECT "Build all d sources to one object file" "ON") |
7 | 65 elseif(D_IS_LLVM) |
9 | 66 option(SINGLE_D_OBJECT "Build all d sources to one object file" "OFF") |
67 if(SINGLE_D_OBJECT) | |
13 | 68 message(STATUS "LDC not support build multiple source files in one .obj file") |
69 set(SINGLE_D_OBJECT "OFF") | |
70 #set(D_FLAGS ${D_FLAGS} -singleobj) | |
9 | 71 endif(SINGLE_D_OBJECT) |
7 | 72 endif(D_IS_MARS) |
73 | |
4 | 74 # Check D compiler version |
75 if(D_VERSION EQUAL "1") | |
76 if (D_FRONTEND LESS "041") | |
77 message(STATUS "Minimum required version of D compiler is 1.041 (or compiler based on this version)") | |
78 endif(D_FRONTEND LESS "041") | |
16 | 79 set(D_TARGET d1-tango) |
4 | 80 elseif(D_VERSION EQUAL "2") |
81 set(D_TARGET ) ## TODO: hm... I don`t known this parameter for D2 ^( | |
82 endif(D_VERSION EQUAL "1") | |
16 | 83 set(D_FLAGS ${D_FLAGS} -I${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}) |
4 | 84 |
85 # Debug and release flags. | |
23 | 86 if (NOT CMAKE_BUILD_TYPE) |
87 set(CMAKE_BUILD_TYPE Release) | |
88 endif (NOT CMAKE_BUILD_TYPE) | |
89 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
90 set(CMAKE_BUILD_TYPE Debug) | |
91 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) | |
92 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) | |
93 add_definitions(-DDEBUG) | |
94 set(D_FLAGS ${D_FLAGS} -g -gc -debug) | |
95 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
96 message(STATUS "Only debug and release configuration are now supproted. Configuration changed to 'Release'") | |
97 set(CMAKE_BUILD_TYPE Release) | |
98 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
99 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
100 #add_definitions(-UNO_DEBUG) | |
9 | 101 set(D_FLAGS ${D_FLAGS} -O -release -inline) |
16 | 102 if(D_IS_MARS) |
103 set(D_FLAGS ${D_FLAGS} -inline) | |
104 elseif(D_IS_LLVM) | |
105 set(D_FLAGS ${D_FLAGS} -enable-inlining) | |
106 endif(D_IS_MARS) | |
4 | 107 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
108 set(D_FLAGS ${D_FLAGS} -L/subsystem:windows) | |
109 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
23 | 110 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] ) |
111 | |
4 | 112 set(D_FLAGS ${D_FLAGS} -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR}) |
10 | 113 if(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
114 else(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
7 | 115 set(D_FLAGS ${D_FLAGS} -L-L${CMAKE_BINARY_DIR}/lib) |
10 | 116 endif(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
117 | |
9 | 118 # System specifc settings. |
4 | 119 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
120 set(implib implib) | |
121 find_program(IMPLIB ${implib}) | |
122 if (NOT IMPLIB) | |
123 message(FATAL_ERROR "implib not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") | |
124 endif (NOT IMPLIB) | |
125 set(D_OBJECT_SUFFIX .obj) | |
126 if(D_IS_MARS) | |
127 set(D_LIB_SUFFIX .lib) | |
128 set(D_LIB_PREFIX ) | |
129 elseif(D_IS_LDC) | |
130 set(D_LIB_SUFFIX .a) | |
131 set(D_LIB_PREFIX lib) | |
132 endif(D_IS_MARS) | |
133 set(GEN_OPT ${GEN_OPT} --cpp_shared) | |
134 add_definitions(-DCPP_SHARED) | |
7 | 135 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") |
4 | 136 elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux) |
137 set(D_LIB_SUFFIX .a) | |
138 set(D_LIB_PREFIX lib) | |
139 set(D_OBJECT_SUFFIX .o) | |
140 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
141 | |
142 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) | |
143 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) | |
144 | |
7 | 145 ##-------------------------------------------- |
146 ## Macroses and functions. | |
147 ##-------------------------------------------- | |
4 | 148 |
7 | 149 ## Make native path. |
150 ## Usage: | |
151 ## set(path c:/file_path/file_name.cpp) | |
152 ## make_native_path(path) | |
153 ## message(STATUS ${path}) | |
154 ## Output: | |
155 ## -- "c:\file_path\file_name.cpp" | |
156 ## Command "file(TO_NATIVE_PATH ...)" is wrong on Windows | |
157 macro(MAKE_NATIVE_PATH pathname) | |
158 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
159 # An extra \\ escape is necessary to get a \ through CMake's processing. | |
160 string(REPLACE "/" "\\" ${pathname} "${${pathname}}") | |
161 # Enclose with UNESCAPED quotes. This means we need to escape our | |
162 # quotes once here, i.e. with \" | |
163 set(${pathname} \"${${pathname}}\") | |
164 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
165 endmacro(MAKE_NATIVE_PATH) | |
166 | |
167 ## Remove unnecessary travel to the object file. | |
168 ## path -- path to object file. | |
169 ## Example: | |
170 ## set(path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/target.dir/main.d.obj) | |
171 ## obj_path(path) | |
172 ## message(STATUS ${path}) | |
173 ## Example output: | |
174 ## -- CMakeFiles/target.dir/main.d.obj | |
4 | 175 macro(OBJ_PATH path) |
9 | 176 set(test) |
4 | 177 string(REGEX MATCH "${CMAKE_CURRENT_BINARY_DIR}/.*" test "${${path}}") |
178 if(NOT ${test} EQUAL "") | |
179 string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" first) | |
180 string(LENGTH "${${path}}" last) | |
181 math(EXPR first "${first} + 1") | |
182 math(EXPR len "${last} - ${first}") | |
183 string(SUBSTRING "${${path}}" ${first} ${len} ${path}) | |
184 else(NOT ${test} EQUAL "") | |
185 string(REGEX MATCH "${CMAKE_CURRENT_SOURCE_DIR}/.*" test "${${path}}") | |
186 if(NOT ${test} EQUAL "") | |
187 string(LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" first) | |
188 string(LENGTH "${${path}}" last) | |
189 math(EXPR first "${first} + 1") | |
190 math(EXPR len "${last} - ${first}") | |
191 string(SUBSTRING "${${path}}" ${first} ${len} ${path}) | |
192 endif(NOT ${test} EQUAL "") | |
193 endif(NOT ${test} EQUAL "") | |
194 endmacro(OBJ_PATH) | |
195 | |
7 | 196 |
197 ## Compile d files. | |
198 ## target -- name of a new target. | |
199 ## objects_list -- created object files. | |
200 ## params -- sources files. | |
4 | 201 macro(compile_d_files target objects_list) |
9 | 202 set(${objects_list}) |
4 | 203 set(tmp_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir) |
204 file(MAKE_DIRECTORY ${tmp_dir}) | |
9 | 205 if(NOT SINGLE_D_OBJECT) |
7 | 206 foreach (d_source_p ${ARGN}) |
207 ## TODO: why find_file command work wrong? | |
208 find_file(d_source_p ${d_source_p} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
209 ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | |
210 set (d_source ${d_source_p}) | |
211 obj_path(d_source) | |
4 | 212 set(d_obj ${tmp_dir}/${d_source}${D_OBJECT_SUFFIX}) |
7 | 213 set(${objects_list} ${${objects_list}} ${d_obj}) |
4 | 214 get_filename_component(path ${d_obj} PATH) |
215 file(MAKE_DIRECTORY ${path}) | |
216 set(d_obj_out ${d_obj}) | |
7 | 217 obj_path(d_obj_out) |
4 | 218 add_custom_command(OUTPUT "${d_obj}" |
219 COMMAND "${DC}" | |
7 | 220 ARGS ${D_FLAGS} -c ${d_source_p} -of${d_obj} |
4 | 221 COMMENT "Building ${d_obj_out}" |
7 | 222 DEPENDS ${d_source_p} |
223 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
4 | 224 ) |
7 | 225 endforeach(d_source_p) |
9 | 226 else(NOT SINGLE_D_OBJECT) |
4 | 227 set(${objects_list} ${tmp_dir}/${target}${D_OBJECT_SUFFIX}) |
228 set(d_obj_out ${${objects_list}}) | |
7 | 229 obj_path(d_obj_out) |
12 | 230 set(parameters ${D_FLAGS} -c ${ARGN} -of${${objects_list}}) |
4 | 231 set(parameters_list_file ${tmp_dir}/parameters) |
12 | 232 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
233 file(REMOVE ${parameters_list_file}) | |
234 foreach(arg ${parameters}) | |
235 file(APPEND ${parameters_list_file} "${arg}\n") | |
236 endforeach(arg) | |
237 set(param @${parameters_list_file}) | |
238 elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux) | |
239 set(param ${parameters}) | |
240 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
4 | 241 add_custom_command(OUTPUT "${${objects_list}}" |
242 COMMAND "${DC}" | |
12 | 243 ARGS ${param} |
4 | 244 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
245 DEPENDS ${ARGN} | |
246 COMMENT "" | |
247 ) | |
9 | 248 endif(NOT SINGLE_D_OBJECT) |
7 | 249 add_custom_target(${target} DEPENDS "${${objects_list}}") |
4 | 250 endmacro(compile_d_files objects_list) |
251 | |
7 | 252 ## Build example macro. |
253 ## name -- example name. | |
254 ## Options: | |
255 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL). | |
256 ## Default value is "QtCore QtGui". | |
257 ## params -- sources d files. | |
258 ## Usage: | |
259 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) | |
4 | 260 macro(build_example name) |
9 | 261 set(is_sources) |
262 set(is_libs) | |
4 | 263 set(qtd_libs ${core_lib_param} ${gui_lib_param}) |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
264 set(reqs Core Gui) |
4 | 265 foreach(param ${ARGN}) |
266 if(is_libs) | |
267 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" param_package "${param}") | |
268 if(${param_package} STREQUAL ${param}) | |
9 | 269 set(is_libs) |
4 | 270 set(is_sources 1) |
271 else(${param_package} STREQUAL ${param}) | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
272 set(reqs ${reqs} ${param_package}) |
4 | 273 endif(${param_package} STREQUAL ${param}) |
274 endif(is_libs) | |
275 if(NOT is_libs) | |
276 if(NOT is_sources) | |
277 if(${param} STREQUAL PACKAGES) | |
278 set(is_libs 1) | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
279 set(reqs) |
4 | 280 else(${param} STREQUAL PACKAGES) |
281 set(is_sources 1) | |
282 endif(${param} STREQUAL PACKAGES) | |
283 endif(NOT is_sources) | |
284 if(is_sources) | |
285 set(sources ${sources} ${param}) | |
286 endif(is_sources) | |
287 endif(NOT is_libs) | |
288 endforeach(param ${ARGN}) | |
289 compile_d_files(${name}_dobjs objects ${sources} ) | |
290 set(output ${CMAKE_CURRENT_BINARY_DIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}) | |
291 set(output_native ${output}) | |
7 | 292 make_native_path(output_native) |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
293 foreach(req ${reqs}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
294 set(is_founded) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
295 foreach(package_big ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
296 string(TOLOWER ${package_big} package) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
297 if(${req} STREQUAL ${package_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
298 set(is_founded 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
299 break(package_big ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
300 endif(${req} STREQUAL ${package_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
301 endforeach(package_big ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
302 if(NOT is_founded) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
303 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
304 return(build_example name) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
305 else(NOT is_founded) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
306 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
307 endif(NOT is_founded) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
308 endforeach(req ${reqs}) |
4 | 309 add_custom_command(OUTPUT "${output}" |
310 COMMAND "${DC}" | |
311 ARGS ${D_FLAGS} ${libs_path} ${qtd_libs} ${objects} | |
312 -of${output_native} | |
313 DEPENDS ${objects} | |
314 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
315 COMMENT "Building example ${name}" | |
316 ) | |
317 add_custom_target(example_${name} ALL DEPENDS "${output}") | |
23 | 318 ## TODO: Enable on windows too. |
319 if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND ${CMAKE_SYSTEM_NAME} STREQUAL Linux) ## | |
320 add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") | |
321 endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND ${CMAKE_SYSTEM_NAME} STREQUAL Linux) | |
4 | 322 add_dependencies(example_${name} allpackages) |
323 endmacro(build_example sources) | |
324 | |
7 | 325 ##-------------------------------------------- |
23 | 326 ## Build and install library. |
7 | 327 ##-------------------------------------------- |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
328 |
7 | 329 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
330 add_custom_target(allpackages ALL) | |
331 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | |
332 | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
333 foreach(package_big ${all_packages}) |
7 | 334 string(TOLOWER ${package_big} package) |
335 ## Loading settings for package. | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
336 set(required) |
9 | 337 set(d_objs) |
338 set(cpp_objs) | |
339 set(d_sources) | |
340 set(cpp_sources) | |
341 set(lib_name) | |
342 set(link_cpp) | |
343 set(link_d) | |
344 set(cpp_files) | |
345 set(d_files) | |
346 set(classes) | |
347 set(d_generated_files) | |
16 | 348 set(d_version_files) |
9 | 349 set(link_example) |
7 | 350 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) |
351 | |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
352 set(all_req_found 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
353 string(TOUPPER ${package} package_upper) |
42 | 354 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON") |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
355 if(BUILD_QT_${package_upper}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
356 foreach(req ${required}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
357 set(req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
358 foreach(pack ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
359 if(${pack} STREQUAL ${req}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
360 set(req_found 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
361 endif(${pack} STREQUAL ${req}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
362 endforeach(pack ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
363 if(NOT req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
364 set(req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
365 foreach(pack ${all_packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
366 if(${pack} STREQUAL ${req}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
367 set(req_found 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
368 endif(${pack} STREQUAL ${req}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
369 endforeach(pack ${all_packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
370 if(req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
371 message(STATUS "Package '${package_big}' required '${req}', but its not active") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
372 else(req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
373 message(STATUS "Package '${package_big}' required '${req}', but its not found") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
374 endif(req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
375 set(all_req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
376 endif(NOT req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
377 endforeach(req ${required}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
378 else(BUILD_QT_${package_upper}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
379 set(all_req_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
380 endif(BUILD_QT_${package_upper}) |
7 | 381 |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
382 if("${all_req_found}" EQUAL 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
383 set(packages_big ${packages_big} ${package_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
384 set(packages ${packages} ${package}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
385 ## Loading package sources list. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
386 foreach(d_source ${d_version_files}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
387 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
388 if(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
389 get_filename_component(path ${d_source}.d PATH) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
390 get_filename_component(name ${d_source}.d NAME_WE) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
391 install(FILES ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d DESTINATION include/d/qtd/${path} RENAME ${name}.di) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
392 endif(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
393 endforeach(d_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
394 foreach(d_source ${d_files}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
395 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
396 if(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
397 get_filename_component(path ${d_source}.d PATH) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
398 get_filename_component(name ${d_source}.d NAME_WE) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
399 install(FILES ${CMAKE_SOURCE_DIR}/qt/${d_source}.d DESTINATION include/d/qtd/${path} RENAME ${name}.di) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
400 endif(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
401 endforeach(d_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
402 foreach(d_source ${d_generated_files}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
403 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
404 if(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
405 get_filename_component(path ${d_source}.d PATH) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
406 get_filename_component(name ${d_source}.d NAME_WE) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
407 install(FILES ${CMAKE_BINARY_DIR}/qt/${d_source}.d DESTINATION include/d/qtd/${path} RENAME ${name}.di) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
408 endif(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
409 endforeach(d_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
410 foreach (cpp_source ${cpp_files}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
411 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
412 endforeach(cpp_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
413 set(classes ArrayOps ${classes}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
414 foreach(class ${classes}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
415 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
416 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
417 set(files_for_gen ${files_for_gen} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
418 ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
419 if(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
420 install(FILES ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d DESTINATION include/d/qtd/${package} RENAME ${class}.di) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
421 install(FILES ${CMAKE_BINARY_DIR}/qt/${package}/${class}_enum.d DESTINATION include/d/qtd/${package} RENAME ${class}_enum.di OPTIONAL) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
422 endif(NOT GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
423 endforeach(class) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
424 |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
425 ## Link CPP library. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
426 add_library(cpp_${package} SHARED ${cpp_sources}) |
7 | 427 |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
428 ## Link D library. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
429 set(lib_name ${D_LIB_PREFIX}qtd${package}${D_LIB_SUFFIX}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
430 set(lib lib/${lib_name}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
431 compile_d_files(${package}_dobjs objects ${d_sources}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
432 set(d_objs ${d_objs} ${objects}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
433 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
434 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
435 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
436 foreach(req ${required}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
437 set(is_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
438 foreach(pack ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
439 if("${pack}" STREQUAL "${req}") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
440 set(is_found 1) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
441 break(pack ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
442 endif("${pack}" STREQUAL "${req}") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
443 endforeach(pack ${packages_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
444 if(NOT is_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
445 message(FATAL_ERROR "Package ${package_big} required ${req}, but its not found") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
446 endif(NOT is_found) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
447 string(TOUPPER ${req} req_upper) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
448 string(TOLOWER ${req} req_lower) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
449 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
450 endforeach(req ${require}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
451 string(TOUPPER ${package} package_upper) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
452 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
453 target_link_libraries(cpp_${package} ${link_cpp} ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
454 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
455 set(cpp_lib_native ${cpp_lib}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
456 make_native_path(cpp_lib_native) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
457 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
458 set(d_implib_native ${d_implib}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
459 make_native_path(d_implib_native) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
460 add_custom_command( |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
461 OUTPUT "${d_implib}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
462 COMMAND "${IMPLIB}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
463 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
464 DEPENDS "cpp_${package}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
465 COMMENT "Creating implib ${lib_name}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
466 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
467 add_custom_command( |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
468 OUTPUT "${lib}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
469 COMMAND "${DC}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
470 ARGS -lib ${d_objs} ${d_implib} -of${lib} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
471 DEPENDS ${d_objs} ${d_implib} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
472 COMMENT "Linking ${lib_name}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
473 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
474 install(FILES ${cpp_lib} DESTINATION lib) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
475 else(${CMAKE_SYSTEM_NAME} STREQUAL Linux) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
476 set_property(TARGET cpp_${package} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
477 foreach(cpp_source ${cpp_sources}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
478 set(cpp_source ${cpp_source}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
479 obj_path(cpp_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
480 set(cpp_objs ${cpp_objs} CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
481 endforeach(cpp_source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
482 add_custom_command( |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
483 OUTPUT "${lib}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
484 COMMAND "${CMAKE_AR}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
485 ARGS rcs ${lib} ${d_objs} ${cpp_objs} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
486 DEPENDS ${d_objs} cpp_${package} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
487 COMMENT "Linking ${lib_name}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
488 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
489 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
490 install(FILES ${CMAKE_BINARY_DIR}/${lib} DESTINATION lib) |
7 | 491 |
28
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
492 ## Dependences. |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
493 add_custom_target(${package} DEPENDS ${lib}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
494 foreach(depend ${required}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
495 string(TOLOWER ${depend} depend) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
496 add_dependencies(cpp_${package} cpp_${depend}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
497 add_dependencies(${package} ${depend}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
498 endforeach(depend ${required}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
499 add_dependencies(allpackages ${package}) |
10baf869635a
CMake: QtD build with cmake again, but some functionality from previews revision are disabled.
SokoL_SD
parents:
27
diff
changeset
|
500 |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
501 ## Paths for QtD libs. Needed by examples. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
502 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
503 set(libs_path ${CMAKE_BINARY_DIR}/lib/qtd${package}.lib) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
504 make_native_path(libs_path) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
505 set(${package}_lib_param -L+${libs_path}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
506 foreach(link ${link_example}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
507 set(link ${CMAKE_SOURCE_DIR}/lib/${link}.lib) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
508 make_native_path(link) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
509 set(link -L+${link}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
510 set(${package}_lib_param ${${package}_lib_param} ${link}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
511 endforeach(link ${link_example}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
512 else (${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
513 set(${package}_lib_param -L-lqtd${package} -L-lQt${package_big}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
514 foreach(link ${link_example}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
515 set(${package}_lib_param ${${package}_lib_param} ${link}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
516 endforeach(link ${link_example}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
517 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS) |
9 | 518 |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
519 if(GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
520 set(regexp_str "(${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}|${CMAKE_BINARY_DIR}|${CMAKE_SOURCE_DIR})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
521 foreach(source ${d_sources}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
522 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
523 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
524 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
525 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
526 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
527 set(interface_file "${interface_file_path}/${file_name}.di") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
528 if(NOT "${file_name}" STREQUAL "QGlobal") |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
529 add_custom_command(OUTPUT "${interface_file}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
530 COMMAND "${DC}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
531 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
532 COMMENT "Generating header for ${source}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
533 DEPENDS ${source} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
534 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
535 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
536 else(NOT "${file_name}" STREQUAL "QGlobal") ## DMD frontend crash on this file. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
537 add_custom_command(OUTPUT "${interface_file}" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
538 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
539 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
540 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
541 COMMENT "" |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
542 DEPENDS ${source} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
543 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
544 ) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
545 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
546 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
547 install(FILES ${interface_file} DESTINATION include/d/${inc_path}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
548 endforeach(source) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
549 endif(GENERATE_DI_FILES) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
550 endif("${all_req_found}" EQUAL 1) |
13 | 551 endforeach(package_big ${packages_big}) |
552 if(GENERATE_DI_FILES) | |
553 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) | |
554 endif(GENERATE_DI_FILES) | |
7 | 555 |
42 | 556 add_subdirectory(generator) |
27
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
557 ## Dependences. |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
558 foreach(package ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
559 add_dependencies(cpp_${package} dgen) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
560 endforeach(package ${packages}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
561 add_sources_for_generating(${files_for_gen}) |
a9626891eca6
CMake: generator will work only for needed packages.
SokoL_SD
parents:
24
diff
changeset
|
562 |
7 | 563 ##-------------------------------------------- |
564 ## Build other parts of the QtD. | |
565 ##-------------------------------------------- | |
566 if(BUILD_EXAMPLES) | |
4 | 567 add_subdirectory(demos) |
568 add_subdirectory(examples) | |
16 | 569 endif(BUILD_EXAMPLES) |
570 | |
571 | |
572 ##-------------------------------------------- | |
573 ## CPack. | |
574 ##-------------------------------------------- | |
575 set(CPACK_PACKAGE_VERSION_PATCH 1) | |
576 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt") | |
577 set(CPACK_PACKAGE_VENDOR "QtD team") | |
578 set(CPACK_PACKAGE_CONTACT "e@mail.ru" ) | |
579 SET(CPACK_PACKAGE_VERSION "0.1") | |
580 #set(CPACK_PACKAGE_VERSION_PATCH "${RFS_VERSION_BUILD}") | |
581 set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}") | |
582 set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
583 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
17 | 584 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
585 set(CPACK_GENERATOR "ZIP") | |
24 | 586 elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux) |
17 | 587 set(CPACK_GENERATOR "TBZ2;DEB;RPM") |
588 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | |
16 | 589 include(CPack) |