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