diff --git a/CMakeLists.txt b/CMakeLists.txt index 6368d1f..4324132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,11 +26,7 @@ endif(PythonQt_Qt5) #----------------------------------------------------------------------------- # The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers # associated with the Qt version being used. -if(PythonQt_Qt5) - set(generated_cpp_suffix "_${Qt5Core_VERSION_MAJOR}${Qt5Core_VERSION_MINOR}") -else() - set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}") -endif() +set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}") if("${generated_cpp_suffix}" STREQUAL "_48") set(generated_cpp_suffix "") @@ -118,6 +114,27 @@ include_directories(${PYTHON_INCLUDE_DIRS}) add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK) #----------------------------------------------------------------------------- +# Library Name +# The variable PythonQt_LibraryName contains the PythonQt core library name +# It incorporates library mayor versions +# The variable PythonQt_LibrarySuffix is "" or "_d", if it is a debug build +set(PythonQt_LibraryName PythonQt) + +if(PythonQt_Qt5) + set(PythonQt_LibraryName ${PythonQt_LibraryName}5) +endif() + +if(NOT ${PYTHON_VERSION} VERSION_LESS 3) + set(PythonQt_LibraryName ${PythonQt_LibraryName}_3) +endif() + +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(PythonQt_LibrarySuffix _d) +endif() + +message(STATUS "Building ${PythonQt_LibraryName}${PythonQt_LibrarySuffix} (Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} + Python ${PYTHON_VERSION} | ${CMAKE_BUILD_TYPE})") + +#----------------------------------------------------------------------------- # Core add_subdirectory(src) diff --git a/build/PythonQt.prf b/build/PythonQt.prf new file mode 100644 index 0000000..cbe6e89 --- /dev/null +++ b/build/PythonQt.prf @@ -0,0 +1,16 @@ +# profile for non-mevis users to link to PythonQt + +include ( python.prf ) + +INCLUDEPATH += $$PWD/../src + +# check if debug or release +CONFIG(debug, debug|release) { + DEBUG_EXT = _d +} else { + DEBUG_EXT = +} + +win32-msvc*:LIBS += $$PWD/../lib/PythonQt$${DEBUG_EXT}.lib +win32-g++:LIBS += $$PWD/../lib/libPythonQt$${DEBUG_EXT}.a +unix:LIBS += -L$$OUT_PWD/../lib -L$$OUT_PWD/../../lib -lPythonQt$${DEBUG_EXT} diff --git a/build/PythonQt_QtAll.prf b/build/PythonQt_QtAll.prf new file mode 100644 index 0000000..e535ddf --- /dev/null +++ b/build/PythonQt_QtAll.prf @@ -0,0 +1,13 @@ +# profile for non-mevis users to link to PythonQt_QtAll + +INCLUDEPATH += $$PWD/../extensions/PythonQt_QtAll + +# check if debug or release +CONFIG(debug, debug|release) { + DEBUG_EXT = _d +} else { + DEBUG_EXT = +} + +win32::LIBS += $$PWD/../lib/PythonQt_QtAll$${DEBUG_EXT}.lib +unix::LIBS += -L$$PWD/../lib -lPythonQt_QtAll$${DEBUG_EXT} diff --git a/build/common.prf b/build/common.prf new file mode 100644 index 0000000..bdc86a1 --- /dev/null +++ b/build/common.prf @@ -0,0 +1,23 @@ + +# depending on your Qt configuration, you want to enable or disable +# one of the release/debug builds (if all three lines are commented, +# the default of your Qt installation will used) + +# build with both debug and release mode +#CONFIG += debug_and_release build_all + +# build with release mode only +#CONFIG += release + +# build with debug mode only +#CONFIG += debug + +# for all debug builds, add "_d" extension to target +CONFIG(debug, debug|release) { + TARGET = $${TARGET}_d +} +mac { + QMAKE_POST_LINK += bash $$PWD/../scripts/osx-fix-dylib.sh +} + +#message("Directory - Build-Target: "$$PWD - $$TARGET) diff --git a/build/python.prf b/build/python.prf new file mode 100644 index 0000000..c98865e --- /dev/null +++ b/build/python.prf @@ -0,0 +1,43 @@ +# profile to include and link Python + +# Change this variable to your python version (2.5, 2.6) +win32:PYTHON_VERSION=27 +unix:PYTHON_VERSION=2.7 + +macx { + # for macx you need to have the Python development kit installed as framework + INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers + LIBS += -F/System/Library/Frameworks -framework Python +} else:win32 { + # for windows install a Python development kit or build Python yourself from the sources + # Make sure that you set the environment variable PYTHON_PATH to point to your + # python installation (or the python sources/header files when building from source). + # Make sure that you set the environment variable PYTHON_LIB to point to + # the directory where the python libs are located. + # + # When using the prebuild Python installer, this will be: + # set PYTHON_PATH = c:\Python26 + # set PYTHON_LIB = c:\Python26\libs + # + # When using the python sources, this will be something like: + # set PYTHON_PATH = c:\yourDir\Python-2.6.1\ + # set PYTHON_LIB = c:\yourDir\Python-2.6.1\PCbuild8\Win32 + + # check if debug or release + CONFIG(debug, debug|release) { + DEBUG_EXT = _d + } else { + DEBUG_EXT = + } + + win32:INCLUDEPATH += $(PYTHON_PATH)/PC $(PYTHON_PATH)/include + win32-msvc*:LIBS += $(PYTHON_LIB)/python$${PYTHON_VERSION}$${DEBUG_EXT}.lib + win32-g++:LIBS += $(PYTHON_PATH)/libs/libpython$${PYTHON_VERSION}.a + +} else:unix { + # on linux, python-config is used to autodetect Python. + # make sure that you have installed a matching python-dev package. + + unix:LIBS += $$system(python$${PYTHON_VERSION}-config --libs) + unix:QMAKE_CXXFLAGS += $$system(python$${PYTHON_VERSION}-config --includes) +} diff --git a/cmake/PythonQt_Qt_5x.cmake b/cmake/PythonQt_Qt_5x.cmake index 47cf5c2..37ba502 100644 --- a/cmake/PythonQt_Qt_5x.cmake +++ b/cmake/PythonQt_Qt_5x.cmake @@ -12,3 +12,8 @@ endmacro() macro(qt_add_resources) qt5_add_resources(${ARGN}) endmacro() + +# version +set(QT_VERSION_MAJOR ${Qt5Core_VERSION_MAJOR}) +set(QT_VERSION_MINOR ${Qt5Core_VERSION_MINOR}) +set(QT_VERSION_PATCH ${Qt5Core_VERSION_PATCH}) diff --git a/examples/NicePyConsole/CMakeLists.txt b/examples/NicePyConsole/CMakeLists.txt index f3c9d84..0378c11 100644 --- a/examples/NicePyConsole/CMakeLists.txt +++ b/examples/NicePyConsole/CMakeLists.txt @@ -23,6 +23,10 @@ SET(FILES module_completion.py ) +SET(DIRS + pygments +) + qt_wrap_cpp(GEN_MOC ${HEADERS}) add_executable(NicePyConsole ${SOURCES} ${GEN_MOC}) @@ -31,13 +35,27 @@ if(PythonQt_Qt5) else() qt_use_modules(NicePyConsole Core Gui) endif() -get_property(PythonQt_lib TARGET PythonQt PROPERTY LOCATION) -get_property(PythonQt_QtAll_lib TARGET PythonQt_QtAll PROPERTY LOCATION) + +get_property(PythonQt_lib TARGET ${PythonQt} PROPERTY LOCATION) +get_property(PythonQt_QtAll_lib TARGET ${PythonQt_QtAll} PROPERTY LOCATION) target_link_libraries(NicePyConsole ${PythonQt_lib} ${PythonQt_QtAll_lib} ${PYTHON_LIBRARIES}) foreach(FILE ${FILES}) - add_custom_command(OUTPUT ${FILE} - COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" + SET(OUT "${CMAKE_CURRENT_BINARY_DIR}/${FILE}") + SET(IN "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}") + add_custom_command(OUTPUT "${OUT}" + COMMAND "${CMAKE_COMMAND}" -E copy "${IN}" "${OUT}" + MAIN_DEPENDENCY "${IN}" + ) + add_dependencies(NicePyConsole "${OUT}") +endforeach() + +foreach(DIR ${DIRS}) + SET(OUT "${CMAKE_CURRENT_BINARY_DIR}/${DIR}") + SET(IN "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}") + add_custom_command(OUTPUT "${OUT}" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${IN}" "${OUT}" + MAIN_DEPENDENCY "${IN}" ) - add_dependencies(NicePyConsole ${FILE}) + add_dependencies(NicePyConsole "${OUT}") endforeach() diff --git a/extensions/PythonQt_QtAll/CMakeLists.txt b/extensions/PythonQt_QtAll/CMakeLists.txt index 5d28023..0a411d9 100644 --- a/extensions/PythonQt_QtAll/CMakeLists.txt +++ b/extensions/PythonQt_QtAll/CMakeLists.txt @@ -1,7 +1,5 @@ project(PythonQt_QtAll) -SET(GEN ../../generated_cpp${generated_cpp_suffix}) - # Bindings SET(HEADERS PythonQt_QtAll.h @@ -11,147 +9,152 @@ SET(SOURCES PythonQt_QtAll.cpp ) -# Core -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core0.h - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core1.h - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core2.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core0.cpp - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core1.cpp - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core2.cpp - ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp -) - -# Gui -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui0.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui1.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui2.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui3.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui4.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui5.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui6.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui7.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui8.h - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui9.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp - ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui_init.cpp -) - -# Network -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network0.cpp - ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp -) - -# OpenGL -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp - ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl_init.cpp -) - -# Sql -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp - ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql_init.cpp -) - -# Svg -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp - ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg_init.cpp -) - -# uitools -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp - ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools_init.cpp -) - -# WebKit -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.h -) - -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp - ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit_init.cpp -) - -# Xml -LIST(APPEND HEADERS - ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml0.h -) +#------------------------------------------------------------------- +# Generated stuff +SET(GEN ../../generated_cpp${generated_cpp_suffix}) -LIST(APPEND SOURCES - ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp - ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml_init.cpp -) +foreach(MODULE core gui network opengl sql svg uitools webkit xml) + SET(MODULE_TROLL com_trolltech_qt_${MODULE}) + SET(MODULE_BASE ${GEN}/${MODULE_TROLL}/${MODULE_TROLL}) + FILE(GLOB HFILES ${MODULE_BASE}*.h) + FILE(GLOB CFILES ${MODULE_BASE}*.cpp) + LIST(APPEND HEADERS ${HFILES}) + LIST(APPEND SOURCES ${CFILES}) +endforeach() + +## Core +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core0.h +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core1.h +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core2.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core0.cpp +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core1.cpp +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core2.cpp +# ${GEN}/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp +#) + +## Gui +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui0.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui1.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui2.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui3.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui4.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui5.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui6.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui7.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui8.h +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui9.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp +# ${GEN}/com_trolltech_qt_gui/com_trolltech_qt_gui_init.cpp +#) + +## Network +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network0.cpp +# ${GEN}/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp +#) + +## OpenGL +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp +# ${GEN}/com_trolltech_qt_opengl/com_trolltech_qt_opengl_init.cpp +#) + +## Sql +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp +# ${GEN}/com_trolltech_qt_sql/com_trolltech_qt_sql_init.cpp +#) + +## Svg +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp +# ${GEN}/com_trolltech_qt_svg/com_trolltech_qt_svg_init.cpp +#) + +## uitools +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp +# ${GEN}/com_trolltech_qt_uitools/com_trolltech_qt_uitools_init.cpp +#) + +## WebKit +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp +# ${GEN}/com_trolltech_qt_webkit/com_trolltech_qt_webkit_init.cpp +#) + +## Xml +#LIST(APPEND HEADERS +# ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml0.h +#) + +#LIST(APPEND SOURCES +# ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp +# ${GEN}/com_trolltech_qt_xml/com_trolltech_qt_xml_init.cpp +#) #------------------------------------------------------------------- # Build +set(PythonQt_QtAll ${PythonQt_LibraryName}_QtAll${PythonQt_LibrarySuffix} CACHE INTERNAL "") include_directories(../../src) add_definitions(-DPYTHONQT_QTALL_EXPORTS) qt_wrap_cpp(GEN_MOC ${HEADERS}) -SET(QT - Core - Gui - Network - OpenGL - Sql - Svg - UiTools - WebKit - Xml -) - +SET(QT Core Gui Network OpenGL Sql Svg UiTools WebKit Xml) if(PythonQt_Qt5) - LIST(APPEND QT - Widgets - WebKitWidgets - ) + LIST(APPEND QT Widgets WebKitWidgets) endif() -add_library(PythonQt_QtAll SHARED ${SOURCES} ${GEN_MOC}) -qt_use_modules(PythonQt_QtAll ${QT}) +add_library(${PythonQt_QtAll} SHARED ${SOURCES} ${GEN_MOC}) +qt_use_modules(${PythonQt_QtAll} ${QT}) + +get_property(PythonQt_lib TARGET ${PythonQt} PROPERTY LOCATION) +target_link_libraries(${PythonQt_QtAll} ${PythonQt_lib} ${PYTHON_LIBRARIES}) -get_property(PythonQt_lib TARGET PythonQt PROPERTY LOCATION) -target_link_libraries(PythonQt_QtAll ${PythonQt_lib} ${PYTHON_LIBRARIES}) +install(TARGETS ${PythonQt_QtAll} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) diff --git a/generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h b/generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h index f4cb650..3b85fdd 100644 --- a/generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h +++ b/generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h @@ -186,7 +186,11 @@ void delete_QByteArray(QByteArray* obj) { delete obj; } PyObject* data(QByteArray* b) { if (b->data()) { +#ifdef PY3K + return PyUnicode_FromStringAndSize(b->data(), b->size()); +#else return PyString_FromStringAndSize(b->data(), b->size()); +#endif } else { Py_INCREF(Py_None); return Py_None; diff --git a/generator_50/CMakeLists.txt b/generator_50/CMakeLists.txt index d50a86f..6754139 100644 --- a/generator_50/CMakeLists.txt +++ b/generator_50/CMakeLists.txt @@ -8,8 +8,7 @@ SET(RESOURCES) SET(INCLUDEPATH) SET(DEFINES) -SET(GENERATORPATH ${CMAKE_CURRENT_SOURCE_DIR}) -include(${GENERATORPATH}/generator_50.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/generator_50.cmake) LIST(APPEND HEADERS #generatorscript.h diff --git a/generator_50/generator_50.cmake b/generator_50/generator_50.cmake index 9a9109e..72d030c 100644 --- a/generator_50/generator_50.cmake +++ b/generator_50/generator_50.cmake @@ -1,13 +1,16 @@ +IF(NOT GENERATORPATH) + SET(GENERATORPATH ${CMAKE_CURRENT_LIST_DIR}) +ENDIF() + LIST(APPEND INCLUDEPATH ${GENERATORPATH}) LIST(APPEND INCLUDEPATH ${GENERATORPATH}/.) LIST(APPEND INCLUDEPATH ${GENERATORPATH}/../common) LIST(APPEND RESOURCES ${GENERATORPATH}/generator.qrc) -SET(RXXPATH ${GENERATORPATH}/parser) -include(${RXXPATH}/rxx.cmake) -include(${RXXPATH}/rpp/rpp.cmake) +include(${GENERATORPATH}/parser/rxx.cmake) +include(${GENERATORPATH}/parser/rpp/rpp.cmake) LIST(APPEND HEADERS ${GENERATORPATH}/generator.h diff --git a/generator_50/parser/rxx.cmake b/generator_50/parser/rxx.cmake index 69d3f8d..a3b35ce 100644 --- a/generator_50/parser/rxx.cmake +++ b/generator_50/parser/rxx.cmake @@ -1,3 +1,8 @@ + +IF(NOT RXXPATH) + SET(RXXPATH ${CMAKE_CURRENT_LIST_DIR}) +ENDIF() + LIST(APPEND INCLUDEPATH ${RXXPATH}) LIST(APPEND DEFINES -DRXX_ALLOCATOR_INIT_0) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97ee1f6..2a641f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,35 +78,32 @@ set(SOURCES_MOC set(SOURCES_QRC ) #----------------------------------------------------------------------------- -# Do wrapping -qt_wrap_cpp(GEN_MOC ${SOURCES_MOC}) -qt_add_resources(GEN_QRC ${SOURCES_QRC}) - -#----------------------------------------------------------------------------- # Build the library +set(PythonQt ${PythonQt_LibraryName}${PythonQt_LibrarySuffix} CACHE INTERNAL "") include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -#add_definitions(-DQT_NO_KEYWORDS) # recent python versions use them :( +qt_wrap_cpp(GEN_MOC ${SOURCES_MOC}) +qt_add_resources(GEN_QRC ${SOURCES_QRC}) -add_library(PythonQt SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC} ${HEADERS}) +add_library(${PythonQt} SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC} ${HEADERS}) if(PythonQt_Qt5) - qt_use_modules(PythonQt Core Gui Widgets) + qt_use_modules(${PythonQt} Core Gui Widgets) else() - qt_use_modules(PythonQt Core Gui) + qt_use_modules(${PythonQt} Core Gui) endif() -target_link_libraries(PythonQt ${PYTHON_LIBRARIES}) +target_link_libraries(${PythonQt} ${PYTHON_LIBRARIES}) # # That should solve linkage error on Mac when the project is used in a superbuild setup # See http://blog.onesadcookie.com/2008/01/installname-magic.html # -set_target_properties(PythonQt PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +set_target_properties(${PythonQt} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") #----------------------------------------------------------------------------- # Install library (on windows, put the dll in 'bin' and the archive in 'lib') -install(TARGETS PythonQt +install(TARGETS ${PythonQt} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) diff --git a/src/PythonQtInstanceWrapper.cpp b/src/PythonQtInstanceWrapper.cpp index c1362f4..7eef089 100644 --- a/src/PythonQtInstanceWrapper.cpp +++ b/src/PythonQtInstanceWrapper.cpp @@ -662,20 +662,20 @@ static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) if (wrapper->_wrappedPtr) { if (wrapper->_obj) { #ifdef PY3K - return PyUnicode_FromFormat("%s (C++ Object %p wrapped by %s %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); + return PyUnicode_FromFormat("<%s C++ Object at %p wrapped by %s at %p>", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); #else return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); #endif } else { #ifdef PY3K - return PyUnicode_FromFormat("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr); + return PyUnicode_FromFormat("<%s C++ Object at %p>", typeName, wrapper->_wrappedPtr); #else return PyString_FromFormat("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr); #endif } } else { #ifdef PY3K - return PyUnicode_FromFormat("%s (QObject %p)", typeName, qobj); + return PyUnicode_FromFormat("<%s QObject at %p>", typeName, qobj); #else return PyString_FromFormat("%s (QObject %p)", typeName, qobj); #endif @@ -698,7 +698,7 @@ static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) #endif } else { #ifdef PY3K - return PyUnicode_FromFormat("%s (%s, at: %p)", typeName, str.toLatin1().constData(), wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj); + return PyUnicode_FromFormat("<%s %s at %p>", typeName, str.toLatin1().constData(), wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj); #else return PyString_FromFormat("%s (%s, at: %p)", typeName, str.toLatin1().constData(), wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj); #endif @@ -707,20 +707,20 @@ static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) if (wrapper->_wrappedPtr) { if (wrapper->_obj) { #ifdef PY3K - return PyUnicode_FromFormat("%s (C++ object at: %p wrapped by %s at: %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); + return PyUnicode_FromFormat("<%s C++ object at %p wrapped by %s at %p>", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); #else return PyString_FromFormat("%s (C++ object at: %p wrapped by %s at: %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); #endif } else { #ifdef PY3K - return PyUnicode_FromFormat("%s (C++ object at: %p)", typeName, wrapper->_wrappedPtr); + return PyUnicode_FromFormat("<%s C++ object at %p>", typeName, wrapper->_wrappedPtr); #else return PyString_FromFormat("%s (C++ object at: %p)", typeName, wrapper->_wrappedPtr); #endif } } else { #ifdef PY3K - return PyUnicode_FromFormat("%s (%s at: %p)", typeName, wrapper->classInfo()->className(), qobj); + return PyUnicode_FromFormat("<%s %s at %p>", typeName, wrapper->classInfo()->className(), qobj); #else return PyString_FromFormat("%s (%s at: %p)", typeName, wrapper->classInfo()->className(), qobj); #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9e5edd1..51591bb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,5 +22,5 @@ if(PythonQt_Qt5) else() qt_use_modules(PythonQtTest Test Gui) endif() -get_property(PythonQt_lib TARGET PythonQt PROPERTY LOCATION) +get_property(PythonQt_lib TARGET ${PythonQt} PROPERTY LOCATION) target_link_libraries(PythonQtTest ${PythonQt_lib} ${PYTHON_LIBRARIES})