Skip to content

Python qt3 upgrade #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 189 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
99a5b4f
made generator compile on VC11
Oct 23, 2013
821dbdc
removed event() method from QClipboard and QWebFrame to avoid derivin…
Oct 23, 2013
be10dae
fixed wrong inplace operator function assignment
Nov 5, 2013
fb6de26
updated with current MeVisLab version
Sep 1, 2014
304eb41
replaced signals, slots and foreach with Q_* macros
Sep 1, 2014
75d1017
started qt5 port
Sep 1, 2014
c77ef51
replaced emit with Q_EMIT
Sep 2, 2014
3605980
replaced run script with direct AddObject calls
Sep 2, 2014
d4097ed
added searching super class in class hierachy
Sep 2, 2014
d20c722
undefine slots keyword and introduce PY3K define
Sep 2, 2014
bcc8da9
merged Qt5 port and exception parsing
Sep 2, 2014
1e6e485
deleted unmaintained original files
Sep 2, 2014
35989bb
removed QNoImplicitBoolCast, it seems to be gone in Qt 5.3
Sep 2, 2014
48b87c8
readded linefeed
Sep 2, 2014
d1ffe1e
removed qualifier again, the problem was QUrlTwoFlag<>
Sep 2, 2014
580615f
Qt5 introduces new QUrl flags
Sep 2, 2014
f352f82
initial qt5 support
Sep 2, 2014
5244754
initial qt5 support
Sep 2, 2014
4b95623
added typeName helper to make it behave like Qt4
Sep 2, 2014
941b910
added more Qt5 specific classes
Sep 3, 2014
25b51a3
adapted test to Qt5
Sep 3, 2014
91f9c80
adapted test to Qt5, escape is gone in Qt5
Sep 3, 2014
7da06d3
adapted examples to Qt5
Sep 3, 2014
a4c4488
renamed 4.8 bindings
Sep 3, 2014
f158901
added wrapper for Qt 5.0 and 5.3
Sep 3, 2014
aeab3d9
more adaptions because of Qt 5.0
Sep 3, 2014
0f58f93
qt5 adaptions
Sep 3, 2014
cac3318
auto-select pre-generated wrappers
Sep 3, 2014
8b063bd
- started PY3K porting
Sep 4, 2014
cc2e43d
further PY3K port
Sep 4, 2014
ce17d7b
return unicode instead on Py3
Sep 4, 2014
e4f8b00
further PY3K port
Sep 4, 2014
de3c0fe
adapted to PY3K
Sep 4, 2014
58f7dc1
upgraded to PY3K
Sep 4, 2014
b9c5d06
ported test to PY3K
Sep 4, 2014
b094918
added define for debug PY3K
Sep 4, 2014
d91a993
fixed porting typo
Sep 8, 2014
f873031
ported to PY3K
Sep 8, 2014
26d5cfa
fixed Python 2 build
Sep 8, 2014
ceaca65
removed warnings
Sep 8, 2014
c3e40e9
added support for QtMsgType
Sep 8, 2014
2496c03
updated documentation
Sep 8, 2014
5c51a94
updated to doxygen 1.8.x
Sep 8, 2014
3161952
updated documentation
Sep 8, 2014
6236950
added note
Sep 9, 2014
aebfde5
added more Qt5 classes and moved some from Core to GUI
Sep 10, 2014
0ac4cf6
removed phonon, which never worked
Sep 10, 2014
ae6c783
further cleanup
Sep 10, 2014
705933a
removed phonon and xmlpatterns, which never worked
Sep 10, 2014
40bd056
removed unused files
Sep 10, 2014
a351522
removed unused rules
Sep 10, 2014
e25af10
further cleanup
Sep 10, 2014
fe2494a
further cleanup
Sep 10, 2014
a2015f5
added polymorphic type ids
Sep 10, 2014
1872f1c
fixed building of xmlpatterns
Sep 10, 2014
e0afc5d
updated 5.3 api to current generator xmls
Sep 10, 2014
dc8e94a
do not generate shell classes for classes that don't have any constru…
Sep 11, 2014
6f247b3
added Qt multimedia
Sep 11, 2014
7183072
reverted accidental commit
Sep 11, 2014
7af21b7
use "__" as delimiter for nested classes
Sep 11, 2014
0a14d28
further cleanup of typesystem, enabled some nested classes
Sep 11, 2014
9f88d0b
added support for nested classes (only one level)
Sep 11, 2014
a5897a8
further cleanup, removed duplicate enum warning
Sep 11, 2014
cb462ab
added missing constData()
Sep 15, 2014
fd30fb9
typesystem cleanup
Sep 15, 2014
3f2971c
reverted
Sep 15, 2014
737938a
added missing classes
Sep 15, 2014
8fac949
added QOpenGLPaintDevice
Sep 15, 2014
4fe8b62
added more classes
Sep 15, 2014
eafa87f
QDataStream::ByteOrder
Sep 15, 2014
db2e3d5
added missing flags and types
Sep 15, 2014
88b6f43
more improvements
Sep 15, 2014
2783af5
fixed error
Sep 15, 2014
d3da378
added QPersistentModelIndex
Sep 15, 2014
80558cf
moved generate=no to xml
Sep 15, 2014
4dc5ebb
added more tests
Sep 16, 2014
f1a3d27
added new conversion templates
Sep 16, 2014
c7c419d
added new QList/QVector aliases
Sep 16, 2014
0c7f8e3
changed to new templates
Sep 16, 2014
6fae50b
added support for registering QList/QVector template converters for n…
Sep 16, 2014
6016b36
added test
Sep 16, 2014
ffc0797
changed to use last index (for nested templates like QPair)
Sep 16, 2014
eb34bd4
added new tests
Sep 17, 2014
381884f
added new conversions for QList/QPair/QHash/QMap
Sep 17, 2014
3f31250
added more aliases
Sep 17, 2014
766f9c2
GLuint64 may not be present, disable test for the moment
Sep 17, 2014
5a2a459
added implicit conversion of unicode to QByteArray for PY3K
Sep 18, 2014
57617ab
simplified QList<Object*> conversion
Sep 18, 2014
5f77588
added more tests
Sep 18, 2014
3505957
fixed compilation for Qt 4.x
Sep 18, 2014
badf55b
updated to current generator (and added missing files)
Sep 18, 2014
6ffa938
added newly generated wrappers
Sep 18, 2014
9406c0c
added multimedia include
Sep 18, 2014
14ce859
added support for new BoolResult class to support bool* parameters
Sep 18, 2014
2b9a1b9
added new source file to cmake
Sep 18, 2014
6ad64ed
changed to only map unicode to QByteArray in non-strict mode
Sep 22, 2014
bc42b91
updated docs
Sep 22, 2014
16ddcb1
implemented polymorphic downcasting on subclasses
Sep 24, 2014
41f71ad
support meta type based converters for pointer return values as well …
Sep 24, 2014
8ef82f2
added additional nested classes
Sep 24, 2014
873d341
cleanup of generator
Sep 25, 2014
e4749d8
removed connectNotify from QClipboard to avoid promoter creation
Sep 25, 2014
1c61156
further typesystem cleanup
Sep 25, 2014
f258ff8
more cleanup
Sep 25, 2014
ce419dc
fixed name shadowing via argument index
Sep 25, 2014
3fb4a2e
updated to current generator
Sep 25, 2014
ebe6abd
removed unused code
Sep 25, 2014
b190643
changed generator to use int instead of protected enums in shell and …
Sep 29, 2014
27de3b9
updated wrappers to build on clang
Sep 29, 2014
e147814
added support for size_t in properties and slots
Sep 29, 2014
6d72ce6
added support for [] mapping operators
Oct 2, 2014
6b138fc
remoted QClipboard promoter
Oct 6, 2014
727c76c
fully removed QClipboard::event
Oct 8, 2014
2fb87cf
moved uitools to CONFIG for QT4
Oct 8, 2014
7502fb5
using AsLongLong to allow larger Python int values to be converted to…
Oct 8, 2014
842e116
fixed protected static method promotion
Oct 13, 2014
5b6787b
fixed protected static method promotion (which in Qt 5.3 occurs only …
Oct 13, 2014
399a59d
moved iostream include to the top, since people reported XCode6 compi…
Oct 13, 2014
89d0b4c
added new inject-code target pywrap-operators
Oct 23, 2014
c37dacf
improved generator to allow disabling shell and promoter creation
Oct 29, 2014
180ee19
special check for inventor wrappers
Oct 29, 2014
6fb8fdf
remove virtual functions that are removed from the target language (w…
Oct 29, 2014
36564dc
added support for additional code injection places
Nov 5, 2014
221937d
added support for additional code injection places
Nov 10, 2014
01874b2
speedup of generator by factor 2
Nov 11, 2014
42e1dfa
added special field accessors for Inventor
Nov 13, 2014
6f219bf
merged various improvements from MeVisLab repository
Dec 15, 2014
7a662ac
fixed method promotion code when argument is named like the method
Jan 12, 2015
6f2c21f
initial support for ownership handling
Jan 14, 2015
d577ccf
added initial support for passing ownership to C++ and Python using t…
Jan 15, 2015
e2a1eee
improved signature normalization
Jan 19, 2015
b0056bc
added support for QList ownership passing
Jan 19, 2015
4bb136e
fixed bug that was introduced by refactoring
Jan 20, 2015
f5eb178
added more default arguments
Jan 20, 2015
e558014
added ownership handling to central Qt classes
Jan 21, 2015
949abff
fixed ugly problem with itemChange method
Jan 21, 2015
b699027
regenerated wrappers for Qt 5.3 including ownership handling
Feb 3, 2015
5eceded
regenerated wrappers for Qt 5.0 including ownership handling
Feb 3, 2015
adf2040
regenerated wrappers for Qt 4.8 including ownership handling
Feb 3, 2015
7781f0b
updated docs
Feb 3, 2015
1d2aa70
fixed compilation
Feb 3, 2015
3de2202
removed mapPlanes that can not be wrapped
Feb 3, 2015
8d2c7c0
added Qt 5.4
Feb 3, 2015
a8de7f1
added Qt 5.4 support
Feb 3, 2015
3659ca6
added Qt 5.4 wrappers
Feb 3, 2015
a1fc69f
removed PyQt references
Feb 4, 2015
f9858cd
removed extra incref on PyObject* that are returned from slots. The r…
Apr 22, 2015
b60922b
fixed ref-counting in test
Apr 22, 2015
2d445d5
reuse wrapper if it inherits, not only if it is the same class
May 4, 2015
3cd57d7
Fix VS2010 compilation issue when PythonQt Debug build against python…
Mar 26, 2013
aa11edd
Fix mac build error with C standard lib macros
pieper Jul 12, 2012
ec51dc9
Add README file specific to CTK github fork
jcfr Jul 10, 2012
6aa410e
Fix "_invalid_parameter_noinfo_noreturn" link error
jcfr May 28, 2013
e802dcc
Update Readme.md to use new url format for svn revision reference
jcfr Sep 10, 2013
90ef60f
Add CMake testing support
jcfr Sep 10, 2013
dbf0900
Revert part of r91 preventing QFlags from being wrapped
jcfr Sep 10, 2013
166bb44
fix problem in CMake error message
mwoehlke-kitware May 21, 2014
502cba0
allow specifying install directories
mwoehlke-kitware May 21, 2014
49c5b5b
remove trailing spaces in CMakeLists.txt
mwoehlke-kitware May 21, 2014
990cfab
Fix unused variable warning in PythonQtSlot
texpert May 7, 2015
503597b
Ensure "PythonQtUtils.h" is installed when building using CMake
jcfr May 10, 2015
f2c1b29
Added CMake build system.
ericheim May 6, 2015
bd4e1e5
Added qt5 in testing and variable re-naming to match the previously u…
ericheim May 11, 2015
0fca79f
fixed rebase merge conflicts
ericheim May 11, 2015
1cb4c4f
fixed win32 linker issues and test build with qt5
ericheim May 12, 2015
36ab9c7
removed debug message
ericheim May 12, 2015
e31864b
Added Qt versions greater than 5.4 in cmake build. Use 5.4 wrappers a…
ericheim Feb 10, 2016
3388c4f
Update README.md to describe the "patched-5" branch
jcfr Aug 31, 2015
9ce3be3
Add missing refcount decrements when creating wrappers
msmolens Aug 28, 2015
a7e2b88
Fix refcount of PyInt_Type when creating enum wrapper
msmolens Aug 31, 2015
296b902
Prevent crash when an object is destroyed after calling PythonQt::cle…
msmolens Aug 28, 2015
f891954
fixed error handling for evalFile
May 29, 2015
aea3b94
fixed a missign QMetaObject::disconnect which leads to connection lea…
Jun 3, 2015
fd6082d
fixed test
Jun 4, 2015
857a7df
initial version that handles qualified virtual calls better
Jun 18, 2015
e40bdf9
improved handling of qualified virtual calls
Jun 18, 2015
0cb64a5
improved handling of qualified virtual calls
Jun 18, 2015
dbeb475
removed generating wrappers for virtual functions that are already de…
Jun 18, 2015
98d1c58
Enable "name" property support
msmolens Sep 1, 2015
e90a690
Update README.md to describe new commits
msmolens Sep 4, 2015
039d785
Prevent crashes during and after cleanup
msmolens Sep 11, 2015
a636d5a
Fix tests link error on Windows
msmolens Sep 11, 2015
9245264
Fix refcount problems seen when re-initializing Python after finalizing
msmolens Sep 11, 2015
e41b773
Explicitly initialize global storage containers
msmolens Sep 11, 2015
81e51e4
Add cleanup/finalization tests
msmolens Sep 11, 2015
af6cc54
Fix PythonQtSignalReceiver crash during cleanup
msmolens Sep 15, 2015
0171dce
Forked PythonQt 3.0 from Sourceforge and added CMake build system
ericheim Feb 17, 2016
72abf21
fixed rebase merge conflicts
ericheim May 11, 2015
7bbf27f
fixed win32 linker issues and test build with qt5
ericheim May 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
236 changes: 184 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#-----------------------------------------------------------------------------
# NOTE: The CMake files have been contributed to PythonQt and have not been tested with the current
# PythonQt version. They have not yet been updated to support Qt 5 and/or Python 3.
#
# If you are not a CMake expert, you should better use the provided qmake profiles.
#-----------------------------------------------------------------------------

cmake_minimum_required(VERSION 2.8)

#-----------------------------------------------------------------------------
Expand All @@ -6,6 +13,14 @@ project(PythonQt)

include(CTestUseLaunchers OPTIONAL)

#----------------------------------------------------------------------------
# Qt version

set(PythonQt_QT_VERSION 5 CACHE STRING "Pick a version of Qt to use: 4 or 5")

set(minimum_required_qt5_version "5.3.0")
set(minimum_required_qt4_version "4.6.2")

#-----------------------------------------------------------------------------
# Python libraries

Expand All @@ -15,17 +30,39 @@ add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)

#-----------------------------------------------------------------------------
# Build options
option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)

