Mercurial > projects > qtd
annotate CMakeLists.txt @ 186:d5af7c48b733
fix for 64but
author | eldar |
---|---|
date | Sat, 04 Jul 2009 13:41:21 +0000 |
parents | 973564c7e388 |
children | ba7abb5c9e03 |
rev | line source |
---|---|
132 | 1 cmake_minimum_required(VERSION 2.6) |
2 PROJECT(qtd CXX C) | |
3 FIND_PACKAGE(Qt4 REQUIRED) | |
4 | |
5 ##-------------------------------------------- | |
6 ## Settings. | |
7 ##-------------------------------------------- | |
8 | |
9 include_directories(${QT_INCLUDES} include ${CMAKE_CURRENT_BINARY_DIR}/include) | |
10 | |
11 ## Options. | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
12 option(BUILD_EXAMPLES "Build examples" "OFF") |
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
13 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF") |
132 | 14 option(BUILD_TOOLS "Build tools" "ON") |
15 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
16 set(GENERATE_DI_FILES OFF) ## Very experemental option. Temporary disabled. |
132 | 17 |
18 set(QTD_VERSION_STR ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}) | |
19 math(EXPR QTD_VERSION "(${QT_VERSION_MAJOR} << 16) + (${QT_VERSION_MINOR} << 8) + ${QT_VERSION_PATCH}") | |
20 configure_file(qt/QGlobal.d.inc qt/QGlobal.d) | |
21 | |
22 set(all_packages Core Gui OpenGL Xml Svg Network WebKit) | |
23 | |
24 ## Init D toolkit. | |
25 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | |
26 FIND_PACKAGE(D REQUIRED) | |
27 | |
28 ## Strip utility. | |
29 find_program(STRIP strip) | |
30 | |
31 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
32 set(CMAKE_INSTALL_PREFIX | |
33 ${DC_PATH} CACHE PATH "QtD install prefix" FORCE | |
34 ) | |
35 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
36 | |
37 # Check D compiler version | |
38 if(D_VERSION EQUAL "1") | |
39 if (D_FRONTEND LESS "041") | |
40 message(STATUS "Minimum required version of D compiler is 1.041 (or compiler based on this version)") | |
41 endif(D_FRONTEND LESS "041") | |
42 set(D_TARGET d1-tango) | |
43 elseif(D_VERSION EQUAL "2") | |
44 set(D_TARGET ) ## TODO: hm... I don`t known this parameter for D2 ^( | |
45 endif(D_VERSION EQUAL "1") | |
46 | |
47 # Debug and release flags. | |
48 if (NOT CMAKE_BUILD_TYPE) | |
49 set(CMAKE_BUILD_TYPE Release) | |
50 endif (NOT CMAKE_BUILD_TYPE) | |
51 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
52 set(CMAKE_BUILD_TYPE Debug) | |
53 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) | |
54 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) | |
55 add_definitions(-DDEBUG) | |
56 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
57 message(STATUS "Only debug and release configurations are supproted now. Configuration will change to 'Release'") | |
58 set(CMAKE_BUILD_TYPE Release) | |
59 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
60 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
61 #add_definitions(-UNO_DEBUG) | |
62 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] ) | |
63 | |
64 # System specifc settings. | |
65 if(CMAKE_HOST_WIN32) | |
66 set(implib implib) | |
67 find_program(IMPLIB ${implib}) | |
68 if (NOT IMPLIB) | |
69 message(FATAL_ERROR "implib not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") | |
70 endif (NOT IMPLIB) | |
71 if(D_IS_MARS) | |
72 set(D_FLAGS ${D_FLAGS} -version=cpp_shared) | |
73 set(GEN_OPT ${GEN_OPT} --cpp_shared) | |
74 add_definitions(-DCPP_SHARED) | |
75 endif(D_IS_MARS) | |
76 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") | |
77 endif(CMAKE_HOST_WIN32) | |
78 | |
79 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) | |
80 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) | |
81 | |
82 ## Bootstrap settings for QtD. | |
83 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
84 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic) |
132 | 85 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}) |
86 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib) | |
87 | |
88 ##-------------------------------------------- | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
89 ## Macros and functions. |
132 | 90 ##-------------------------------------------- |
91 | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
92 macro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
93 set (params NAME OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
94 qtd_parse_params (RESOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
95 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
96 if(NAME_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
97 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
98 endif(NAME_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
99 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
100 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
101 "Generate" ${RESOURCES_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
102 endmacro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
103 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
104 macro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
105 set (params OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
106 qtd_parse_params (UI params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
107 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
108 "Generate" ${UI_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
109 endmacro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
110 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
111 macro(qtd_command output command options prefix comment) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
112 foreach(file "${ARGN}") |
132 | 113 ## Test input file exists. |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
114 get_filename_component(file_path ${file} PATH) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
115 get_filename_component(file_name ${file} NAME_WE) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
116 get_filename_component(file_ext ${file} EXT) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
117 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
118 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) |
132 | 119 add_custom_command(OUTPUT "${out}" |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
120 COMMAND "${command}" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
121 ARGS ${options} ${file} -o ${out} |
132 | 122 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
123 DEPENDS ${file} |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
124 COMMENT "${comment} ${file}" |
132 | 125 ) |
126 set(${output} ${${output}} ${out}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
127 endforeach(file "${ARGN}") |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
128 endmacro(qtd_command output command options files prefix comment) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
129 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
130 ## Parse the parameters list. |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
131 macro(qtd_parse_params default params) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
132 set(type_tmp ${default}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
133 set(params_tmp ${default} ${${params}}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
134 foreach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
135 set(${param_tmp}_tmp ) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
136 endforeach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
137 foreach(arg_tmp ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
138 set(founded_type_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
139 if(NOT founded_type_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
140 foreach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
141 if(arg_tmp STREQUAL param_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
142 set(type_tmp ${param_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
143 set(founded_type_tmp 1) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
144 break(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
145 endif(arg_tmp STREQUAL param_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
146 endforeach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
147 endif(NOT founded_type_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
148 if(NOT founded_type_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
149 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
150 endif(NOT founded_type_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
151 endforeach(arg_tmp ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
152 endmacro(qtd_parse_params default) |
132 | 153 |
154 ## Build example macro. | |
155 ## name -- example name. | |
156 ## Options: | |
157 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL). | |
158 ## Default value is "QtCore QtGui". | |
159 ## params -- sources d files. | |
160 ## Usage: | |
161 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) | |
162 macro(build_example name) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
163 set (params UIC RESOURCES PACKAGES) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
164 qtd_parse_params (SOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
165 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
166 if(NOT PACKAGES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
167 set(PACKAGES_tmp QtCore QtGui) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
168 endif(NOT PACKAGES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
169 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
170 if(RESOURCES_tmp) |
132 | 171 if(NOT BUILD_TOOLS) |
172 message(STATUS "Example '${name}' required drcc. Example will not build") | |
173 return(build_example name) | |
174 endif(NOT BUILD_TOOLS) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
175 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
176 endif(RESOURCES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
177 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
178 if(UIC_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
179 if(NOT BUILD_TOOLS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
180 message(STATUS "Example '${name}' required drcc. Example will not build") |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
181 return(build_example name) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
182 endif(NOT BUILD_TOOLS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
183 qtd_wrap_ui(uic_sources ${UIC_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
184 endif(UIC_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
185 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
186 foreach(package ${PACKAGES_tmp}) |
132 | 187 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") |
188 set(is_founded) | |
189 foreach(package_big ${packages_big}) | |
190 string(TOLOWER ${package_big} package) | |
191 if(${req} STREQUAL ${package_big}) | |
192 set(is_founded 1) | |
193 break(package_big ${packages_big}) | |
194 endif(${req} STREQUAL ${package_big}) | |
195 endforeach(package_big ${packages_big}) | |
196 if(NOT is_founded) | |
197 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build") | |
198 return(build_example name) | |
199 else(NOT is_founded) | |
200 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) | |
201 endif(NOT is_founded) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
202 endforeach(package ${PACKAGES_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
203 add_d_program(${name} ${SOURCES_tmp} ${res_sources} ${uic_sources} |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
204 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} |
132 | 205 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib LIBS ${qtd_libs}) |
206 ## TODO: Enable on windows too. | |
207 if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## | |
208 add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") | |
209 endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) | |
210 add_dependencies(${name} allpackages) | |
211 endmacro(build_example sources) | |
212 | |
213 ##-------------------------------------------- | |
214 ## Build and install library. | |
215 ##-------------------------------------------- | |
216 | |
217 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
218 add_custom_target(allpackages) | |
219 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | |
220 | |
221 foreach(package_big ${all_packages}) | |
222 string(TOLOWER ${package_big} package) | |
223 ## Loading settings for package. | |
224 set(required) | |
225 set(d_objs) | |
226 set(cpp_objs) | |
227 set(d_sources) | |
228 set(cpp_sources) | |
229 set(lib_name) | |
230 set(link_cpp) | |
231 set(link_d) | |
232 set(cpp_files) | |
233 set(d_files) | |
234 set(classes) | |
235 set(d_generated_files) | |
236 set(d_version_files) | |
237 set(link_example) | |
238 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) | |
239 | |
240 set(all_req_found 1) | |
241 string(TOUPPER ${package} package_upper) | |
242 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON") | |
243 if(BUILD_QT_${package_upper}) | |
244 foreach(req ${required}) | |
245 set(req_found) | |
246 foreach(pack ${packages_big}) | |
247 if(${pack} STREQUAL ${req}) | |
248 set(req_found 1) | |
249 endif(${pack} STREQUAL ${req}) | |
250 endforeach(pack ${packages}) | |
251 if(NOT req_found) | |
252 set(req_found) | |
253 foreach(pack ${all_packages}) | |
254 if(${pack} STREQUAL ${req}) | |
255 set(req_found 1) | |
256 endif(${pack} STREQUAL ${req}) | |
257 endforeach(pack ${all_packages}) | |
258 if(req_found) | |
259 message(STATUS "Package '${package_big}' required '${req}', but its not active") | |
260 else(req_found) | |
261 message(STATUS "Package '${package_big}' required '${req}', but its not found") | |
262 endif(req_found) | |
263 set(all_req_found) | |
264 endif(NOT req_found) | |
265 endforeach(req ${required}) | |
266 else(BUILD_QT_${package_upper}) | |
267 set(all_req_found) | |
268 endif(BUILD_QT_${package_upper}) | |
269 | |
270 ## TODO: cleanup. | |
271 if("${all_req_found}" EQUAL 1) | |
272 set(packages_big ${packages_big} ${package_big}) | |
273 set(packages ${packages} ${package}) | |
274 ## Loading package sources list. | |
177 | 275 foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) |
132 | 276 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) |
277 endforeach(d_source ${d_generated_files}) | |
278 set(classes ArrayOps ${classes}) | |
279 foreach(class ${classes}) | |
280 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) | |
281 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) | |
282 endforeach(class ${classes}) | |
283 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) | |
284 | |
285 foreach (cpp_source ${cpp_files}) | |
286 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) | |
287 endforeach(cpp_source) | |
288 foreach(d_source ${d_version_files}) | |
289 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d) | |
290 endforeach(d_source ${d_version_files}) | |
291 foreach(d_source ${d_files}) | |
292 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d) | |
293 endforeach(d_source ${d_files}) | |
294 | |
295 if(NOT GENERATE_DI_FILES) | |
296 foreach(d_source ${d_sources}) | |
297 get_filename_component(path ${d_source} PATH) | |
298 get_filename_component(name ${d_source} NAME_WE) | |
299 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) | |
300 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}) | |
301 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/qt/d${D_VERSION}) | |
302 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") | |
303 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") | |
304 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) | |
305 install(FILES ${path}/${name}_enum.d DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}_enum.di OPTIONAL) | |
306 endforeach(d_source ${d_sources}) | |
307 endif(NOT GENERATE_DI_FILES) | |
308 | |
309 ## Link CPP library. | |
310 add_library(cpp_${package} SHARED ${cpp_sources}) | |
311 set_property(TARGET cpp_${package} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) | |
312 if(CMAKE_HOST_WIN32 AND D_IS_MARS) ## TODO: Replace by SEPAREATE_CPP_PART | |
313 else(CMAKE_HOST_WIN32 AND D_IS_MARS) | |
314 foreach(cpp_source ${cpp_sources}) | |
315 set(cpp_source ${cpp_source}) | |
316 obj_path(cpp_source) | |
317 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) | |
318 endforeach(cpp_source ${cpp_sources}) | |
319 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) | |
320 | |
321 ## Link D library. | |
322 set(lib_name qtd${package}) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
323 if(BUILD_SHARED_LIBRARIES) |
132 | 324 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) |
325 set(build_type SHARED) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
326 else(BUILD_SHARED_LIBRARIES) |
132 | 327 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) |
328 set(build_type STATIC) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
329 endif(BUILD_SHARED_LIBRARIES) |
132 | 330 |
331 foreach(req ${required}) | |
332 set(is_found) | |
333 foreach(pack ${packages_big}) | |
334 if("${pack}" STREQUAL "${req}") | |
335 set(is_found 1) | |
336 break(pack ${packages_big}) | |
337 endif("${pack}" STREQUAL "${req}") | |
338 endforeach(pack ${packages_big}) | |
339 if(NOT is_found) | |
340 message(FATAL_ERROR "Package ${package_big} required ${req}, but its not found") | |
341 endif(NOT is_found) | |
342 string(TOUPPER ${req} req_upper) | |
343 string(TOLOWER ${req} req_lower) | |
344 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) | |
345 endforeach(req ${require}) | |
346 set(d_objs ${d_objs} ${objects}) | |
347 | |
348 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) | |
349 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) | |
350 string(TOUPPER ${package} package_upper) | |
351 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) | |
352 target_link_libraries(cpp_${package} ${link_cpp} ) | |
353 if(CMAKE_HOST_WIN32 AND D_IS_MARS) ## TODO: Replace by SEPAREATE_CPP_PART | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
354 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll) |
132 | 355 set(cpp_lib_native ${cpp_lib}) |
356 make_native_path(cpp_lib_native) | |
357 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) | |
358 set(d_implib_native ${d_implib}) | |
359 make_native_path(d_implib_native) | |
360 add_custom_command( | |
361 OUTPUT "${d_implib}" | |
362 COMMAND "${IMPLIB}" | |
363 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native} | |
364 DEPENDS "cpp_${package}" | |
365 COMMENT "Creating implib ${lib_name}" | |
366 ) | |
367 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) | |
368 else(CMAKE_HOST_WIN32 AND D_IS_MARS) | |
369 set(${package}_lib_param Qt${package_big}) ## Paths for QtD libs. Needed by examples. | |
370 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) | |
371 add_d_target(${lib_name} TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} | |
372 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib}) | |
373 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) | |
374 | |
375 ## Paths for QtD libs. Needed by examples. | |
376 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) | |
377 | |
378 ## Dependences. | |
379 add_custom_target(${package} DEPENDS ${lib}) | |
380 foreach(depend ${required}) | |
381 string(TOLOWER ${depend} depend) | |
382 add_dependencies(cpp_${package} cpp_${depend}) | |
383 add_dependencies(${package} ${depend}) | |
384 endforeach(depend ${required}) | |
385 add_dependencies(allpackages ${package}) | |
386 | |
387 if(GENERATE_DI_FILES) | |
388 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) | |
389 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) | |
390 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | |
391 foreach(source ${d_sources}) | |
392 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
393 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | |
394 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") | |
395 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") | |
396 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) | |
397 set(interface_file "${interface_file_path}/${file_name}.di") | |
398 if(NOT "${file_name}" STREQUAL "QGlobal") | |
399 add_custom_command(OUTPUT "${interface_file}" | |
400 COMMAND "${DC}" | |
401 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} | |
402 COMMENT "Generating header for ${source}" | |
403 DEPENDS ${source} | |
404 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
405 ) | |
406 else(NOT "${file_name}" STREQUAL "QGlobal") ## DMD frontend crash on this file. | |
407 add_custom_command(OUTPUT "${interface_file}" | |
408 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} | |
409 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} | |
410 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} | |
411 COMMENT "" | |
412 DEPENDS ${source} | |
413 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
414 ) | |
415 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) | |
416 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) | |
417 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) | |
418 endforeach(source) | |
419 endif(GENERATE_DI_FILES) | |
420 endif("${all_req_found}" EQUAL 1) | |
421 endforeach(package_big ${packages_big}) | |
422 if(GENERATE_DI_FILES) | |
423 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) | |
424 endif(GENERATE_DI_FILES) | |
425 | |
426 add_subdirectory(generator) | |
427 ## Dependences. | |
428 foreach(package ${packages}) | |
429 add_dependencies(cpp_${package} dgen) | |
430 endforeach(package ${packages}) | |
431 add_sources_for_generating(${files_for_gen}) | |
432 | |
433 set(CPACK_COMPONENTS_ALL qtd qtd_tools) | |
434 | |
435 ##-------------------------------------------- | |
436 ## Build other parts of the QtD. | |
437 ##-------------------------------------------- | |
438 add_custom_target(tools ALL) | |
439 if(BUILD_TOOLS) | |
440 add_subdirectory(tools) | |
441 add_dependencies(tools drcc duic) | |
442 endif(BUILD_TOOLS) | |
443 | |
444 if(BUILD_EXAMPLES) | |
445 add_subdirectory(demos) | |
446 add_subdirectory(examples) | |
447 endif(BUILD_EXAMPLES) | |
448 | |
449 ##-------------------------------------------- | |
450 ## CPack. | |
451 ##-------------------------------------------- | |
452 set(CPACK_PACKAGE_VERSION_PATCH 1) | |
453 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework. | |
454 QtD is a D binding to the Qt application and UI framework. | |
455 This package installs binding and static library for qt port on D programming language. | |
456 ") | |
457 #SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt") | |
458 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") | |
459 set(CPACK_PACKAGE_VENDOR "QtD team") | |
460 set(CPACK_PACKAGE_CONTACT "e@mail.ru" ) | |
461 SET(CPACK_PACKAGE_VERSION "0.1") | |
462 #set(CPACK_PACKAGE_VERSION_PATCH "${RFS_VERSION_BUILD}") | |
463 set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}") | |
464 set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
465 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
466 if(CMAKE_HOST_WIN32) | |
467 set(CPACK_GENERATOR "ZIP") | |
468 elseif(CMAKE_HOST_UNIX) | |
469 set(CPACK_GENERATOR "TBZ2;DEB;RPM") | |
470 endif(CMAKE_HOST_WIN32) | |
16 | 471 include(CPack) |