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