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