Skip to content

Commit caa330a

Browse files
committed
Re-factor code introducing qt_wrapped_libs variable
1 parent 4ca1039 commit caa330a

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

CMakeLists.txt

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ cmake_minimum_required(VERSION 2.8)
1111
project(PythonQt)
1212
#-----------------------------------------------------------------------------
1313

14+
#----------------------------------------------------------------------------
15+
# Qt version
16+
17+
# Set PythonQt_QT_VERSION
18+
set(PythonQt_QT_VERSION 4)
19+
20+
# Requirements
21+
set(minimum_required_qt4_version "4.6.2")
22+
set(minimum_required_qt_version ${minimum_required_qt${PythonQt_QT_VERSION}_version})
23+
24+
# Qt components
25+
set(qt4libs core gui network opengl sql svg uitools webkit xml xmlpatterns)
26+
set(qtlibs ${qt${PythonQt_QT_VERSION}libs})
27+
1428
#-----------------------------------------------------------------------------
1529
# Python libraries
1630

@@ -40,17 +54,24 @@ if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR)
4054
set(PythonQt_INSTALL_INCLUDE_DIR include/PythonQt)
4155
endif()
4256

43-
option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)
57+
set(qt4_wrapped_libs ${qt4libs})
58+
set(qt_wrapped_libs ${qt${PythonQt_QT_VERSION}_wrapped_libs})
4459

45-
set(qtlibs core gui network opengl sql svg uitools webkit xml xmlpatterns)
46-
foreach(qtlib ${qtlibs})
60+
# Define PythonQt_Wrap_Qt* options
61+
option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)
62+
foreach(qtlib ${qt_wrapped_libs})
4763
OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF)
4864
endforeach()
4965

66+
5067
# Force option if it applies
5168
if(PythonQt_Wrap_QtAll)
52-
list(REMOVE_ITEM qtlibs xmlpatterns) # xmlpatterns wrapper does *NOT* build at all :(
53-
foreach(qtlib ${qtlibs})
69+
set(_qt_wrapped_libs ${qt_wrapped_libs})
70+
71+
# XXX xmlpatterns wrapper does *NOT* build at all :(
72+
list(REMOVE_ITEM _qt_wrapped_libs xmlpatterns)
73+
74+
foreach(qtlib ${_qt_wrapped_libs})
5475
if(NOT ${PythonQt_Wrap_Qt${qtlib}})
5576
set(PythonQt_Wrap_Qt${qtlib} ON CACHE BOOL "Make all of Qt${qtlib} available in python" FORCE)
5677
message(STATUS "Enabling [PythonQt_Wrap_Qt${qtlib}] because of [PythonQt_Wrap_QtAll] evaluates to True")
@@ -68,7 +89,6 @@ endif()
6889
#-----------------------------------------------------------------------------
6990
# Setup Qt
7091

71-
set(minimum_required_qt_version "4.6.2")
7292

7393
find_package(Qt4)
7494

@@ -81,7 +101,7 @@ if(QT4_FOUND)
81101
endif()
82102

83103
# Enable required qt module
84-
foreach(qtlib network opengl sql svg uitools webkit xml xmlpatterns)
104+
foreach(qtlib ${qt_wrapped_libs})
85105
string(TOUPPER ${qtlib} qtlib_uppercase)
86106
if (NOT ${QT_QT${qtlib_uppercase}_FOUND})
87107
message(FATAL_ERROR "QT_QT${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}")
@@ -185,7 +205,7 @@ set(moc_sources
185205

186206
#-----------------------------------------------------------------------------
187207
# Add extra sources
188-
foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
208+
foreach(qtlib ${qt_wrapped_libs})
189209

190210
if (${PythonQt_Wrap_Qt${qtlib}})
191211

0 commit comments

Comments
 (0)