Mercurial > projects > qtd
annotate CMakeLists.txt @ 383:bd7f485e3573
More debug fixes
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Mon, 12 Jul 2010 22:50:58 +0300 |
parents | 347e4c7a9ba1 |
children | d2f48c4cb3e3 |
rev | line source |
---|---|
376
06d8188a23e3
Revert requirement of cmake 2.8@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
375
diff
changeset
|
1 cmake_minimum_required(VERSION 2.6) |
132 | 2 PROJECT(qtd CXX C) |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
3 |
344 | 4 # Debug and release flags. |
5 if (NOT CMAKE_BUILD_TYPE) | |
6 set(CMAKE_BUILD_TYPE Release) | |
375 | 7 endif () |
344 | 8 |
9 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
10 set(CMAKE_BUILD_TYPE Debug) | |
11 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) | |
12 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) | |
13 add_definitions(-DDEBUG) | |
14 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
15 message(STATUS "Only debug and release configurations are supported. The configuration is changed to 'Release'") |
344 | 16 set(CMAKE_BUILD_TYPE Release) |
375 | 17 endif () |
344 | 18 |
19 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
20 #add_definitions(-UNO_DEBUG) | |
375 | 21 endif() |
344 | 22 |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
23 ########################################################## |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
24 ## Build generator. |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
25 ########################################################## |
344 | 26 if (NOT SECOND_RUN) |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
27 |
242 | 28 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF") |
344 | 29 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) |
30 message(FATAL_ERROR "In-source builds are not allowed. " | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
31 "Please create a directory and run cmake from there, passing the path " |
344 | 32 "to this source directory as the last argument. " |
33 "This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. Please delete them. " | |
34 "Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not recommended." | |
35 ) | |
375 | 36 endif () |
239 | 37 |
132 | 38 FIND_PACKAGE(Qt4 REQUIRED) |
344 | 39 set(QT_USE_QTMAIN false) |
40 set(QT_USE_QTGUI false) | |
132 | 41 |
42 ##-------------------------------------------- | |
43 ## Settings. | |
44 ##-------------------------------------------- | |
45 | |
46 ## Options. | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
47 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
|
48 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF") |
132 | 49 option(BUILD_TOOLS "Build tools" "ON") |
50 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") | |
344 | 51 set(GENERATE_DI_FILES OFF) ## Very experimental option. Temporarily disabled. |
274 | 52 option(VERBOSE_DEBUG "Verbose debug" "OFF") |
273 | 53 |
378 | 54 set(all_packages Core Gui OpenGL Xml Svg Network WebKit Qwt CACHE INTERNAL "") |
132 | 55 |
56 ## Init D toolkit. | |
57 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | |
58 FIND_PACKAGE(D REQUIRED) | |
59 | |
60 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
61 set(CMAKE_INSTALL_PREFIX | |
344 | 62 ${DC_PATH} CACHE PATH "QtD install prefix" |
132 | 63 ) |
375 | 64 endif() |
132 | 65 |
66 # Check D compiler version | |
67 if(D_VERSION EQUAL "1") | |
282
256ab6cb8e85
Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents:
280
diff
changeset
|
68 if (D_FRONTEND LESS "050") |
344 | 69 message(STATUS "Minimum required version of D compiler is 1.050 (or compiler based on this version)") |
282
256ab6cb8e85
Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents:
280
diff
changeset
|
70 endif(D_FRONTEND LESS "050") |
344 | 71 set(D_TARGET d1-tango CACHE INTERNAL "") |
132 | 72 elseif(D_VERSION EQUAL "2") |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
73 set(D_TARGET d2-phobos CACHE INTERNAL "") |
375 | 74 endif() |
132 | 75 |
237 | 76 # System specific settings. |
132 | 77 if(CMAKE_HOST_WIN32) |
78 set(implib implib) | |
79 find_program(IMPLIB ${implib}) | |
80 if (NOT IMPLIB) | |
344 | 81 message(FATAL_ERROR "implib is not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") |
375 | 82 endif () |
132 | 83 if(D_IS_MARS) |
84 set(GEN_OPT ${GEN_OPT} --cpp_shared) | |
375 | 85 endif() |
86 endif() | |
87 add_definitions(-DCPP_SHARED) | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
88 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
89 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
90 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
91 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
92 set(packages CACHE INTERNAL "") |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
93 foreach(package_big ${all_packages}) |
344 | 94 string(TOLOWER ${package_big} package) |
95 string(TOUPPER ${package_big} package_upper) | |
378 | 96 set(package_default_option "ON") |
97 if(${package_big} STREQUAL "Qwt") | |
98 set(package_default_option "OFF") | |
99 endif() | |
100 option(BUILD_QT_${package_upper} "Build Qt${package_big}" ${package_default_option}) | |
243 | 101 if(BUILD_QT_${package_upper}) |
375 | 102 set(packages ${packages} ${package_big}) |
103 endif() | |
104 endforeach() | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
105 |
378 | 106 set(QWT_INCLUDE_PATH "/usr/include/qwt-qt4" CACHE STRING "Qwt include path") |
381
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
107 if(CMAKE_HOST_WIN32) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
108 set(QWT_LIB_PATH "" CACHE STRING "Qwt lib path") |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
109 endif() |
378 | 110 set(inc_paths "") |
111 | |
112 if(CMAKE_HOST_WIN32) | |
381
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
113 set(sep "*") |
378 | 114 else() |
115 set(sep ":") | |
116 endif() | |
117 | |
118 if(BUILD_QT_QWT) | |
381
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
119 set(inc_paths ${inc_paths}${sep}${QWT_INCLUDE_PATH}${sep}) |
378 | 120 endif() |
121 | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
122 add_subdirectory(generator) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
123 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
124 add_custom_target(main ALL) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
125 add_dependencies(main dgen) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
126 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
127 if(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles") |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
128 set(make_util nmake) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
129 elseif(${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles" OR |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
130 ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
131 set(make_util $(MAKE)) |
375 | 132 else() |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
133 message(FATAL_ERROR "${CMAKE_GENERATOR} is not supported") |
375 | 134 endif() |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
135 |
239 | 136 if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
137 set(cd_path ${CMAKE_SOURCE_DIR}) | |
375 | 138 else() |
239 | 139 set(cd_path ${CMAKE_BINARY_DIR}/build) |
375 | 140 endif() |
239 | 141 |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
142 make_native_path(cd_path) |
344 | 143 add_custom_command(TARGET main POST_BUILD |
144 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build | |
145 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} | |
146 COMMENT "" | |
147 ) | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
148 |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
149 ## "Make install" command. |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
150 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
151 add_custom_target(install |
344 | 152 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install |
153 COMMENT "" | |
154 ) | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
155 add_dependencies(install preinstall) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
156 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
157 ########################################################## |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
158 ## Build QtD. |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
159 ########################################################## |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
160 else(NOT SECOND_RUN) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
161 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
162 PROJECT(qtd CXX C) |
240 | 163 if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
164 load_cache(${CMAKE_BINARY_DIR}/.. INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION) | |
375 | 165 endif() |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
166 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
167 FIND_PACKAGE(D REQUIRED) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
168 FIND_PACKAGE(Qt4 REQUIRED) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
169 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
170 set(QTD_VERSION_STR ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}) |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
171 math(EXPR QTD_VERSION "(${QT_VERSION_MAJOR} << 16) + (${QT_VERSION_MINOR} << 8) + ${QT_VERSION_PATCH}") |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
172 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
173 include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) |
381
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
174 if(BUILD_QT_QWT) |
378 | 175 include_directories(${QWT_INCLUDE_PATH}) |
176 endif() | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
177 |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
178 # System specifc settings. |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
179 if(CMAKE_HOST_WIN32) |
132 | 180 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") |
375 | 181 endif() |
132 | 182 |
229 | 183 if(CMAKE_HOST_WIN32 AND D_IS_MARS) |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
184 set(D_FLAGS -version=cpp_shared) |
375 | 185 endif() |
186 add_definitions(-DCPP_SHARED) | |
187 set(CPP_SHARED 1 CACHE INTERNAL "") | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
188 |
229 | 189 |
273 | 190 if(UNITTEST) |
191 add_d_versions(QtdUnittest) | |
344 | 192 set(D_FLAGS ${D_FLAGS} -unittest) |
375 | 193 endif() |
273 | 194 |
274 | 195 if(VERBOSE_DEBUG) |
196 add_d_debugs(QtdVerbose) | |
375 | 197 endif() |
274 | 198 |
344 | 199 if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") |
200 add_d_debugs(QtdDebug) | |
375 | 201 endif() |
344 | 202 |
132 | 203 ## Bootstrap settings for QtD. |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
204 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc CACHE INTERNAL "") |
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
205 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "") |
344 | 206 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/d${D_VERSION} CACHE INTERNAL "") |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
207 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "") |
132 | 208 |
209 ##-------------------------------------------- | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
210 ## Macros and functions. |
132 | 211 ##-------------------------------------------- |
212 | |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
213 macro(load_generated_classes ) |
237 | 214 include(${CMAKE_BINARY_DIR}/cpp/qt_${package}/qt_${package}.txt) |
375 | 215 endmacro() |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
216 |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
217 macro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
218 set (params NAME OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
219 qtd_parse_params (RESOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
220 if(NAME_tmp) |
344 | 221 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp}) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
222 endif(NAME_tmp) |
344 | 223 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" |
224 "Generate" ${RESOURCES_tmp}) | |
375 | 225 endmacro() |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
226 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
227 macro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
228 set (params OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
229 qtd_parse_params (UI params ${ARGN}) |
344 | 230 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" |
231 "Generate" ${UI_tmp}) | |
375 | 232 endmacro() |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
233 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
234 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
|
235 foreach(file "${ARGN}") |
375 | 236 ## Test if the input file exists |
237 get_filename_component(file_path ${file} PATH) | |
238 get_filename_component(file_name ${file} NAME_WE) | |
239 get_filename_component(file_ext ${file} EXT) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
240 |
375 | 241 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) |
242 add_custom_command(OUTPUT "${out}" | |
344 | 243 COMMAND "${command}" |
244 ARGS ${options} ${file} -o ${out} | |
245 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
246 DEPENDS ${file} | |
247 COMMENT "${comment} ${file}" | |
248 ) | |
375 | 249 set(${output} ${${output}} ${out}) |
250 endforeach() | |
251 endmacro() | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
252 |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
253 ## Parses the parameters list. |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
254 macro(qtd_parse_params default params) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
255 set(type_tmp ${default}) |
344 | 256 set(params_tmp ${default} ${${params}}) |
257 foreach(param_tmp ${params_tmp}) | |
375 | 258 set(${param_tmp}_tmp ) |
259 endforeach() | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
260 foreach(arg_tmp ${ARGN}) |
375 | 261 set(found_type_tmp) |
262 if(NOT found_type_tmp) | |
263 foreach(param_tmp ${params_tmp}) | |
264 if(arg_tmp STREQUAL param_tmp) | |
265 set(type_tmp ${param_tmp}) | |
266 set(found_type_tmp 1) | |
267 break(param_tmp ${params_tmp}) | |
268 endif() | |
269 endforeach() | |
270 endif() | |
271 if(NOT found_type_tmp) | |
272 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) | |
273 endif() | |
274 endforeach() | |
275 endmacro() | |
132 | 276 |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
277 ## Adds a new example. |
132 | 278 ## name -- example name. |
279 ## Options: | |
344 | 280 ## PACKAGES -- list of packages for link to example (for example, QtCore QtGui QtOpenGL). |
281 ## Default value is "QtCore QtGui". | |
132 | 282 ## params -- sources d files. |
283 ## Usage: | |
344 | 284 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) |
132 | 285 macro(build_example name) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
286 set (params UIC RESOURCES PACKAGES) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
287 qtd_parse_params (SOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
288 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
289 if(NOT PACKAGES_tmp) |
375 | 290 set(PACKAGES_tmp QtCore QtGui) |
291 endif() | |
344 | 292 |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
293 if(RESOURCES_tmp) |
375 | 294 if(NOT BUILD_TOOLS) |
295 message(STATUS "Example '${name}' requires drcc. Example will not be built") | |
296 return(build_example name) | |
297 endif() | |
298 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) | |
299 endif() | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
300 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
301 if(UIC_tmp) |
375 | 302 if(NOT BUILD_TOOLS) |
303 message(STATUS "Example '${name}' requires drcc. Example will not be built") | |
304 return(build_example name) | |
305 endif() | |
306 qtd_wrap_ui(uic_sources ${UIC_tmp}) | |
307 endif() | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
308 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
309 foreach(package ${PACKAGES_tmp}) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
310 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
311 set(is_found) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
312 foreach(package_big ${packages_big}) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
313 string(TOLOWER ${package_big} package) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
314 if(${req} STREQUAL ${package_big}) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
315 set(is_found 1) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
316 break(package_big ${packages_big}) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
317 endif() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
318 endforeach() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
319 if(NOT is_found) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
320 message(STATUS "Example '${name}' requires the package '${req}', but it is not active. Example will not be built") |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
321 return(build_example name) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
322 else() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
323 set(qtd_libs cpp_${package} ${${package}_lib_param} ${qtd_libs}) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
324 endif() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
325 endforeach() |
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
|
326 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} |
344 | 327 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} |
328 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib ${QT_LIBRARY_DIR} LIBS ${qtd_libs}) | |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
329 ## TODO: Uncomment. |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
330 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## |
344 | 331 # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
332 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) |
237 | 333 add_dependencies(examples ${name}) |
334 add_dependencies(${name} allpackages tools) | |
375 | 335 endmacro() |
132 | 336 |
337 ##-------------------------------------------- | |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
338 ## Build and install the QtD libraries. |
132 | 339 ##-------------------------------------------- |
340 | |
341 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
342 add_custom_target(allpackages) | |
343 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | |
344 | |
345 foreach(package_big ${all_packages}) | |
344 | 346 string(TOLOWER ${package_big} package) |
264
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
347 string(TOUPPER ${package} package_upper) |
da7c867ef2ef
1) A bug is fixed when the generator doesn't restart if typesystem_${package}-java.java has been changed.
SokoL_SD
parents:
254
diff
changeset
|
348 ## Load settings for the package. |
132 | 349 set(required) |
350 set(d_objs) | |
351 set(cpp_objs) | |
352 set(d_sources) | |
353 set(cpp_sources) | |
354 set(lib_name) | |
355 set(link_cpp) | |
356 set(link_d) | |
357 set(cpp_files) | |
227 | 358 set(cpp_generated_files) |
344 | 359 set(d_qt_files) |
360 set(d_qtd_files) | |
132 | 361 set(classes) |
362 set(d_generated_files) | |
363 set(link_example) | |
344 | 364 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) |
132 | 365 |
366 set(all_req_found 1) | |
367 if(BUILD_QT_${package_upper}) | |
378 | 368 foreach(req ${required}) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
369 set(req_found) |
378 | 370 foreach(pack ${packages_big}) |
371 if(${pack} STREQUAL ${req}) | |
372 set(req_found 1) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
373 endif() |
378 | 374 endforeach(pack ${packages}) |
375 if(NOT req_found) | |
376 set(req_found) | |
377 foreach(pack ${all_packages}) | |
378 if(${pack} STREQUAL ${req}) | |
379 set(req_found 1) | |
380 endif(${pack} STREQUAL ${req}) | |
381 endforeach(pack ${all_packages}) | |
382 if(req_found) | |
383 message(STATUS "Package '${package_big}' requires '${req}', but it is not active") | |
384 else() | |
385 message(STATUS "Package '${package_big}' requires '${req}', but it is not found") | |
386 endif() | |
387 set(all_req_found) | |
388 endif() | |
389 endforeach(req ${required}) | |
132 | 390 else(BUILD_QT_${package_upper}) |
378 | 391 set(all_req_found) |
132 | 392 endif(BUILD_QT_${package_upper}) |
344 | 393 |
132 | 394 if("${all_req_found}" EQUAL 1) |
344 | 395 set(packages_big ${packages_big} ${package_big}) |
396 set(packages ${packages} ${package}) | |
397 ## Load a package sources list. | |
398 foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) | |
399 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) | |
400 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) | |
401 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
402 endif() |
344 | 403 endforeach(d_source ${d_generated_files}) |
404 set(classes ArrayOps ${classes}) | |
405 foreach(class ${classes}) | |
406 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) | |
407 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) | |
408 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
409 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
410 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
411 endforeach(class ${classes}) | |
412 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) | |
413 | |
414 foreach (cpp_source ${cpp_files}) | |
415 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) | |
416 endforeach(cpp_source ${cpp_files}) | |
417 foreach (cpp_source ${cpp_generated_files}) | |
418 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp) | |
419 endforeach(cpp_source ${cpp_generated_files}) | |
420 foreach(d_source ${d_qt_files}) | |
421 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qt/${d_source}.d) | |
422 endforeach(d_source ${d_qt_files}) | |
423 foreach(d_source ${d_qtd_files}) | |
424 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qtd/${d_source}.d) | |
425 endforeach(d_source ${d_qtd_files}) | |
132 | 426 |
344 | 427 if(NOT GENERATE_DI_FILES) |
428 foreach(d_source ${d_sources}) | |
429 get_filename_component(path ${d_source} PATH) | |
430 get_filename_component(name ${d_source} NAME_WE) | |
431 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) | |
432 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}) | |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
433 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/d${D_VERSION}) |
344 | 434 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") |
435 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") | |
436 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) | |
437 endforeach(d_source ${d_sources}) | |
438 endif(NOT GENERATE_DI_FILES) | |
132 | 439 |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
440 ### Build the CPP part. |
344 | 441 if(CPP_SHARED) |
442 set(cpp_method SHARED) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
443 else() |
344 | 444 set(cpp_method STATIC) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
445 endif() |
344 | 446 add_library(cpp_${package} ${cpp_method} ${cpp_sources}) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
447 # FIXME, do less redundant |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
448 if(CMAKE_HOST_WIN32) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
449 set_target_properties(cpp_${package} PROPERTIES |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
450 RUNTIME_OUTPUT_DIRECTORY lib |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
451 ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
452 LINK_FLAGS -Wl,-enable-auto-import |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
453 COMPILE_DEFINITIONS QTD_${package_upper} |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
454 ) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
455 else() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
456 set_target_properties(cpp_${package} PROPERTIES |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
457 LIBRARY_OUTPUT_DIRECTORY lib |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
458 ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
459 COMPILE_DEFINITIONS QTD_${package_upper} |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
460 ) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
461 endif() |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
462 |
344 | 463 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
464 if(NOT CPP_SHARED) |
344 | 465 ## Get an objects list. It will be used in building the D part. |
466 foreach(cpp_source ${cpp_sources}) | |
467 set(cpp_source ${cpp_source}) | |
468 obj_path(cpp_source) | |
469 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) | |
470 endforeach(cpp_source ${cpp_sources}) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
471 endif() |
132 | 472 |
344 | 473 ## Settings for the D part. |
474 set(lib_name qtd${package}) | |
475 if(BUILD_SHARED_LIBRARIES) | |
476 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
477 set(build_type SHARED) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
478 else() |
344 | 479 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) |
480 set(build_type STATIC) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
481 endif() |
132 | 482 |
344 | 483 ## Package dependencies. |
484 foreach(req ${required}) | |
485 set(is_found) | |
486 foreach(pack ${packages_big}) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
487 if("${pack}" STREQUAL "${req}") |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
488 set(is_found 1) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
489 break(pack ${packages_big}) |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
490 endif() |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
491 endforeach() |
344 | 492 if(NOT is_found) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
493 message(FATAL_ERROR "Package ${package_big} requires ${req}, but it is not found") |
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
494 endif() |
344 | 495 string(TOUPPER ${req} req_upper) |
496 string(TOLOWER ${req} req_lower) | |
497 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) | |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
498 endforeach() |
381
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
499 |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
500 if(${package_big} STREQUAL "Qwt" AND CMAKE_HOST_WIN32) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
501 set(qwt_release_lib ${QWT_LIB_PATH}/libqwt5.a) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
502 set(qwt_debug_lib ${QWT_LIB_PATH}/libqwtd5.a) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
503 if(EXISTS ${qwt_release_lib}) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
504 set(qwt_lib ${qwt_release_lib}) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
505 elseif(EXISTS ${qwt_debug_lib}) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
506 set(qwt_lib ${qwt_debug_lib}) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
507 endif() |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
508 set(link_cpp ${link_cpp} ${qwt_lib}) |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
509 endif() |
347e4c7a9ba1
make QwtD compile on Windows@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
379
diff
changeset
|
510 |
344 | 511 target_link_libraries(cpp_${package} ${link_cpp} ) |
512 set(d_objs ${d_objs} ${objects}) | |
132 | 513 |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
514 if(CPP_SHARED) |
374
681af90e1d53
Removed debug writelns. Fixed build script.
Max Samukha <maxter@spambox.com>
parents:
372
diff
changeset
|
515 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}${CMAKE_SHARED_LIBRARY_SUFFIX}) |
344 | 516 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
517 |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
518 if(CMAKE_HOST_WIN32) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
519 ## Create an implib library which will be linked to the D part. |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
520 set(cpp_lib_native ${cpp_lib}) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
521 make_native_path(cpp_lib_native) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
522 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
523 set(d_implib_native ${d_implib}) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
524 make_native_path(d_implib_native) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
525 add_custom_command( |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
526 OUTPUT "${d_implib}" |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
527 COMMAND "${IMPLIB}" |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
528 ARGS /system /PAGESIZE:64 ${d_implib_native} ${cpp_lib_native} |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
529 DEPENDS "cpp_${package}" |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
530 COMMENT "Creating implib ${lib_name}" |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
531 ) |
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
532 endif() |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
533 else() |
344 | 534 set(${package}_lib_param Qt${package_big}) |
370
7fd4b69378bf
move cpp part of QtD into shared libs on linux to reduce binaries size
Eldar Insafutdinov
parents:
363
diff
changeset
|
535 endif() |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
370
diff
changeset
|
536 |
344 | 537 ## Link the D part. |
538 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} | |
539 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} ) | |
540 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) | |
541 ## Paths for the QtD libs. It is necessary for examples. | |
542 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) | |
132 | 543 |
344 | 544 ## Generate dependences for make (or nmake). |
545 add_custom_target(${package}) | |
546 add_dependencies(${package} ${lib_name}) | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
547 |
344 | 548 add_dependencies(${lib_name} cpp_${package}) |
549 foreach(depend ${required}) | |
550 string(TOLOWER ${depend} depend) | |
551 add_dependencies(cpp_${package} cpp_${depend}) | |
552 add_dependencies(${package} ${depend}) | |
553 endforeach(depend ${required}) | |
554 add_dependencies(allpackages ${package}) | |
555 | |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
556 ## TODO: Do we need to generate *.di files? |
344 | 557 if(GENERATE_DI_FILES) |
558 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) | |
559 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) | |
560 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | |
561 foreach(source ${d_sources}) | |
562 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
563 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | |
564 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") | |
565 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") | |
566 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) | |
567 set(interface_file "${interface_file_path}/${file_name}.di") | |
568 if(NOT "${file_name}" STREQUAL "QGlobal") | |
569 add_custom_command(OUTPUT "${interface_file}" | |
570 COMMAND "${DC}" | |
571 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} | |
572 COMMENT "Generating header for ${source}" | |
573 DEPENDS ${source} | |
574 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
575 ) | |
576 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file. | |
577 add_custom_command(OUTPUT "${interface_file}" | |
578 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} | |
579 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} | |
580 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} | |
581 COMMENT "" | |
582 DEPENDS ${source} | |
583 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
584 ) | |
585 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) | |
586 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) | |
587 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) | |
588 endforeach(source) | |
589 endif(GENERATE_DI_FILES) | |
132 | 590 endif("${all_req_found}" EQUAL 1) |
591 endforeach(package_big ${packages_big}) | |
344 | 592 if(GENERATE_DI_FILES) |
132 | 593 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) |
594 endif(GENERATE_DI_FILES) | |
595 | |
596 set(CPACK_COMPONENTS_ALL qtd qtd_tools) | |
597 | |
598 ##-------------------------------------------- | |
599 ## Build other parts of the QtD. | |
600 ##-------------------------------------------- | |
237 | 601 |
132 | 602 if(BUILD_TOOLS) |
237 | 603 add_custom_target(tools ALL) |
132 | 604 add_subdirectory(tools) |
605 add_dependencies(tools drcc duic) | |
606 endif(BUILD_TOOLS) | |
607 | |
608 if(BUILD_EXAMPLES) | |
237 | 609 add_custom_target(examples ALL) |
610 add_dependencies(examples allpackages tools) | |
132 | 611 add_subdirectory(demos) |
612 add_subdirectory(examples) | |
613 endif(BUILD_EXAMPLES) | |
614 | |
239 | 615 set(SECOND_RUN 0 CACHE INTERNAL "") |
235
b796329e8c38
We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents:
229
diff
changeset
|
616 |
344 | 617 endif(NOT SECOND_RUN) |
375 | 618 |
619 ##-------------------------------------------- | |
620 ## CPack. | |
621 ##-------------------------------------------- | |
622 set(CPACK_PACKAGE_VERSION_PATCH 1) | |
623 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework.") | |
624 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") | |
625 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") | |
626 set(CPACK_PACKAGE_VENDOR "QtD team") | |
627 set(CPACK_PACKAGE_CONTACT "e@mail.com") | |
376
06d8188a23e3
Revert requirement of cmake 2.8@
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
375
diff
changeset
|
628 set(CPACK_PACKAGE_VERSION "0.6") |
375 | 629 set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}") |
630 set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
631 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") | |
632 if(CMAKE_HOST_WIN32) | |
633 set(CPACK_GENERATOR "ZIP") | |
634 elseif(CMAKE_HOST_UNIX) | |
635 set(CPACK_GENERATOR "TBZ2;DEB") | |
636 endif() | |
637 include(CPack) |