if(PythonQt_QT_VERSION MATCHES 4)
set(qtlibs core gui network opengl sql svg uitools webkit xml xmlpatterns locale)
else()
set(qtlibs Core Network OpenGL Sql Svg Widgets WebKitWidgets Xml XmlPatterns UiTools)
endif()

if(NOT DEFINED PythonQt_INSTALL_RUNTIME_DIR)
set(PythonQt_INSTALL_RUNTIME_DIR bin)
endif()

if(NOT DEFINED PythonQt_INSTALL_LIBRARY_DIR)
set(PythonQt_INSTALL_LIBRARY_DIR lib${LIB_SUFFIX})
endif()

if(NOT DEFINED PythonQt_INSTALL_ARCHIVE_DIR)
set(PythonQt_INSTALL_ARCHIVE_DIR lib${LIB_SUFFIX})
endif()

if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR)
set(PythonQt_INSTALL_INCLUDE_DIR include/PythonQt)
endif()

option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)

set(qtlibs core gui network opengl sql svg uitools webkit xml xmlpatterns)
foreach(qtlib ${qtlibs})
OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF)
endforeach()

# Force option if it applies
if(PythonQt_Wrap_QtAll)
list(REMOVE_ITEM qtlibs xmlpatterns) # xmlpatterns wrapper does *NOT* build at all :(
list(REMOVE_ITEM qtlibs XmlPatterns) # xmlpatterns wrapper does *NOT* build at all :(
foreach(qtlib ${qtlibs})
if(NOT ${PythonQt_Wrap_Qt${qtlib}})
set(PythonQt_Wrap_Qt${qtlib} ON CACHE BOOL "Make all of Qt${qtlib} available in python" FORCE)
Expand All @@ -44,47 +81,97 @@ endif()
#-----------------------------------------------------------------------------
# Setup Qt

