##// END OF EJS Templates
added additional file...
florianlink -
r181:0db666f0d203
parent child
Show More
@@ -1,231 +1,232
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/PythonQtStdDecorators.cpp
100 src/PythonQtStdDecorators.cpp
100 src/PythonQtStdIn.cpp
101 src/PythonQtStdIn.cpp
101 src/PythonQtStdOut.cpp
102 src/PythonQtStdOut.cpp
102 src/gui/PythonQtScriptingConsole.cpp
103 src/gui/PythonQtScriptingConsole.cpp
103
104
104 generated_cpp/PythonQt_QtBindings.cpp
105 generated_cpp/PythonQt_QtBindings.cpp
105
106
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_builtin0.cpp
107 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
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_builtin0.cpp
109 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
110 )
111 )
111
112
112 #-----------------------------------------------------------------------------
113 #-----------------------------------------------------------------------------
113 # List headers. This is list is used for the install command.
114 # List headers. This is list is used for the install command.
114
115
115 set(headers
116 set(headers
116 src/PythonQtClassInfo.h
117 src/PythonQtClassInfo.h
117 src/PythonQtClassWrapper.h
118 src/PythonQtClassWrapper.h
118 src/PythonQtConversion.h
119 src/PythonQtConversion.h
119 src/PythonQtCppWrapperFactory.h
120 src/PythonQtCppWrapperFactory.h
120 src/PythonQtDoc.h
121 src/PythonQtDoc.h
121 src/PythonQt.h
122 src/PythonQt.h
122 src/PythonQtImporter.h
123 src/PythonQtImporter.h
123 src/PythonQtImportFileInterface.h
124 src/PythonQtImportFileInterface.h
124 src/PythonQtInstanceWrapper.h
125 src/PythonQtInstanceWrapper.h
125 src/PythonQtMethodInfo.h
126 src/PythonQtMethodInfo.h
126 src/PythonQtMisc.h
127 src/PythonQtMisc.h
127 src/PythonQtObjectPtr.h
128 src/PythonQtObjectPtr.h
128 src/PythonQtQFileImporter.h
129 src/PythonQtQFileImporter.h
129 src/PythonQtSignalReceiver.h
130 src/PythonQtSignalReceiver.h
130 src/PythonQtSlot.h
131 src/PythonQtSlot.h
131 src/PythonQtStdDecorators.h
132 src/PythonQtStdDecorators.h
132 src/PythonQtStdIn.h
133 src/PythonQtStdIn.h
133 src/PythonQtStdOut.h
134 src/PythonQtStdOut.h
134 src/PythonQtSystem.h
135 src/PythonQtSystem.h
135 src/PythonQtVariants.h
136 src/PythonQtVariants.h
136 src/PythonQtPythonInclude.h
137 src/PythonQtPythonInclude.h
137 generated_cpp/PythonQt_QtBindings.h
138 generated_cpp/PythonQt_QtBindings.h
138 )
139 )
139
140
140 #-----------------------------------------------------------------------------
141 #-----------------------------------------------------------------------------
141 # Headers that should run through moc
142 # Headers that should run through moc
142
143
143 set(moc_sources
144 set(moc_sources
144 src/PythonQt.h
145 src/PythonQt.h
145 src/PythonQtSignalReceiver.h
146 src/PythonQtSignalReceiver.h
146 src/PythonQtStdDecorators.h
147 src/PythonQtStdDecorators.h
147 src/gui/PythonQtScriptingConsole.h
148 src/gui/PythonQtScriptingConsole.h
148
149
149 generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h
150 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 generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h
151 )
152 )
152
153
153 #-----------------------------------------------------------------------------
154 #-----------------------------------------------------------------------------
154 # Add extra sources
155 # Add extra sources
155 foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
156 foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
156
157
157 if (${PythonQt_Wrap_Qt${qtlib}})
158 if (${PythonQt_Wrap_Qt${qtlib}})
158
159
159 ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})
160 ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})
160
161
161 set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
162 set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
162
163
163 foreach(index RANGE 0 10)
164 foreach(index RANGE 0 10)
164
165
165 # Source files
166 # Source files
166 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
167 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
167 list(APPEND sources ${file_prefix}${index}.cpp)
168 list(APPEND sources ${file_prefix}${index}.cpp)
168 endif()
169 endif()
169
170
170 # Headers that should run through moc
171 # Headers that should run through moc
171 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
172 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
172 list(APPEND moc_sources ${file_prefix}${index}.h)
173 list(APPEND moc_sources ${file_prefix}${index}.h)
173 endif()
174 endif()
174
175
175 endforeach()
176 endforeach()
176
177
177 list(APPEND sources ${file_prefix}_init.cpp)
178 list(APPEND sources ${file_prefix}_init.cpp)
178
179
179 endif()
180 endif()
180 endforeach()
181 endforeach()
181
182
182 #-----------------------------------------------------------------------------
183 #-----------------------------------------------------------------------------
183 # UI files
184 # UI files
184 set(ui_sources )
185 set(ui_sources )
185
186
186 #-----------------------------------------------------------------------------
187 #-----------------------------------------------------------------------------
187 # Resources
188 # Resources
188 set(qrc_sources )
189 set(qrc_sources )
189
190
190 #-----------------------------------------------------------------------------
191 #-----------------------------------------------------------------------------
191 # Do wrapping
192 # Do wrapping
192 qt4_wrap_cpp(gen_moc_sources ${moc_sources})
193 qt4_wrap_cpp(gen_moc_sources ${moc_sources})
193 qt4_wrap_ui(gen_ui_sources ${ui_sources})
194 qt4_wrap_ui(gen_ui_sources ${ui_sources})
194 qt4_add_resources(gen_qrc_sources ${qrc_sources})
195 qt4_add_resources(gen_qrc_sources ${qrc_sources})
195
196
196 #-----------------------------------------------------------------------------
197 #-----------------------------------------------------------------------------
197 # Build the library
198 # Build the library
198
199
199 include_directories(
200 include_directories(
200 ${CMAKE_CURRENT_SOURCE_DIR}/src
201 ${CMAKE_CURRENT_SOURCE_DIR}/src
201 )
202 )
202
203
203 add_library(PythonQt SHARED
204 add_library(PythonQt SHARED
204 ${sources}
205 ${sources}
205 ${gen_moc_sources}
206 ${gen_moc_sources}
206 ${gen_ui_sources}
207 ${gen_ui_sources}
207 ${gen_qrc_sources}
208 ${gen_qrc_sources}
208 )
209 )
209 set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
210 set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
210
211
211 #
212 #
212 # That should solve linkage error on Mac when the project is used in a superbuild setup
213 # 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 # See http://blog.onesadcookie.com/2008/01/installname-magic.html
214 #
215 #
215 set_target_properties(PythonQt PROPERTIES
216 set_target_properties(PythonQt PROPERTIES
216 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
217 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
217 )
218 )
218
219
219 target_link_libraries(PythonQt
220 target_link_libraries(PythonQt
220 ${PYTHON_LIBRARY}
221 ${PYTHON_LIBRARY}
221 ${QT_LIBRARIES}
222 ${QT_LIBRARIES}
222 )
223 )
223
224
224 #-----------------------------------------------------------------------------
225 #-----------------------------------------------------------------------------
225 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
226 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
226
227
227 install(TARGETS PythonQt
228 install(TARGETS PythonQt
228 RUNTIME DESTINATION bin
229 RUNTIME DESTINATION bin
229 LIBRARY DESTINATION lib
230 LIBRARY DESTINATION lib
230 ARCHIVE DESTINATION lib)
231 ARCHIVE DESTINATION lib)
231 install(FILES ${headers} DESTINATION include/PythonQt)
232 install(FILES ${headers} DESTINATION include/PythonQt)
General Comments 0
You need to be logged in to leave comments. Login now