Mercurial > projects > qtd
annotate CMakeLists.txt @ 368:185df9220ea7
Fixed startsWith. Implemented meta-object members as ranges. Freed QMetaObject from stuff that belongs to MetaClass
author | Max Samukha <maxter@maxter.com> |
---|---|
date | Mon, 28 Jun 2010 21:29:32 +0300 |
parents | 3b0545d4d479 |
children | 7fd4b69378bf |
rev | line source |
---|---|
132 | 1 cmake_minimum_required(VERSION 2.6) |
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) | |
7 endif (NOT CMAKE_BUILD_TYPE) | |
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) |
17 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
18 | |
19 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
20 #add_definitions(-UNO_DEBUG) | |
21 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] ) | |
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 ) | |
36 endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) | |
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 |
344 | 54 set(all_packages Core Gui OpenGL Xml Svg Network WebKit 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 ) |
64 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
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 "") |
132 | 74 endif(D_VERSION EQUAL "1") |
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") |
132 | 82 endif (NOT IMPLIB) |
83 if(D_IS_MARS) | |
84 set(GEN_OPT ${GEN_OPT} --cpp_shared) | |
85 add_definitions(-DCPP_SHARED) | |
86 endif(D_IS_MARS) | |
344 | 87 endif(CMAKE_HOST_WIN32) |
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) | |
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
|
96 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON") |
243 | 97 if(BUILD_QT_${package_upper}) |
344 | 98 set(packages ${packages} ${package_big}) |
243 | 99 endif(BUILD_QT_${package_upper}) |
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
|
100 endforeach(package_big ${all_packages}) |
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
|
101 |
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
|
102 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
|
103 |
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
|
104 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
|
105 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
|
106 |
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
|
107 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
|
108 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
|
109 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
|
110 ${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
|
111 set(make_util $(MAKE)) |
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
|
112 else(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles") |
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
|
113 message(FATAL_ERROR "${CMAKE_GENERATOR} is not supported") |
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
|
114 endif(${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
|
115 |
239 | 116 if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
117 set(cd_path ${CMAKE_SOURCE_DIR}) | |
118 else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) | |
119 set(cd_path ${CMAKE_BINARY_DIR}/build) | |
120 endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) | |
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 make_native_path(cd_path) |
344 | 123 add_custom_command(TARGET main POST_BUILD |
124 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build | |
125 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} | |
126 COMMENT "" | |
127 ) | |
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
|
128 |
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
|
129 ## "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
|
130 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
|
131 add_custom_target(install |
344 | 132 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install |
133 COMMENT "" | |
134 ) | |
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 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
|
136 |
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
|
137 ##-------------------------------------------- |
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
|
138 ## CPack. |
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
|
139 ##-------------------------------------------- |
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
|
140 set(CPACK_PACKAGE_VERSION_PATCH 1) |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
141 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework.") |
241 | 142 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") |
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
|
143 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") |
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
|
144 set(CPACK_PACKAGE_VENDOR "QtD team") |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
145 set(CPACK_PACKAGE_CONTACT "e@mail.ru") |
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
|
146 SET(CPACK_PACKAGE_VERSION "0.1") |
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
|
147 set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}") |
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 set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") |
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
|
149 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") |
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 if(CMAKE_HOST_WIN32) |
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 set(CPACK_GENERATOR "ZIP") |
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
|
152 elseif(CMAKE_HOST_UNIX) |
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
|
153 set(CPACK_GENERATOR "TBZ2;DEB;RPM") |
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
|
154 endif(CMAKE_HOST_WIN32) |
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 include(CPack) |
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) | |
241 | 165 endif(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
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) |
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
|
174 |
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
|
175 # 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
|
176 if(CMAKE_HOST_WIN32) |
132 | 177 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") |
344 | 178 endif(CMAKE_HOST_WIN32) |
132 | 179 |
229 | 180 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
|
181 set(D_FLAGS -version=cpp_shared) |
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
|
182 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
|
183 set(CPP_SHARED 1 CACHE INTERNAL "") |
229 | 184 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) |
185 | |
273 | 186 if(UNITTEST) |
187 add_d_versions(QtdUnittest) | |
344 | 188 set(D_FLAGS ${D_FLAGS} -unittest) |
273 | 189 endif(UNITTEST) |
190 | |
274 | 191 if(VERBOSE_DEBUG) |
192 add_d_debugs(QtdVerbose) | |
193 endif(VERBOSE_DEBUG) | |
194 | |
344 | 195 if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") |
196 add_d_debugs(QtdDebug) | |
197 endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug") | |
198 | |
132 | 199 ## 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
|
200 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
|
201 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "") |
344 | 202 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
|
203 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "") |
132 | 204 |
205 ##-------------------------------------------- | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
206 ## Macros and functions. |
132 | 207 ##-------------------------------------------- |
208 | |
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
|
209 macro(load_generated_classes ) |
237 | 210 include(${CMAKE_BINARY_DIR}/cpp/qt_${package}/qt_${package}.txt) |
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
|
211 endmacro(load_generated_classes ) |
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
|
212 |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
213 macro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
214 set (params NAME OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
215 qtd_parse_params (RESOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
216 if(NAME_tmp) |
344 | 217 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
|
218 endif(NAME_tmp) |
344 | 219 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" |
220 "Generate" ${RESOURCES_tmp}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
221 endmacro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
222 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
223 macro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
224 set (params OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
225 qtd_parse_params (UI params ${ARGN}) |
344 | 226 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" |
227 "Generate" ${UI_tmp}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
228 endmacro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
229 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
230 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
|
231 foreach(file "${ARGN}") |
344 | 232 ## Test if the input file exists |
233 get_filename_component(file_path ${file} PATH) | |
234 get_filename_component(file_name ${file} NAME_WE) | |
235 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
|
236 |
344 | 237 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) |
238 add_custom_command(OUTPUT "${out}" | |
239 COMMAND "${command}" | |
240 ARGS ${options} ${file} -o ${out} | |
241 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
242 DEPENDS ${file} | |
243 COMMENT "${comment} ${file}" | |
244 ) | |
245 set(${output} ${${output}} ${out}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
246 endforeach(file "${ARGN}") |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
247 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
|
248 |
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
|
249 ## Parses the parameters list. |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
250 macro(qtd_parse_params default params) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
251 set(type_tmp ${default}) |
344 | 252 set(params_tmp ${default} ${${params}}) |
253 foreach(param_tmp ${params_tmp}) | |
254 set(${param_tmp}_tmp ) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
255 endforeach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
256 foreach(arg_tmp ${ARGN}) |
344 | 257 set(found_type_tmp) |
258 if(NOT found_type_tmp) | |
259 foreach(param_tmp ${params_tmp}) | |
260 if(arg_tmp STREQUAL param_tmp) | |
261 set(type_tmp ${param_tmp}) | |
262 set(found_type_tmp 1) | |
263 break(param_tmp ${params_tmp}) | |
264 endif(arg_tmp STREQUAL param_tmp) | |
265 endforeach(param_tmp ${params_tmp}) | |
266 endif(NOT found_type_tmp) | |
267 if(NOT found_type_tmp) | |
268 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) | |
269 endif(NOT found_type_tmp) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
270 endforeach(arg_tmp ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
271 endmacro(qtd_parse_params default) |
132 | 272 |
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
|
273 ## Adds a new example. |
132 | 274 ## name -- example name. |
275 ## Options: | |
344 | 276 ## PACKAGES -- list of packages for link to example (for example, QtCore QtGui QtOpenGL). |
277 ## Default value is "QtCore QtGui". | |
132 | 278 ## params -- sources d files. |
279 ## Usage: | |
344 | 280 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) |
132 | 281 macro(build_example name) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
282 set (params UIC RESOURCES PACKAGES) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
283 qtd_parse_params (SOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
284 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
285 if(NOT PACKAGES_tmp) |
344 | 286 set(PACKAGES_tmp QtCore QtGui) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
287 endif(NOT PACKAGES_tmp) |
344 | 288 |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
289 if(RESOURCES_tmp) |
344 | 290 if(NOT BUILD_TOOLS) |
291 message(STATUS "Example '${name}' requires drcc. Example will not be built") | |
292 return(build_example name) | |
293 endif(NOT BUILD_TOOLS) | |
294 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
295 endif(RESOURCES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
296 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
297 if(UIC_tmp) |
344 | 298 if(NOT BUILD_TOOLS) |
299 message(STATUS "Example '${name}' requires drcc. Example will not be built") | |
300 return(build_example name) | |
301 endif(NOT BUILD_TOOLS) | |
302 qtd_wrap_ui(uic_sources ${UIC_tmp}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
303 endif(UIC_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
304 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
305 foreach(package ${PACKAGES_tmp}) |
344 | 306 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") |
307 set(is_found) | |
308 foreach(package_big ${packages_big}) | |
309 string(TOLOWER ${package_big} package) | |
310 if(${req} STREQUAL ${package_big}) | |
311 set(is_found 1) | |
312 break(package_big ${packages_big}) | |
313 endif(${req} STREQUAL ${package_big}) | |
314 endforeach(package_big ${packages_big}) | |
315 if(NOT is_found) | |
316 message(STATUS "Example '${name}' requires the package '${req}', but it is not active. Example will not be built") | |
317 return(build_example name) | |
318 else(NOT is_found) | |
319 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) | |
320 endif(NOT is_found) | |
321 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
|
322 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} |
344 | 323 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} |
324 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
|
325 ## 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
|
326 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## |
344 | 327 # 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
|
328 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) |
237 | 329 add_dependencies(examples ${name}) |
330 add_dependencies(${name} allpackages tools) | |
132 | 331 endmacro(build_example sources) |
332 | |
333 ##-------------------------------------------- | |
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
|
334 ## Build and install the QtD libraries. |
132 | 335 ##-------------------------------------------- |
336 | |
337 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
338 add_custom_target(allpackages) | |
339 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | |
340 | |
341 foreach(package_big ${all_packages}) | |
344 | 342 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
|
343 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
|
344 ## Load settings for the package. |
132 | 345 set(required) |
346 set(d_objs) | |
347 set(cpp_objs) | |
348 set(d_sources) | |
349 set(cpp_sources) | |
350 set(lib_name) | |
351 set(link_cpp) | |
352 set(link_d) | |
353 set(cpp_files) | |
227 | 354 set(cpp_generated_files) |
344 | 355 set(d_qt_files) |
356 set(d_qtd_files) | |
132 | 357 set(classes) |
358 set(d_generated_files) | |
359 set(link_example) | |
344 | 360 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) |
132 | 361 |
362 set(all_req_found 1) | |
363 if(BUILD_QT_${package_upper}) | |
344 | 364 foreach(req ${required}) |
365 set(req_found) | |
366 foreach(pack ${packages_big}) | |
367 if(${pack} STREQUAL ${req}) | |
368 set(req_found 1) | |
369 endif(${pack} STREQUAL ${req}) | |
370 endforeach(pack ${packages}) | |
371 if(NOT req_found) | |
372 set(req_found) | |
373 foreach(pack ${all_packages}) | |
374 if(${pack} STREQUAL ${req}) | |
375 set(req_found 1) | |
376 endif(${pack} STREQUAL ${req}) | |
377 endforeach(pack ${all_packages}) | |
378 if(req_found) | |
379 message(STATUS "Package '${package_big}' requires '${req}', but it is not active") | |
380 else(req_found) | |
381 message(STATUS "Package '${package_big}' requires '${req}', but it is not found") | |
382 endif(req_found) | |
383 set(all_req_found) | |
384 endif(NOT req_found) | |
385 endforeach(req ${required}) | |
132 | 386 else(BUILD_QT_${package_upper}) |
344 | 387 set(all_req_found) |
132 | 388 endif(BUILD_QT_${package_upper}) |
344 | 389 |
132 | 390 if("${all_req_found}" EQUAL 1) |
344 | 391 set(packages_big ${packages_big} ${package_big}) |
392 set(packages ${packages} ${package}) | |
393 ## Load a package sources list. | |
394 foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) | |
395 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) | |
396 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) | |
397 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) | |
398 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) | |
399 endforeach(d_source ${d_generated_files}) | |
400 set(classes ArrayOps ${classes}) | |
401 foreach(class ${classes}) | |
402 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) | |
403 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) | |
404 if(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
405 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
406 endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) | |
407 endforeach(class ${classes}) | |
408 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) | |
409 | |
410 foreach (cpp_source ${cpp_files}) | |
411 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) | |
412 endforeach(cpp_source ${cpp_files}) | |
413 foreach (cpp_source ${cpp_generated_files}) | |
414 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp) | |
415 endforeach(cpp_source ${cpp_generated_files}) | |
416 foreach(d_source ${d_qt_files}) | |
417 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qt/${d_source}.d) | |
418 endforeach(d_source ${d_qt_files}) | |
419 foreach(d_source ${d_qtd_files}) | |
420 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qtd/${d_source}.d) | |
421 endforeach(d_source ${d_qtd_files}) | |
132 | 422 |
344 | 423 if(NOT GENERATE_DI_FILES) |
424 foreach(d_source ${d_sources}) | |
425 get_filename_component(path ${d_source} PATH) | |
426 get_filename_component(name ${d_source} NAME_WE) | |
427 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) | |
428 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
|
429 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/d${D_VERSION}) |
344 | 430 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") |
431 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") | |
432 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) | |
433 endforeach(d_source ${d_sources}) | |
434 endif(NOT GENERATE_DI_FILES) | |
132 | 435 |
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
|
436 ### Build the CPP part. |
344 | 437 if(CPP_SHARED) |
438 set(cpp_method SHARED) | |
439 else(CPP_SHARED) | |
440 set(cpp_method STATIC) | |
441 endif(CPP_SHARED) | |
442 add_library(cpp_${package} ${cpp_method} ${cpp_sources}) | |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
443 set_target_properties(cpp_${package} PROPERTIES |
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
444 RUNTIME_OUTPUT_DIRECTORY lib |
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
445 ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles |
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
446 LINK_FLAGS -Wl,-enable-auto-import |
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
447 COMPILE_DEFINITIONS QTD_${package_upper} |
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
448 ) |
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
|
449 |
344 | 450 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) |
451 if(CPP_SHARED) | |
452 else(CPP_SHARED) | |
453 ## Get an objects list. It will be used in building the D part. | |
454 foreach(cpp_source ${cpp_sources}) | |
455 set(cpp_source ${cpp_source}) | |
456 obj_path(cpp_source) | |
457 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) | |
458 endforeach(cpp_source ${cpp_sources}) | |
459 endif(CPP_SHARED) | |
132 | 460 |
344 | 461 ## Settings for the D part. |
462 set(lib_name qtd${package}) | |
463 if(BUILD_SHARED_LIBRARIES) | |
464 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
465 set(build_type SHARED) | |
466 else(BUILD_SHARED_LIBRARIES) | |
467 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) | |
468 set(build_type STATIC) | |
469 endif(BUILD_SHARED_LIBRARIES) | |
132 | 470 |
344 | 471 ## Package dependencies. |
472 foreach(req ${required}) | |
473 set(is_found) | |
474 foreach(pack ${packages_big}) | |
475 if("${pack}" STREQUAL "${req}") | |
476 set(is_found 1) | |
477 break(pack ${packages_big}) | |
478 endif("${pack}" STREQUAL "${req}") | |
479 endforeach(pack ${packages_big}) | |
480 if(NOT is_found) | |
481 message(FATAL_ERROR "Package ${package_big} requires ${req}, but it is not found") | |
482 endif(NOT is_found) | |
483 string(TOUPPER ${req} req_upper) | |
484 string(TOLOWER ${req} req_lower) | |
485 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) | |
486 endforeach(req ${require}) | |
487 target_link_libraries(cpp_${package} ${link_cpp} ) | |
488 set(d_objs ${d_objs} ${objects}) | |
132 | 489 |
344 | 490 if(CPP_SHARED) |
491 ## Create an implib library which will be linked to the D part. | |
492 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll) | |
493 set(cpp_lib_native ${cpp_lib}) | |
494 make_native_path(cpp_lib_native) | |
495 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) | |
496 set(d_implib_native ${d_implib}) | |
497 make_native_path(d_implib_native) | |
498 add_custom_command( | |
499 OUTPUT "${d_implib}" | |
500 COMMAND "${IMPLIB}" | |
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
|
501 ARGS /system /PAGESIZE:64 ${d_implib_native} ${cpp_lib_native} |
344 | 502 DEPENDS "cpp_${package}" |
503 COMMENT "Creating implib ${lib_name}" | |
504 ) | |
505 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) | |
506 else(CPP_SHARED) | |
507 set(${package}_lib_param Qt${package_big}) | |
508 endif(CPP_SHARED) | |
509 ## Link the D part. | |
510 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} | |
511 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} ) | |
512 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) | |
513 ## Paths for the QtD libs. It is necessary for examples. | |
514 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) | |
132 | 515 |
344 | 516 ## Generate dependences for make (or nmake). |
517 add_custom_target(${package}) | |
518 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
|
519 |
344 | 520 add_dependencies(${lib_name} cpp_${package}) |
521 foreach(depend ${required}) | |
522 string(TOLOWER ${depend} depend) | |
523 add_dependencies(cpp_${package} cpp_${depend}) | |
524 add_dependencies(${package} ${depend}) | |
525 endforeach(depend ${required}) | |
526 add_dependencies(allpackages ${package}) | |
527 | |
363
3b0545d4d479
Fixed enums in designated interfaces
Max Samukha <maxter@maxter.com>
parents:
357
diff
changeset
|
528 ## TODO: Do we need to generate *.di files? |
344 | 529 if(GENERATE_DI_FILES) |
530 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) | |
531 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) | |
532 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | |
533 foreach(source ${d_sources}) | |
534 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
535 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | |
536 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") | |
537 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") | |
538 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) | |
539 set(interface_file "${interface_file_path}/${file_name}.di") | |
540 if(NOT "${file_name}" STREQUAL "QGlobal") | |
541 add_custom_command(OUTPUT "${interface_file}" | |
542 COMMAND "${DC}" | |
543 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} | |
544 COMMENT "Generating header for ${source}" | |
545 DEPENDS ${source} | |
546 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
547 ) | |
548 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file. | |
549 add_custom_command(OUTPUT "${interface_file}" | |
550 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} | |
551 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} | |
552 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} | |
553 COMMENT "" | |
554 DEPENDS ${source} | |
555 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
556 ) | |
557 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) | |
558 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) | |
559 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) | |
560 endforeach(source) | |
561 endif(GENERATE_DI_FILES) | |
132 | 562 endif("${all_req_found}" EQUAL 1) |
563 endforeach(package_big ${packages_big}) | |
344 | 564 if(GENERATE_DI_FILES) |
132 | 565 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) |
566 endif(GENERATE_DI_FILES) | |
567 | |
568 set(CPACK_COMPONENTS_ALL qtd qtd_tools) | |
569 | |
570 ##-------------------------------------------- | |
571 ## Build other parts of the QtD. | |
572 ##-------------------------------------------- | |
237 | 573 |
132 | 574 if(BUILD_TOOLS) |
237 | 575 add_custom_target(tools ALL) |
132 | 576 add_subdirectory(tools) |
577 add_dependencies(tools drcc duic) | |
578 endif(BUILD_TOOLS) | |
579 | |
580 if(BUILD_EXAMPLES) | |
237 | 581 add_custom_target(examples ALL) |
582 add_dependencies(examples allpackages tools) | |
132 | 583 add_subdirectory(demos) |
584 add_subdirectory(examples) | |
585 endif(BUILD_EXAMPLES) | |
586 | |
239 | 587 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
|
588 |
344 | 589 endif(NOT SECOND_RUN) |