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