set(minimum_required_qt_version "4.6.2")
if(PythonQt_QT_VERSION MATCHES 5)

find_package(Qt4)
if(BUILD_TESTING)
list(APPEND qtlibs Test)
endif()

if(QT4_FOUND)
find_package(Qt5 ${minimum_required_qt5_version} COMPONENTS ${qtlibs} REQUIRED)

set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
if(Qt5_DIR)
get_filename_component(_Qt5_DIR "${Qt5_DIR}/../../../" ABSOLUTE)
list(FIND CMAKE_PREFIX_PATH "${_Qt5_DIR}" _result)
if(_result LESS 0)
set(CMAKE_PREFIX_PATH "${_Qt5_DIR};${CMAKE_PREFIX_PATH}" CACHE PATH "" FORCE)
endif()
endif()

if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version})
message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.")
get_target_property(_qmake_exec Qt5::qmake LOCATION)
execute_process(COMMAND ${_qmake_exec} -query QT_INSTALL_BINS
RESULT_VARIABLE _result
OUTPUT_VARIABLE QT_BINARY_DIR
ERROR_VARIABLE _error
)
string(STRIP "${QT_BINARY_DIR}" QT_BINARY_DIR)
if(_result OR NOT EXISTS "${QT_BINARY_DIR}")
message(FATAL_ERROR "Could not determine Qt binary directory: ${_result} ${QT_BINARY_DIR} ${_error}")
endif()

