@@ -0,0 +1,231 | |||||
|
1 | cmake_minimum_required(VERSION 2.8) | |||
|
2 | ||||
|
3 | #----------------------------------------------------------------------------- | |||
|
4 | # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details | |||
|
5 | # | |||
|
6 | ||||
|
7 | SET(project_policies | |||
|
8 | CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. | |||
|
9 | CMP0002 # NEW: Logical target names must be globally unique. | |||
|
10 | CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. | |||
|
11 | CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. | |||
|
12 | CMP0005 # NEW: Preprocessor definition values are now escaped automatically. | |||
|
13 | CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. | |||
|
14 | CMP0007 # NEW: List command no longer ignores empty elements. | |||
|
15 | CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. | |||
|
16 | CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. | |||
|
17 | CMP0010 # NEW: Bad variable reference syntax is an error. | |||
|
18 | CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. | |||
|
19 | CMP0012 # NEW: if() recognizes numbers and boolean constants. | |||
|
20 | CMP0013 # NEW: Duplicate binary directories are not allowed. | |||
|
21 | CMP0014 # NEW: Input directories must have CMakeLists.txt | |||
|
22 | ) | |||
|
23 | FOREACH(policy ${project_policies}) | |||
|
24 | IF(POLICY ${policy}) | |||
|
25 | CMAKE_POLICY(SET ${policy} NEW) | |||
|
26 | ENDIF() | |||
|
27 | ENDFOREACH() | |||
|
28 | ||||
|
29 | #----------------------------------------------------------------------------- | |||
|
30 | project(PythonQt) | |||
|
31 | #----------------------------------------------------------------------------- | |||
|
32 | ||||
|
33 | #----------------------------------------------------------------------------- | |||
|
34 | # Python libraries | |||
|
35 | ||||
|
36 | find_package(PythonLibs REQUIRED) | |||
|
37 | include_directories("${PYTHON_INCLUDE_DIR}") | |||
|
38 | add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK) | |||
|
39 | ||||
|
40 | #----------------------------------------------------------------------------- | |||
|
41 | # Build options | |||
|
42 | ||||
|
43 | foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns) | |||
|
44 | OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF) | |||
|
45 | endforeach() | |||
|
46 | ||||
|
47 | option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF) | |||
|
48 | if(PythonQt_DEBUG) | |||
|
49 | add_definitions(-DPYTHONQT_DEBUG) | |||
|
50 | else() | |||
|
51 | remove_definitions(-DPYTHONQT_DEBUG) | |||
|
52 | endif() | |||
|
53 | ||||
|
54 | #----------------------------------------------------------------------------- | |||
|
55 | # Setup Qt | |||
|
56 | ||||
|
57 | set(minimum_required_qt_version "4.6.2") | |||
|
58 | ||||
|
59 | find_package(Qt4) | |||
|
60 | ||||
|
61 | if(QT4_FOUND) | |||
|
62 | ||||
|
63 | set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}) | |||
|
64 | ||||
|
65 | if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version}) | |||
|
66 | message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.") | |||
|
67 | endif() | |||
|
68 | ||||
|
69 | # Enable required qt module | |||
|
70 | foreach(qtlib network opengl sql svg uitools webkit xml xmlpatterns) | |||
|
71 | string(TOUPPER ${qtlib} qtlib_uppercase) | |||
|
72 | if (NOT ${QT_QT${qtlib_uppercase}_FOUND}) | |||
|
73 | message(FATAL_ERROR "QT_QT${${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}") | |||
|
74 | endif() | |||
|
75 | set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}}) | |||
|
76 | endforeach() | |||
|
77 | ||||
|
78 | include(${QT_USE_FILE}) | |||
|
79 | else() | |||
|
80 | message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable") | |||
|
81 | endif() | |||
|
82 | ||||
|
83 | #----------------------------------------------------------------------------- | |||
|
84 | # Sources | |||
|
85 | ||||
|
86 | set(sources | |||
|
87 | src/PythonQtClassInfo.cpp | |||
|
88 | src/PythonQtClassWrapper.cpp | |||
|
89 | src/PythonQtConversion.cpp | |||
|
90 | src/PythonQt.cpp | |||
|
91 | src/PythonQtImporter.cpp | |||
|
92 | src/PythonQtInstanceWrapper.cpp | |||
|
93 | src/PythonQtMethodInfo.cpp | |||
|
94 | src/PythonQtMisc.cpp | |||
|
95 | src/PythonQtObjectPtr.cpp | |||
|
96 | src/PythonQtQFileImporter.cpp | |||
|
97 | src/PythonQtSignalReceiver.cpp | |||
|
98 | src/PythonQtSlot.cpp | |||
|
99 | src/PythonQtStdDecorators.cpp | |||
|
100 | src/PythonQtStdIn.cpp | |||
|
101 | src/PythonQtStdOut.cpp | |||
|
102 | src/gui/PythonQtScriptingConsole.cpp | |||
|
103 | ||||
|
104 | generated_cpp/PythonQt_QtBindings.cpp | |||
|
105 | ||||
|
106 | generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp | |||
|
107 | generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp | |||
|
108 | generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp | |||
|
109 | generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp | |||
|
110 | ) | |||
|
111 | ||||
|
112 | #----------------------------------------------------------------------------- | |||
|
113 | # List headers. This is list is used for the install command. | |||
|
114 | ||||
|
115 | set(headers | |||
|
116 | src/PythonQtClassInfo.h | |||
|
117 | src/PythonQtClassWrapper.h | |||
|
118 | src/PythonQtConversion.h | |||
|
119 | src/PythonQtCppWrapperFactory.h | |||
|
120 | src/PythonQtDoc.h | |||
|
121 | src/PythonQt.h | |||
|
122 | src/PythonQtImporter.h | |||
|
123 | src/PythonQtImportFileInterface.h | |||
|
124 | src/PythonQtInstanceWrapper.h | |||
|
125 | src/PythonQtMethodInfo.h | |||
|
126 | src/PythonQtMisc.h | |||
|
127 | src/PythonQtObjectPtr.h | |||
|
128 | src/PythonQtQFileImporter.h | |||
|
129 | src/PythonQtSignalReceiver.h | |||
|
130 | src/PythonQtSlot.h | |||
|
131 | src/PythonQtStdDecorators.h | |||
|
132 | src/PythonQtStdIn.h | |||
|
133 | src/PythonQtStdOut.h | |||
|
134 | src/PythonQtSystem.h | |||
|
135 | src/PythonQtVariants.h | |||
|
136 | src/PythonQtPythonInclude.h | |||
|
137 | generated_cpp/PythonQt_QtBindings.h | |||
|
138 | ) | |||
|
139 | ||||
|
140 | #----------------------------------------------------------------------------- | |||
|
141 | # Headers that should run through moc | |||
|
142 | ||||
|
143 | set(moc_sources | |||
|
144 | src/PythonQt.h | |||
|
145 | src/PythonQtSignalReceiver.h | |||
|
146 | src/PythonQtStdDecorators.h | |||
|
147 | src/gui/PythonQtScriptingConsole.h | |||
|
148 | ||||
|
149 | generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h | |||
|
150 | generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h | |||
|
151 | ) | |||
|
152 | ||||
|
153 | #----------------------------------------------------------------------------- | |||
|
154 | # Add extra sources | |||
|
155 | foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns) | |||
|
156 | ||||
|
157 | if (${PythonQt_Wrap_Qt${qtlib}}) | |||
|
158 | ||||
|
159 | ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib}) | |||
|
160 | ||||
|
161 | set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib}) | |||
|
162 | ||||
|
163 | foreach(index RANGE 0 10) | |||
|
164 | ||||
|
165 | # Source files | |||
|
166 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp) | |||
|
167 | list(APPEND sources ${file_prefix}${index}.cpp) | |||
|
168 | endif() | |||
|
169 | ||||
|
170 | # Headers that should run through moc | |||
|
171 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h) | |||
|
172 | list(APPEND moc_sources ${file_prefix}${index}.h) | |||
|
173 | endif() | |||
|
174 | ||||
|
175 | endforeach() | |||
|
176 | ||||
|
177 | list(APPEND sources ${file_prefix}_init.cpp) | |||
|
178 | ||||
|
179 | endif() | |||
|
180 | endforeach() | |||
|
181 | ||||
|
182 | #----------------------------------------------------------------------------- | |||
|
183 | # UI files | |||
|
184 | set(ui_sources ) | |||
|
185 | ||||
|
186 | #----------------------------------------------------------------------------- | |||
|
187 | # Resources | |||
|
188 | set(qrc_sources ) | |||
|
189 | ||||
|
190 | #----------------------------------------------------------------------------- | |||
|
191 | # Do wrapping | |||
|
192 | qt4_wrap_cpp(gen_moc_sources ${moc_sources}) | |||
|
193 | qt4_wrap_ui(gen_ui_sources ${ui_sources}) | |||
|
194 | qt4_add_resources(gen_qrc_sources ${qrc_sources}) | |||
|
195 | ||||
|
196 | #----------------------------------------------------------------------------- | |||
|
197 | # Build the library | |||
|
198 | ||||
|
199 | include_directories( | |||
|
200 | ${CMAKE_CURRENT_SOURCE_DIR}/src | |||
|
201 | ) | |||
|
202 | ||||
|
203 | add_library(PythonQt SHARED | |||
|
204 | ${sources} | |||
|
205 | ${gen_moc_sources} | |||
|
206 | ${gen_ui_sources} | |||
|
207 | ${gen_qrc_sources} | |||
|
208 | ) | |||
|
209 | set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS) | |||
|
210 | ||||
|
211 | # | |||
|
212 | # That should solve linkage error on Mac when the project is used in a superbuild setup | |||
|
213 | # See http://blog.onesadcookie.com/2008/01/installname-magic.html | |||
|
214 | # | |||
|
215 | set_target_properties(PythonQt PROPERTIES | |||
|
216 | INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" | |||
|
217 | ) | |||
|
218 | ||||
|
219 | target_link_libraries(PythonQt | |||
|
220 | ${PYTHON_LIBRARY} | |||
|
221 | ${QT_LIBRARIES} | |||
|
222 | ) | |||
|
223 | ||||
|
224 | #----------------------------------------------------------------------------- | |||
|
225 | # Install library (on windows, put the dll in 'bin' and the archive in 'lib') | |||
|
226 | ||||
|
227 | install(TARGETS PythonQt | |||
|
228 | RUNTIME DESTINATION bin | |||
|
229 | LIBRARY DESTINATION lib | |||
|
230 | ARCHIVE DESTINATION lib) | |||
|
231 | install(FILES ${headers} DESTINATION include/PythonQt) |
General Comments 0
You need to be logged in to leave comments.
Login now