Skip to content

Commit f28f554

Browse files
committed
ENH: Generator - Added CMakeLists.txt allowing to compile PythonQtGenerator in a cross-platform fashion
Note it's possible to run the generator from either the build directory or the install directory. Indeed, the dependent files (typesystem_*.xml, build_*.xml, qtscript_masterinclude.h and parser/rpp/pp-qt-configuration) have the appropriate install rules and are also copied to the build directory.
1 parent e2dce4b commit f28f554

File tree

1 file changed

+186
-0
lines changed

1 file changed

+186
-0
lines changed

generator/CMakeLists.txt

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
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(PythonQtGenerator)
31+
#-----------------------------------------------------------------------------
32+
33+
#-----------------------------------------------------------------------------
34+
# Setup Qt
35+
36+
set(minimum_required_qt_version "4.6.2")
37+
38+
find_package(Qt4)
39+
40+
if(QT4_FOUND)
41+
42+
set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
43+
44+
if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version})
45+
message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.")
46+
endif()
47+
48+
set(QT_USE_QTXML ON)
49+
50+
include(${QT_USE_FILE})
51+
else()
52+
message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
53+
endif()
54+
55+
#-----------------------------------------------------------------------------
56+
# Sources
57+
58+
set(sources
59+
parser/ast.cpp
60+
parser/binder.cpp
61+
parser/class_compiler.cpp
62+
parser/codemodel.cpp
63+
parser/codemodel_finder.cpp
64+
parser/compiler_utils.cpp
65+
parser/control.cpp
66+
parser/declarator_compiler.cpp
67+
parser/default_visitor.cpp
68+
parser/dumptree.cpp
69+
parser/lexer.cpp
70+
parser/list.cpp
71+
parser/name_compiler.cpp
72+
parser/parser.cpp
73+
parser/smallobject.cpp
74+
parser/tokens.cpp
75+
parser/type_compiler.cpp
76+
parser/visitor.cpp
77+
78+
abstractmetabuilder.cpp
79+
abstractmetalang.cpp
80+
asttoxml.cpp
81+
customtypes.cpp
82+
fileout.cpp
83+
generator.cpp
84+
generatorset.cpp
85+
generatorsetqtscript.cpp
86+
main.cpp
87+
metajava.cpp
88+
metaqtscriptbuilder.cpp
89+
metaqtscript.cpp
90+
prigenerator.cpp
91+
reporthandler.cpp
92+
setupgenerator.cpp
93+
shellgenerator.cpp
94+
shellheadergenerator.cpp
95+
shellimplgenerator.cpp
96+
typeparser.cpp
97+
typesystem.cpp
98+
)
99+
100+
#-----------------------------------------------------------------------------
101+
# List headers. This list is used for the install command.
102+
103+
set(headers
104+
)
105+
106+
#-----------------------------------------------------------------------------
107+
# Headers that should run through moc
108+
109+
set(moc_sources
110+
fileout.h
111+
generator.h
112+
generatorset.h
113+
generatorsetqtscript.h
114+
prigenerator.h
115+
setupgenerator.h
116+
shellgenerator.h
117+
shellheadergenerator.h
118+
shellimplgenerator.h
119+
)
120+
121+
#-----------------------------------------------------------------------------
122+
# UI files
123+
124+
set(ui_sources )
125+
126+
#-----------------------------------------------------------------------------
127+
# Resources
128+
129+
set(qrc_sources
130+
generator.qrc
131+
)
132+
133+
#-----------------------------------------------------------------------------
134+
# Do wrapping
135+
qt4_wrap_cpp(gen_moc_sources ${moc_sources})
136+
qt4_wrap_ui(gen_ui_sources ${ui_sources})
137+
qt4_add_resources(gen_qrc_sources ${qrc_sources})
138+
139+
#-----------------------------------------------------------------------------
140+
# Copy file expected by the generator and specify install rules
141+
142+
file(GLOB files_to_copy RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "build_*.txt" "typesystem_*.xml")
143+
list(APPEND files_to_copy qtscript_masterinclude.h parser/rpp/pp-qt-configuration)
144+
foreach(file ${files_to_copy})
145+
configure_file(
146+
${file}
147+
${CMAKE_CURRENT_BINARY_DIR}/${file}
148+
COPYONLY
149+
)
150+
get_filename_component(destination_dir ${file} PATH)
151+
install(FILES ${file} DESTINATION bin/${destination_dir})
152+
endforeach()
153+
154+
#-----------------------------------------------------------------------------
155+
# Build the library
156+
157+
SOURCE_GROUP("Resources" FILES
158+
${qrc_sources}
159+
${ui_sources}
160+
${files_to_copy}
161+
)
162+
163+
include_directories(
164+
${CMAKE_CURRENT_SOURCE_DIR}
165+
${CMAKE_CURRENT_SOURCE_DIR}/parser
166+
${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp
167+
)
168+
169+
add_definitions(-DRXX_ALLOCATOR_INIT_0)
170+
171+
add_executable(${PROJECT_NAME}
172+
${sources}
173+
${gen_moc_sources}
174+
${gen_ui_sources}
175+
${gen_qrc_sources}
176+
)
177+
178+
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
179+
180+
#-----------------------------------------------------------------------------
181+
# Install library (on windows, put the dll in 'bin' and the archive in 'lib')
182+
183+
install(TARGETS ${PROJECT_NAME}
184+
RUNTIME DESTINATION bin
185+
LIBRARY DESTINATION lib
186+
ARCHIVE DESTINATION lib)

0 commit comments

Comments
 (0)