# Enable required qt module
foreach(qtlib network opengl sql svg uitools webkit xml xmlpatterns)
string(TOUPPER ${qtlib} qtlib_uppercase)
if (NOT ${QT_QT${qtlib_uppercase}_FOUND})
message(FATAL_ERROR "QT_QT${${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}")
endif()
set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}})

set(QT_LIBRARIES )
foreach(qtlib ${qtlibs})
include_directories(${Qt5${qtlib}_INCLUDE_DIRS})
list(APPEND QT_LIBRARIES ${Qt5${qtlib}_LIBRARIES})
add_definitions(${Qt5${qtlib}_DEFINITIONS})
endforeach()

include(${QT_USE_FILE})

#-----------------------------------------------------------------------------
# The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
# associated with the Qt version being used.
set(generated_cpp_suffix "_${Qt5Core_VERSION_MAJOR}${Qt5Core_VERSION_MINOR}")

# Use Qt5.4 as default for higher versions like it's done in build/common.prf
if(${Qt5Core_VERSION_MINOR} GREATER 4)
set(generated_cpp_suffix "_${Qt5Core_VERSION_MAJOR}4")
endif()


else()
message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
endif()
#-----------------------------------------------------------------------------
# Setup Qt4

#-----------------------------------------------------------------------------
# The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
# associated with the Qt version being used.
set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}")
if("${generated_cpp_suffix}" STREQUAL "_48")
set(generated_cpp_suffix "")
endif()
if("${generated_cpp_suffix}" STREQUAL "_46")
set(generated_cpp_suffix "_47") # Also use 4.7 wrappers for 4.6.x version
endif()
find_package(Qt4)

