Mercurial > projects > qtd
annotate CMakeLists.txt @ 242:f2f4c9cbadc2
Fix #28.
You cannot build in the sources folder by default but can override this behavior using ALLOW_IN_SOURCE_BUILDS option. However, in this case you'll have to use 'cmake . && make' instead of make. Otherwise, the generator won't start.
author | SokoL_SD |
---|---|
date | Mon, 20 Jul 2009 09:33:10 +0000 |
parents | e792a5287673 |
children | e4cbe1e9ded6 |
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 |
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
|
4 ########################################################## |
237 | 5 ## Building generator && settings. |
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
|
6 ########################################################## |
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
|
7 if(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
|
8 |
242 | 9 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF") |
10 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) | |
239 | 11 message(FATAL_ERROR "In-source builds are not allowed. |
241 | 12 Please create a directory and run cmake from there, passing the path |
239 | 13 to this source directory as the last argument. |
241 | 14 This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. |
239 | 15 Please delete them. |
241 | 16 |
242 | 17 Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not |
239 | 18 recomended. |
19 ") | |
242 | 20 endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) |
239 | 21 |
132 | 22 FIND_PACKAGE(Qt4 REQUIRED) |
227 | 23 set (QT_USE_QTMAIN false) |
24 set (QT_USE_QTGUI false) | |
132 | 25 |
26 ##-------------------------------------------- | |
27 ## Settings. | |
28 ##-------------------------------------------- | |
29 | |
30 ## Options. | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
31 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
|
32 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF") |
132 | 33 option(BUILD_TOOLS "Build tools" "ON") |
34 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
35 set(GENERATE_DI_FILES OFF) ## Very experemental option. Temporary disabled. |
132 | 36 |
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
|
37 set(all_packages Core Gui OpenGL Xml Svg Network WebKit CACHE INTERNAL "") |
132 | 38 |
39 ## Init D toolkit. | |
40 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | |
41 FIND_PACKAGE(D REQUIRED) | |
42 | |
43 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
44 set(CMAKE_INSTALL_PREFIX | |
241 | 45 ${DC_PATH} CACHE PATH "QtD install prefix" |
132 | 46 ) |
47 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") | |
48 | |
49 # Check D compiler version | |
50 if(D_VERSION EQUAL "1") | |
51 if (D_FRONTEND LESS "041") | |
52 message(STATUS "Minimum required version of D compiler is 1.041 (or compiler based on this version)") | |
53 endif(D_FRONTEND LESS "041") | |
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
|
54 set(D_TARGET d1-tango CACHE INTERNAL "") |
132 | 55 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
|
56 set(D_TARGET d2-phobos CACHE INTERNAL "") |
132 | 57 endif(D_VERSION EQUAL "1") |
58 | |
59 # Debug and release flags. | |
60 if (NOT CMAKE_BUILD_TYPE) | |
61 set(CMAKE_BUILD_TYPE Release) | |
62 endif (NOT CMAKE_BUILD_TYPE) | |
63 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
64 set(CMAKE_BUILD_TYPE Debug) | |
65 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) | |
66 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) | |
67 add_definitions(-DDEBUG) | |
68 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
69 message(STATUS "Only debug and release configurations are supproted now. Configuration will change to 'Release'") | |
70 set(CMAKE_BUILD_TYPE Release) | |
71 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) | |
72 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) | |
73 #add_definitions(-UNO_DEBUG) | |
74 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] ) | |
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) | |
81 message(FATAL_ERROR "implib not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") | |
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) | |
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
|
87 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
|
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}) |
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
|
94 string(TOLOWER ${package_big} package) |
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
|
95 string(TOUPPER ${package_big} package_upper) |
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") |
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
|
97 set(packages ${packages} ${package}) |
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
|
98 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
|
99 |
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 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
|
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_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
|
103 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
|
104 |
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 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
|
106 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
|
107 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
|
108 ${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
|
109 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
|
110 else(${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
|
111 message(FATAL_ERROR "${CMAKE_GENERATOR} isn't supported") |
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 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
|
113 |
239 | 114 if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
115 set(cd_path ${CMAKE_SOURCE_DIR}) | |
116 else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) | |
117 set(cd_path ${CMAKE_BINARY_DIR}/build) | |
118 endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) | |
119 | |
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
|
120 make_native_path(cd_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
|
121 add_custom_command(TARGET main POST_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
|
122 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build |
237 | 123 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} |
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
|
124 COMMENT "" |
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 ) |
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 ## Make commands. |
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_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
|
129 add_custom_target(install |
240 | 130 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install |
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
|
131 COMMENT "" |
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
|
132 ) |
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
|
133 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
|
134 |
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 ##-------------------------------------------- |
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 ## 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
|
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 set(CPACK_PACKAGE_VERSION_PATCH 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
|
139 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework. |
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 QtD is a D binding to the Qt application and UI framework. |
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
|
141 This package installs binding and static library for qt port on D programming language. |
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 ") |
241 | 143 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
|
144 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
|
145 set(CPACK_PACKAGE_VENDOR "QtD team") |
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_CONTACT "e@mail.ru" ) |
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_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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 |
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
|
158 ########################################################## |
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 ## Building QtD. |
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 ########################################################## |
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 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
|
162 |
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
|
163 PROJECT(qtd CXX C) |
240 | 164 if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
165 load_cache(${CMAKE_BINARY_DIR}/.. INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION) | |
241 | 166 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
|
167 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
|
168 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
|
169 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
|
170 |
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 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
|
172 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
|
173 |
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 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
|
175 |
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 # 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
|
177 if(CMAKE_HOST_WIN32) |
132 | 178 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") |
179 endif(CMAKE_HOST_WIN32) | |
180 | |
229 | 181 if(CMAKE_HOST_WIN32 AND D_IS_MARS) |
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
|
182 set(CPP_SHARED 1 CACHE INTERNAL "") |
229 | 183 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) |
184 | |
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
|
185 if(D_IS_MARS) |
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
|
186 set(D_FLAGS -version=cpp_shared) |
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
|
187 add_definitions(-DCPP_SHARED) |
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
|
188 endif(D_IS_MARS) |
132 | 189 |
190 ## 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
|
191 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
|
192 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic 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
|
193 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION} 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
|
194 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "") |
132 | 195 |
196 ##-------------------------------------------- | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
197 ## Macros and functions. |
132 | 198 ##-------------------------------------------- |
199 | |
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 macro(load_generated_classes ) |
237 | 201 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
|
202 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
|
203 |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
204 macro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
205 set (params NAME OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
206 qtd_parse_params (RESOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
207 if(NAME_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
208 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
209 endif(NAME_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
210 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
211 "Generate" ${RESOURCES_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
212 endmacro(qtd_add_resource output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
213 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
214 macro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
215 set (params OPTIONS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
216 qtd_parse_params (UI params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
217 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
218 "Generate" ${UI_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
219 endmacro(qtd_wrap_ui output) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
220 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
221 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
|
222 foreach(file "${ARGN}") |
241 | 223 ## Test an exist of the input file. |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
224 get_filename_component(file_path ${file} PATH) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
225 get_filename_component(file_name ${file} NAME_WE) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
226 get_filename_component(file_ext ${file} EXT) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
227 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
228 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) |
132 | 229 add_custom_command(OUTPUT "${out}" |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
230 COMMAND "${command}" |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
231 ARGS ${options} ${file} -o ${out} |
132 | 232 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
233 DEPENDS ${file} |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
234 COMMENT "${comment} ${file}" |
132 | 235 ) |
236 set(${output} ${${output}} ${out}) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
237 endforeach(file "${ARGN}") |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
238 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
|
239 |
241 | 240 ## Parsing the parameters list. |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
241 macro(qtd_parse_params default params) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
242 set(type_tmp ${default}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
243 set(params_tmp ${default} ${${params}}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
244 foreach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
245 set(${param_tmp}_tmp ) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
246 endforeach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
247 foreach(arg_tmp ${ARGN}) |
241 | 248 set(found_type_tmp) |
249 if(NOT found_type_tmp) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
250 foreach(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
251 if(arg_tmp STREQUAL param_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
252 set(type_tmp ${param_tmp}) |
241 | 253 set(found_type_tmp 1) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
254 break(param_tmp ${params_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
255 endif(arg_tmp STREQUAL param_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
256 endforeach(param_tmp ${params_tmp}) |
241 | 257 endif(NOT found_type_tmp) |
258 if(NOT found_type_tmp) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
259 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) |
241 | 260 endif(NOT found_type_tmp) |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
261 endforeach(arg_tmp ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
262 endmacro(qtd_parse_params default) |
132 | 263 |
264 ## Build example macro. | |
265 ## name -- example name. | |
266 ## Options: | |
267 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL). | |
268 ## Default value is "QtCore QtGui". | |
269 ## params -- sources d files. | |
270 ## Usage: | |
271 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) | |
272 macro(build_example name) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
273 set (params UIC RESOURCES PACKAGES) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
274 qtd_parse_params (SOURCES params ${ARGN}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
275 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
276 if(NOT PACKAGES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
277 set(PACKAGES_tmp QtCore QtGui) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
278 endif(NOT PACKAGES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
279 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
280 if(RESOURCES_tmp) |
132 | 281 if(NOT BUILD_TOOLS) |
282 message(STATUS "Example '${name}' required drcc. Example will not build") | |
283 return(build_example name) | |
284 endif(NOT BUILD_TOOLS) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
285 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
286 endif(RESOURCES_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
287 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
288 if(UIC_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
289 if(NOT BUILD_TOOLS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
290 message(STATUS "Example '${name}' required drcc. Example will not build") |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
291 return(build_example name) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
292 endif(NOT BUILD_TOOLS) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
293 qtd_wrap_ui(uic_sources ${UIC_tmp}) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
294 endif(UIC_tmp) |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
295 |
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
296 foreach(package ${PACKAGES_tmp}) |
132 | 297 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") |
298 set(is_founded) | |
299 foreach(package_big ${packages_big}) | |
300 string(TOLOWER ${package_big} package) | |
301 if(${req} STREQUAL ${package_big}) | |
302 set(is_founded 1) | |
303 break(package_big ${packages_big}) | |
304 endif(${req} STREQUAL ${package_big}) | |
305 endforeach(package_big ${packages_big}) | |
306 if(NOT is_founded) | |
307 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build") | |
308 return(build_example name) | |
309 else(NOT is_founded) | |
310 set(qtd_libs ${${package}_lib_param} ${qtd_libs}) | |
311 endif(NOT is_founded) | |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
312 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
|
313 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} |
182
973564c7e388
CMake: add an UIC option in the build_example macro.
SokoL_SD
parents:
177
diff
changeset
|
314 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} |
132 | 315 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib LIBS ${qtd_libs}) |
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
|
316 ## TODO: Enable. |
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
|
317 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND 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
|
318 # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") |
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
|
319 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) |
237 | 320 add_dependencies(examples ${name}) |
321 add_dependencies(${name} allpackages tools) | |
132 | 322 endmacro(build_example sources) |
323 | |
324 ##-------------------------------------------- | |
325 ## Build and install library. | |
326 ##-------------------------------------------- | |
327 | |
328 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
329 add_custom_target(allpackages) | |
330 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) | |
331 | |
332 foreach(package_big ${all_packages}) | |
333 string(TOLOWER ${package_big} package) | |
334 ## Loading settings for package. | |
335 set(required) | |
336 set(d_objs) | |
337 set(cpp_objs) | |
338 set(d_sources) | |
339 set(cpp_sources) | |
340 set(lib_name) | |
341 set(link_cpp) | |
342 set(link_d) | |
343 set(cpp_files) | |
227 | 344 set(cpp_generated_files) |
132 | 345 set(d_files) |
346 set(classes) | |
347 set(d_generated_files) | |
348 set(d_version_files) | |
349 set(link_example) | |
350 include (${CMAKE_SOURCE_DIR}/build/${package}.txt) | |
351 | |
352 set(all_req_found 1) | |
353 string(TOUPPER ${package} package_upper) | |
354 if(BUILD_QT_${package_upper}) | |
355 foreach(req ${required}) | |
356 set(req_found) | |
357 foreach(pack ${packages_big}) | |
358 if(${pack} STREQUAL ${req}) | |
359 set(req_found 1) | |
360 endif(${pack} STREQUAL ${req}) | |
361 endforeach(pack ${packages}) | |
362 if(NOT req_found) | |
363 set(req_found) | |
364 foreach(pack ${all_packages}) | |
365 if(${pack} STREQUAL ${req}) | |
366 set(req_found 1) | |
367 endif(${pack} STREQUAL ${req}) | |
368 endforeach(pack ${all_packages}) | |
369 if(req_found) | |
370 message(STATUS "Package '${package_big}' required '${req}', but its not active") | |
371 else(req_found) | |
372 message(STATUS "Package '${package_big}' required '${req}', but its not found") | |
373 endif(req_found) | |
374 set(all_req_found) | |
375 endif(NOT req_found) | |
376 endforeach(req ${required}) | |
377 else(BUILD_QT_${package_upper}) | |
378 set(all_req_found) | |
379 endif(BUILD_QT_${package_upper}) | |
380 | |
381 ## TODO: cleanup. | |
382 if("${all_req_found}" EQUAL 1) | |
383 set(packages_big ${packages_big} ${package_big}) | |
384 set(packages ${packages} ${package}) | |
385 ## Loading package sources list. | |
177 | 386 foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) |
132 | 387 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) |
388 endforeach(d_source ${d_generated_files}) | |
389 set(classes ArrayOps ${classes}) | |
390 foreach(class ${classes}) | |
391 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) | |
392 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) | |
393 endforeach(class ${classes}) | |
394 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) | |
395 | |
396 foreach (cpp_source ${cpp_files}) | |
397 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) | |
227 | 398 endforeach(cpp_source ${cpp_files}) |
399 foreach (cpp_source ${cpp_generated_files}) | |
400 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp) | |
401 endforeach(cpp_source ${cpp_generated_files}) | |
132 | 402 foreach(d_source ${d_version_files}) |
403 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d) | |
404 endforeach(d_source ${d_version_files}) | |
405 foreach(d_source ${d_files}) | |
406 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d) | |
407 endforeach(d_source ${d_files}) | |
408 | |
409 if(NOT GENERATE_DI_FILES) | |
410 foreach(d_source ${d_sources}) | |
411 get_filename_component(path ${d_source} PATH) | |
412 get_filename_component(name ${d_source} NAME_WE) | |
413 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) | |
414 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}) | |
415 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/qt/d${D_VERSION}) | |
416 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") | |
417 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") | |
418 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) | |
419 install(FILES ${path}/${name}_enum.d DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}_enum.di OPTIONAL) | |
420 endforeach(d_source ${d_sources}) | |
421 endif(NOT GENERATE_DI_FILES) | |
422 | |
423 ## Link CPP library. | |
229 | 424 if(CPP_SHARED) |
425 set(cpp_method SHARED) | |
426 else(CPP_SHARED) | |
427 set(cpp_method STATIC) | |
428 endif(CPP_SHARED) | |
429 add_library(cpp_${package} ${cpp_method} ${cpp_sources}) | |
132 | 430 set_property(TARGET cpp_${package} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) |
229 | 431 if(CPP_SHARED) |
432 else(CPP_SHARED) | |
132 | 433 foreach(cpp_source ${cpp_sources}) |
434 set(cpp_source ${cpp_source}) | |
435 obj_path(cpp_source) | |
436 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) | |
437 endforeach(cpp_source ${cpp_sources}) | |
229 | 438 endif(CPP_SHARED) |
132 | 439 |
440 ## Link D library. | |
441 set(lib_name qtd${package}) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
442 if(BUILD_SHARED_LIBRARIES) |
132 | 443 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) |
444 set(build_type SHARED) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
445 else(BUILD_SHARED_LIBRARIES) |
132 | 446 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) |
447 set(build_type STATIC) | |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
448 endif(BUILD_SHARED_LIBRARIES) |
132 | 449 |
450 foreach(req ${required}) | |
451 set(is_found) | |
452 foreach(pack ${packages_big}) | |
453 if("${pack}" STREQUAL "${req}") | |
454 set(is_found 1) | |
455 break(pack ${packages_big}) | |
456 endif("${pack}" STREQUAL "${req}") | |
457 endforeach(pack ${packages_big}) | |
458 if(NOT is_found) | |
459 message(FATAL_ERROR "Package ${package_big} required ${req}, but its not found") | |
460 endif(NOT is_found) | |
461 string(TOUPPER ${req} req_upper) | |
462 string(TOLOWER ${req} req_lower) | |
463 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) | |
464 endforeach(req ${require}) | |
465 set(d_objs ${d_objs} ${objects}) | |
466 | |
467 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) | |
468 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) | |
469 string(TOUPPER ${package} package_upper) | |
470 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) | |
471 target_link_libraries(cpp_${package} ${link_cpp} ) | |
229 | 472 if(CPP_SHARED) |
136
798e54c1f66e
CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents:
135
diff
changeset
|
473 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll) |
132 | 474 set(cpp_lib_native ${cpp_lib}) |
475 make_native_path(cpp_lib_native) | |
476 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) | |
477 set(d_implib_native ${d_implib}) | |
478 make_native_path(d_implib_native) | |
479 add_custom_command( | |
480 OUTPUT "${d_implib}" | |
481 COMMAND "${IMPLIB}" | |
482 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native} | |
483 DEPENDS "cpp_${package}" | |
484 COMMENT "Creating implib ${lib_name}" | |
485 ) | |
486 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) | |
229 | 487 else(CPP_SHARED) |
132 | 488 set(${package}_lib_param Qt${package_big}) ## Paths for QtD libs. Needed by examples. |
229 | 489 endif(CPP_SHARED) |
215 | 490 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} |
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
|
491 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} ) |
132 | 492 |
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
|
493 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) |
132 | 494 ## Paths for QtD libs. Needed by examples. |
495 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) | |
496 | |
497 ## Dependences. | |
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
|
498 add_custom_target(${package}) |
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
|
499 add_dependencies(${package} ${lib_name}) |
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
|
500 add_dependencies(${lib_name} cpp_${package}) |
132 | 501 foreach(depend ${required}) |
502 string(TOLOWER ${depend} depend) | |
503 add_dependencies(cpp_${package} cpp_${depend}) | |
504 add_dependencies(${package} ${depend}) | |
505 endforeach(depend ${required}) | |
506 add_dependencies(allpackages ${package}) | |
507 | |
508 if(GENERATE_DI_FILES) | |
509 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) | |
510 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) | |
511 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | |
512 foreach(source ${d_sources}) | |
513 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
514 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | |
515 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") | |
516 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") | |
517 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) | |
518 set(interface_file "${interface_file_path}/${file_name}.di") | |
519 if(NOT "${file_name}" STREQUAL "QGlobal") | |
520 add_custom_command(OUTPUT "${interface_file}" | |
521 COMMAND "${DC}" | |
522 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} | |
523 COMMENT "Generating header for ${source}" | |
524 DEPENDS ${source} | |
525 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
526 ) | |
241 | 527 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file. |
132 | 528 add_custom_command(OUTPUT "${interface_file}" |
529 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} | |
530 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} | |
531 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} | |
532 COMMENT "" | |
533 DEPENDS ${source} | |
534 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
535 ) | |
536 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) | |
537 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) | |
538 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) | |
539 endforeach(source) | |
540 endif(GENERATE_DI_FILES) | |
541 endif("${all_req_found}" EQUAL 1) | |
542 endforeach(package_big ${packages_big}) | |
543 if(GENERATE_DI_FILES) | |
544 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) | |
545 endif(GENERATE_DI_FILES) | |
546 | |
547 set(CPACK_COMPONENTS_ALL qtd qtd_tools) | |
548 | |
549 ##-------------------------------------------- | |
550 ## Build other parts of the QtD. | |
551 ##-------------------------------------------- | |
237 | 552 |
132 | 553 if(BUILD_TOOLS) |
237 | 554 add_custom_target(tools ALL) |
132 | 555 add_subdirectory(tools) |
556 add_dependencies(tools drcc duic) | |
557 endif(BUILD_TOOLS) | |
558 | |
559 if(BUILD_EXAMPLES) | |
237 | 560 add_custom_target(examples ALL) |
561 add_dependencies(examples allpackages tools) | |
132 | 562 add_subdirectory(demos) |
563 add_subdirectory(examples) | |
564 endif(BUILD_EXAMPLES) | |
565 | |
239 | 566 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
|
567 |
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
|
568 endif(NOT SECOND_RUN) |