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