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