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