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