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