if(QT4_FOUND)

set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})

if(${found_qt_version} VERSION_LESS ${minimum_required_qt4_version})
message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt4_version} -- you cannot use Qt ${found_qt_version}.")
endif()

# Enable required qt module
foreach(qtlib ${qtlibs})
string(TOUPPER ${qtlib} qtlib_uppercase)
if (NOT ${QT_QT${qtlib_uppercase}_FOUND})
message(FATAL_ERROR "QT_QT${${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}")
endif()
set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}})
endforeach()

set(QT_USE_QTTEST ${BUILD_TESTING})

include(${QT_USE_FILE})
else()
message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
endif()

#-----------------------------------------------------------------------------
# The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
# associated with the Qt version being used.
set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}")

# TODO: generated headers for Qt4.8 contains several locales that are not available
# out of the box -> force 4.7
if("${generated_cpp_suffix}" STREQUAL "_46" OR "${generated_cpp_suffix}" STREQUAL "_48")
set(generated_cpp_suffix "_47") # Also use 4.7 wrappers for 4.6.x version
endif()
endif()
#-----------------------------------------------------------------------------
# Sources

set(sources
src/PythonQtBoolResult.cpp
src/PythonQtClassInfo.cpp
src/PythonQtClassWrapper.cpp
src/PythonQtConversion.cpp
Expand All @@ -102,8 +189,6 @@ set(sources
src/PythonQtStdIn.cpp
src/PythonQtStdOut.cpp
src/gui/PythonQtScriptingConsole.cpp

generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.cpp

generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp
generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp
Expand All @@ -115,6 +200,7 @@ set(sources
# List headers. This is list is used for the install command.

set(headers
src/PythonQtBoolResult.h
src/PythonQtClassInfo.h
src/PythonQtClassWrapper.h
src/PythonQtConversion.h
Expand All @@ -137,9 +223,12 @@ set(headers
src/PythonQtSystem.h
src/PythonQtVariants.h
src/PythonQtPythonInclude.h
generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h
src/PythonQtUtils.h
)

if(PythonQt_QT_VERSION MATCHES 4)
set(sources ${sources} generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.cpp)
set(headers ${headers} generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h)
endif()
#-----------------------------------------------------------------------------
# Headers that should run through moc

Expand All @@ -155,28 +244,28 @@ set(moc_sources

#-----------------------------------------------------------------------------
# Add extra sources
foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
foreach(qtlib ${qtlibs})

if (${PythonQt_Wrap_Qt${qtlib}})

ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})

set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})

foreach(index RANGE 0 11)

# Source files
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
list(APPEND sources ${file_prefix}${index}.cpp)
endif()

# Headers that should run through moc
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
list(APPEND moc_sources ${file_prefix}${index}.h)
endif()

endforeach()

list(APPEND sources ${file_prefix}_init.cpp)

endif()
Expand All @@ -192,17 +281,22 @@ set(qrc_sources )

#-----------------------------------------------------------------------------
# Do wrapping
qt4_wrap_cpp(gen_moc_sources ${moc_sources})
qt4_wrap_ui(gen_ui_sources ${ui_sources})
qt4_add_resources(gen_qrc_sources ${qrc_sources})

if(PythonQt_QT_VERSION MATCHES 4)
qt4_wrap_cpp(gen_moc_sources ${moc_sources})
qt4_wrap_ui(gen_ui_sources ${ui_sources})
qt4_add_resources(gen_qrc_sources ${qrc_sources})
else()
qt5_wrap_cpp(gen_moc_sources ${moc_sources})
qt5_wrap_ui(gen_ui_sources ${ui_sources})
qt5_add_resources(gen_qrc_sources ${qrc_sources})
endif()
#-----------------------------------------------------------------------------
# Build the library

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
)

