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