Skip to content

Commit 6bbd177

Browse files
author
feihong
committed
add CMake build support to PythonQtGenerator
1 parent 651427e commit 6bbd177

File tree

4 files changed

+57
-154
lines changed

4 files changed

+57
-154
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else()
2929
endif()
3030

3131
add_subdirectory(src)
32-
# add_subdirectory(generator)
32+
add_subdirectory(generator)
3333
add_subdirectory(extensions)
3434
add_subdirectory(tests)
3535
# add_subdirectory(examples)

generator/CMakeLists.txt

Lines changed: 16 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,25 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
project(PythonQtGenerator LANGUAGES CXX)
22

3-
#-----------------------------------------------------------------------------
4-
project(PythonQtGenerator)
5-
#-----------------------------------------------------------------------------
3+
add_subdirectory(parser)
64

7-
include(CTestUseLaunchers OPTIONAL)
5+
set(CMAKE_AUTOMOC ON)
6+
set(CMAKE_AUTORCC ON)
87

9-
#-----------------------------------------------------------------------------
10-
# Setup Qt
8+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Xml REQUIRED)
119

12-
set(minimum_required_qt_version "4.6.2")
10+
file(GLOB SOURCES *.h *.cpp *.qrc)
11+
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_LIST_DIR}/qtscript_masterinclude.h")
1312

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
13+
add_executable(${PROJECT_NAME})
5314

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}
15+
target_sources(${PROJECT_NAME} PRIVATE
16+
${SOURCES}
15217
)
15318

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')
19+
target_link_libraries(${PROJECT_NAME} PUBLIC
20+
Qt${QT_VERSION_MAJOR}::Widgets
21+
Qt${QT_VERSION_MAJOR}::Xml
22+
rxx
23+
)
15824

159-
install(TARGETS ${PROJECT_NAME}
160-
RUNTIME DESTINATION bin
161-
LIBRARY DESTINATION lib
162-
ARCHIVE DESTINATION lib)
25+
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})

generator/parser/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
project(rxx LANGUAGES CXX)
2+
add_subdirectory(rpp)
3+
4+
set(CMAKE_AUTOMOC ON)
5+
set(CMAKE_AUTORCC ON)
6+
7+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
8+
9+
file(GLOB SOURCES *.h *.cpp)
10+
11+
add_library(${PROJECT_NAME} INTERFACE)
12+
13+
target_sources(${PROJECT_NAME} INTERFACE
14+
${SOURCES}
15+
)
16+
17+
target_link_libraries(${PROJECT_NAME} INTERFACE
18+
Qt${QT_VERSION_MAJOR}::Core
19+
rpp
20+
)
21+
22+
target_include_directories(${PROJECT_NAME} INTERFACE
23+
${CMAKE_CURRENT_LIST_DIR}
24+
)
25+
26+
target_compile_definitions(${PROJECT_NAME} INTERFACE RXX_ALLOCATOR_INIT_0)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
project(rpp LANGUAGES CXX)
2+
3+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
4+
5+
file(GLOB SOURCES *.h preprocessor.cpp)
6+
7+
add_library(${PROJECT_NAME} INTERFACE)
8+
9+
target_sources(${PROJECT_NAME} INTERFACE ${SOURCES})
10+
11+
target_link_libraries(${PROJECT_NAME} INTERFACE Qt${QT_VERSION_MAJOR}::Core)
12+
13+
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
14+

0 commit comments

Comments
 (0)