add_library(PythonQt SHARED
${sources}
${gen_moc_sources}
Expand All @@ -228,7 +322,45 @@ target_link_libraries(PythonQt
# Install library (on windows, put the dll in 'bin' and the archive in 'lib')

install(TARGETS PythonQt
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES ${headers} DESTINATION include/PythonQt)
RUNTIME DESTINATION ${PythonQt_INSTALL_RUNTIME_DIR}
LIBRARY DESTINATION ${PythonQt_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${PythonQt_INSTALL_ARCHIVE_DIR})
install(FILES ${headers} DESTINATION ${PythonQt_INSTALL_INCLUDE_DIR})

#-----------------------------------------------------------------------------
# Testing

option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest)

if(BUILD_TESTING)
create_test_sourcelist(test_sources PythonQtCppTests.cpp
tests/PythonQtTestMain.cpp
)

list(APPEND test_sources
tests/PythonQtTests.cpp
tests/PythonQtTests.h
)
if(PythonQt_QT_VERSION MATCHES 4)
QT4_WRAP_CPP(test_sources
tests/PythonQtTests.h
)
else()
QT5_WRAP_CPP(test_sources
tests/PythonQtTests.h
)
endif()

set_property(SOURCE tests/PythonQtTestMain.cpp PROPERTY COMPILE_DEFINITIONS "main=tests_PythonQtTestMain")

add_executable(PythonQtCppTests ${test_sources})
target_link_libraries(PythonQtCppTests PythonQt ${Qt5Test_LIBRARIES})

add_test(
NAME tests_PythonQtTestMain
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:PythonQtCppTests> tests/PythonQtTestMain
)
endif()


Loading