##// END OF EJS Templates
florianlink -
r202:ca58bd51b222
parent child
Show More
@@ -0,0 +1,162
1 cmake_minimum_required(VERSION 2.8)
2
3 #-----------------------------------------------------------------------------
4 project(PythonQtGenerator)
5 #-----------------------------------------------------------------------------
6
7 include(CTestUseLaunchers OPTIONAL)
8
9 #-----------------------------------------------------------------------------
10 # Setup Qt
11
12 set(minimum_required_qt_version "4.6.2")
13
14 find_package(Qt4)
15
16 if(QT4_FOUND)
17
18 set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
19
20 if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version})
21 message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.")
22 endif()
23
24 set(QT_USE_QTXML ON)
25
26 include(${QT_USE_FILE})
27 else()
28 message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
29 endif()
30
31 #-----------------------------------------------------------------------------
32 # Sources
33
34 set(sources
35 parser/ast.cpp
36 parser/binder.cpp
37 parser/class_compiler.cpp
38 parser/codemodel.cpp
39 parser/codemodel_finder.cpp
40 parser/compiler_utils.cpp
41 parser/control.cpp
42 parser/declarator_compiler.cpp
43 parser/default_visitor.cpp
44 parser/dumptree.cpp
45 parser/lexer.cpp
46 parser/list.cpp
47 parser/name_compiler.cpp
48 parser/parser.cpp
49 parser/smallobject.cpp
50 parser/tokens.cpp
51 parser/type_compiler.cpp
52 parser/visitor.cpp
53
54 abstractmetabuilder.cpp
55 abstractmetalang.cpp
56 asttoxml.cpp
57 customtypes.cpp
58 fileout.cpp
59 generator.cpp
60 generatorset.cpp
61 generatorsetqtscript.cpp
62 main.cpp
63 metajava.cpp
64 metaqtscriptbuilder.cpp
65 metaqtscript.cpp
66 prigenerator.cpp
67 reporthandler.cpp
68 setupgenerator.cpp
69 shellgenerator.cpp
70 shellheadergenerator.cpp
71 shellimplgenerator.cpp
72 typeparser.cpp
73 typesystem.cpp
74 )
75
76 #-----------------------------------------------------------------------------
77 # List headers. This list is used for the install command.
78
79 set(headers
80 )
81
82 #-----------------------------------------------------------------------------
83 # Headers that should run through moc
84
85 set(moc_sources
86 fileout.h
87 generator.h
88 generatorset.h
89 generatorsetqtscript.h
90 prigenerator.h
91 setupgenerator.h
92 shellgenerator.h
93 shellheadergenerator.h
94 shellimplgenerator.h
95 )
96
97 #-----------------------------------------------------------------------------
98 # UI files
99
100 set(ui_sources )
101
102 #-----------------------------------------------------------------------------
103 # Resources
104
105 set(qrc_sources
106 generator.qrc
107 )
108
109 #-----------------------------------------------------------------------------
110 # Do wrapping
111 qt4_wrap_cpp(gen_moc_sources ${moc_sources})
112 qt4_wrap_ui(gen_ui_sources ${ui_sources})
113 qt4_add_resources(gen_qrc_sources ${qrc_sources})
114
115 #-----------------------------------------------------------------------------
116 # Copy file expected by the generator and specify install rules
117
118 file(GLOB files_to_copy RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "build_*.txt" "typesystem_*.xml")
119 list(APPEND files_to_copy qtscript_masterinclude.h parser/rpp/pp-qt-configuration)
120 foreach(file ${files_to_copy})
121 configure_file(
122 ${file}
123 ${CMAKE_CURRENT_BINARY_DIR}/${file}
124 COPYONLY
125 )
126 get_filename_component(destination_dir ${file} PATH)
127 install(FILES ${file} DESTINATION bin/${destination_dir})
128 endforeach()
129
130 #-----------------------------------------------------------------------------
131 # Build the library
132
133 SOURCE_GROUP("Resources" FILES
134 ${qrc_sources}
135 ${ui_sources}
136 ${files_to_copy}
137 )
138
139 include_directories(
140 ${CMAKE_CURRENT_SOURCE_DIR}
141 ${CMAKE_CURRENT_SOURCE_DIR}/parser
142 ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp
143 )
144
145 add_definitions(-DRXX_ALLOCATOR_INIT_0)
146
147 add_executable(${PROJECT_NAME}
148 ${sources}
149 ${gen_moc_sources}
150 ${gen_ui_sources}
151 ${gen_qrc_sources}
152 )
153
154 target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
155
156 #-----------------------------------------------------------------------------
157 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
158
159 install(TARGETS ${PROJECT_NAME}
160 RUNTIME DESTINATION bin
161 LIBRARY DESTINATION lib
162 ARCHIVE DESTINATION lib)
@@ -1,233 +1,234
1 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
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 4 project(PythonQt)
31 5 #-----------------------------------------------------------------------------
32 6
7 include(CTestUseLaunchers OPTIONAL)
8
33 9 #-----------------------------------------------------------------------------
34 10 # Python libraries
35 11
36 12 find_package(PythonLibs REQUIRED)
37 13 include_directories("${PYTHON_INCLUDE_DIR}")
38 14 add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
39 15
40 16 #-----------------------------------------------------------------------------
41 17 # Build options
42 18
43 foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
19 option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)
20
21 set(qtlibs core gui network opengl sql svg uitools webkit xml xmlpatterns)
22 foreach(qtlib ${qtlibs})
44 23 OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF)
45 24 endforeach()
46 25
26 # Force option if it applies
27 if(PythonQt_Wrap_QtAll)
28 list(REMOVE_ITEM qtlibs xmlpatterns) # xmlpatterns wrapper does *NOT* build at all :(
29 foreach(qtlib ${qtlibs})
30 if(NOT ${PythonQt_Wrap_Qt${qtlib}})
31 set(PythonQt_Wrap_Qt${qtlib} ON CACHE BOOL "Make all of Qt${qtlib} available in python" FORCE)
32 message(STATUS "Enabling [PythonQt_Wrap_Qt${qtlib}] because of [PythonQt_Wrap_QtAll] evaluates to True")
33 endif()
34 endforeach()
35 endif()
36
47 37 option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF)
48 38 if(PythonQt_DEBUG)
49 39 add_definitions(-DPYTHONQT_DEBUG)
50 40 else()
51 41 remove_definitions(-DPYTHONQT_DEBUG)
52 42 endif()
53 43
54 44 #-----------------------------------------------------------------------------
55 45 # Setup Qt
56 46
57 47 set(minimum_required_qt_version "4.6.2")
58 48
59 49 find_package(Qt4)
60 50
61 51 if(QT4_FOUND)
62 52
63 53 set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
64 54
65 55 if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version})
66 56 message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.")
67 57 endif()
68 58
69 59 # Enable required qt module
70 60 foreach(qtlib network opengl sql svg uitools webkit xml xmlpatterns)
71 61 string(TOUPPER ${qtlib} qtlib_uppercase)
72 62 if (NOT ${QT_QT${qtlib_uppercase}_FOUND})
73 63 message(FATAL_ERROR "QT_QT${${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}")
74 64 endif()
75 65 set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}})
76 66 endforeach()
77 67
78 68 include(${QT_USE_FILE})
79 69 else()
80 70 message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
81 71 endif()
82 72
83 73 #-----------------------------------------------------------------------------
74 # The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
75 # associated with the Qt version being used.
76 set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}")
77 if("${generated_cpp_suffix}" STREQUAL "_48")
78 set(generated_cpp_suffix "")
79 endif()
80 if("${generated_cpp_suffix}" STREQUAL "_46")
81 set(generated_cpp_suffix "_47") # Also use 4.7 wrappers for 4.6.x version
82 endif()
83
84 #-----------------------------------------------------------------------------
84 85 # Sources
85 86
86 87 set(sources
87 88 src/PythonQtClassInfo.cpp
88 89 src/PythonQtClassWrapper.cpp
89 90 src/PythonQtConversion.cpp
90 91 src/PythonQt.cpp
91 92 src/PythonQtImporter.cpp
92 93 src/PythonQtInstanceWrapper.cpp
93 94 src/PythonQtMethodInfo.cpp
94 95 src/PythonQtMisc.cpp
95 96 src/PythonQtObjectPtr.cpp
96 97 src/PythonQtQFileImporter.cpp
97 98 src/PythonQtSignalReceiver.cpp
98 99 src/PythonQtSlot.cpp
99 100 src/PythonQtSignal.cpp
100 101 src/PythonQtStdDecorators.cpp
101 102 src/PythonQtStdIn.cpp
102 103 src/PythonQtStdOut.cpp
103 104 src/gui/PythonQtScriptingConsole.cpp
104 105
105 generated_cpp/PythonQt_QtBindings.cpp
106 generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.cpp
106 107
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
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
108 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp
109 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp
110 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp
111 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp
111 112 )
112 113
113 114 #-----------------------------------------------------------------------------
114 115 # List headers. This is list is used for the install command.
115 116
116 117 set(headers
117 118 src/PythonQtClassInfo.h
118 119 src/PythonQtClassWrapper.h
119 120 src/PythonQtConversion.h
120 121 src/PythonQtCppWrapperFactory.h
121 122 src/PythonQtDoc.h
122 123 src/PythonQt.h
123 124 src/PythonQtImporter.h
124 125 src/PythonQtImportFileInterface.h
125 126 src/PythonQtInstanceWrapper.h
126 127 src/PythonQtMethodInfo.h
127 128 src/PythonQtMisc.h
128 129 src/PythonQtObjectPtr.h
129 130 src/PythonQtQFileImporter.h
130 131 src/PythonQtSignalReceiver.h
131 132 src/PythonQtSlot.h
132 133 src/PythonQtSignal.h
133 134 src/PythonQtStdDecorators.h
134 135 src/PythonQtStdIn.h
135 136 src/PythonQtStdOut.h
136 137 src/PythonQtSystem.h
137 138 src/PythonQtVariants.h
138 139 src/PythonQtPythonInclude.h
139 generated_cpp/PythonQt_QtBindings.h
140 generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h
140 141 )
141 142
142 143 #-----------------------------------------------------------------------------
143 144 # Headers that should run through moc
144 145
145 146 set(moc_sources
146 147 src/PythonQt.h
147 148 src/PythonQtSignalReceiver.h
148 149 src/PythonQtStdDecorators.h
149 150 src/gui/PythonQtScriptingConsole.h
150 151
151 generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h
152 generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h
152 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h
153 generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h
153 154 )
154 155
155 156 #-----------------------------------------------------------------------------
156 157 # Add extra sources
157 158 foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
158 159
159 160 if (${PythonQt_Wrap_Qt${qtlib}})
160 161
161 162 ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})
162 163
163 set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
164 set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
164 165
165 foreach(index RANGE 0 10)
166 foreach(index RANGE 0 11)
166 167
167 168 # Source files
168 169 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
169 170 list(APPEND sources ${file_prefix}${index}.cpp)
170 171 endif()
171 172
172 173 # Headers that should run through moc
173 174 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
174 175 list(APPEND moc_sources ${file_prefix}${index}.h)
175 176 endif()
176 177
177 178 endforeach()
178 179
179 180 list(APPEND sources ${file_prefix}_init.cpp)
180 181
181 182 endif()
182 183 endforeach()
183 184
184 185 #-----------------------------------------------------------------------------
185 186 # UI files
186 187 set(ui_sources )
187 188
188 189 #-----------------------------------------------------------------------------
189 190 # Resources
190 191 set(qrc_sources )
191 192
192 193 #-----------------------------------------------------------------------------
193 194 # Do wrapping
194 195 qt4_wrap_cpp(gen_moc_sources ${moc_sources})
195 196 qt4_wrap_ui(gen_ui_sources ${ui_sources})
196 197 qt4_add_resources(gen_qrc_sources ${qrc_sources})
197 198
198 199 #-----------------------------------------------------------------------------
199 200 # Build the library
200 201
201 202 include_directories(
202 203 ${CMAKE_CURRENT_SOURCE_DIR}/src
203 204 )
204 205
205 206 add_library(PythonQt SHARED
206 207 ${sources}
207 208 ${gen_moc_sources}
208 209 ${gen_ui_sources}
209 210 ${gen_qrc_sources}
210 211 )
211 212 set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
212 213
213 214 #
214 215 # That should solve linkage error on Mac when the project is used in a superbuild setup
215 216 # See http://blog.onesadcookie.com/2008/01/installname-magic.html
216 217 #
217 218 set_target_properties(PythonQt PROPERTIES
218 219 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
219 220 )
220 221
221 222 target_link_libraries(PythonQt
222 223 ${PYTHON_LIBRARY}
223 224 ${QT_LIBRARIES}
224 225 )
225 226
226 227 #-----------------------------------------------------------------------------
227 228 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
228 229
229 230 install(TARGETS PythonQt
230 231 RUNTIME DESTINATION bin
231 232 LIBRARY DESTINATION lib
232 233 ARCHIVE DESTINATION lib)
233 234 install(FILES ${headers} DESTINATION include/PythonQt)
General Comments 0
You need to be logged in to leave comments. Login now