From Kristofer Tingdahl, with additions from Riccardo Corsi and Robert Milharcic, support for Qt5 build

This commit is contained in:
Robert Osfield
2013-06-10 14:34:25 +00:00
parent 8cf9600e2c
commit bdfd18dc03
25 changed files with 184 additions and 90 deletions

View File

@@ -34,7 +34,7 @@ FOREACH( mylibfolder
ENDFOREACH()
IF (QT4_FOUND AND NOT ANDROID)
IF ((QT4_FOUND OR Qt5Widgets_FOUND) AND NOT ANDROID)
ADD_SUBDIRECTORY(osgQt)
ENDIF()

View File

@@ -81,14 +81,14 @@ IF(CMAKE_SYSTEM MATCHES IRIX)
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
# Add support for using Qt threads
IF(QT4_FOUND)
IF(QT4_FOUND OR Qt5Widgets_FOUND)
OPTION(BUILD_OPENTHREADS_WITH_QT "Build OpenThreads with Qt threading support." OFF)
ENDIF()
# Maybe we should be using the FindThreads.cmake module?
IF(ANDROID)
SUBDIRS(pthreads)
ELSEIF(QT4_FOUND AND BUILD_OPENTHREADS_WITH_QT)
ELSEIF((QT4_FOUND OR Qt5Widgets_FOUND) AND BUILD_OPENTHREADS_WITH_QT)
SUBDIRS(qt)
ELSEIF(WIN32)
# So I think Cygwin wants to use pthreads

View File

@@ -39,8 +39,15 @@ IF(OPENTHREADS_SONAMES)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION})
ENDIF()
TARGET_LINK_LIBRARIES(${LIB_NAME} ${QT_QTCORE_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
if ( QT4_FOUND )
TARGET_LINK_LIBRARIES(${LIB_NAME} ${QT_QTCORE_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
else( QT4_FOUND )
IF ( Qt5Widgets_FOUND )
qt5_use_modules( ${LIB_NAME} Core )
ENDIF ( Qt5Widgets_FOUND )
endif( QT4_FOUND )
# Since we're building different platforms binaries in
# their respective directories, we need to set the

View File

@@ -20,7 +20,7 @@
#define _QTCONDITIONPRIVATEDATA_H_
#include <OpenThreads/Condition>
#include <QtCore/QWaitCondition>
#include <QWaitCondition>
class QtConditionPrivateData : public QWaitCondition
{

View File

@@ -20,7 +20,7 @@
#define _QTMUTEXPRIVATEDATA_H_
#include <OpenThreads/Mutex>
#include <QtCore/QMutex>
#include <QMutex>
class QtMutexPrivateData : public QMutex
{

View File

@@ -16,7 +16,7 @@
// ~~~~~~~~~~~
#include "QtThreadPrivateData.h"
#include <QtCore/QCoreApplication>
#include <QCoreApplication>
#include <iostream>
using namespace OpenThreads;

View File

@@ -21,7 +21,7 @@
#include <OpenThreads/Thread>
#include <OpenThreads/Block>
#include <QtCore/QThread>
#include <QThread>
struct QtThreadCanceled {};

View File

@@ -12,7 +12,11 @@ SET(SOURCES_H
${HEADER_PATH}/QGraphicsViewAdapter
)
QT4_WRAP_CPP( SOURCES_H_MOC ${SOURCES_H} OPTIONS "-f" )
IF ( Qt5Widgets_FOUND )
QT5_WRAP_CPP( SOURCES_H_MOC ${SOURCES_H} OPTIONS "-f" )
ELSE()
QT4_WRAP_CPP( SOURCES_H_MOC ${SOURCES_H} OPTIONS "-f" )
ENDIF()
SET(TARGET_H
${HEADER_PATH}/Export
@@ -47,20 +51,27 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDIF()
SET(TARGET_LIBRARIES
${TARGET_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTOPENGL_LIBRARY}
)
# FIXME: This should work but something with the LINK_WITH_VARIABLES macro is not working
#SET(TARGET_LIBRARIES_VARS
# QT_QTCORE_LIBRARY
# QT_QTGUI_LIBRARY
# QT_QTOPENGL_LIBRARY
#)
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
IF( QT4_FOUND )
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
${QT_QTOPENGL_INCLUDE_DIR} )
SET(TARGET_LIBRARIES
${TARGET_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTOPENGL_LIBRARY}
)
ENDIF( QT4_FOUND )
SETUP_LIBRARY(${LIB_NAME})
IF ( Qt5Widgets_FOUND )
qt5_use_modules( ${LIB_NAME} Widgets OpenGL )
ENDIF ( Qt5Widgets_FOUND )

View File

@@ -14,7 +14,7 @@
#include <osg/DeleteHandler>
#include <osgQt/GraphicsWindowQt>
#include <osgViewer/ViewerBase>
#include <QtGui/QInputEvent>
#include <QInputEvent>
using namespace osgQt;
@@ -96,7 +96,7 @@ public:
KeyMap::iterator itr = mKeyMap.find(event->key());
if (itr == mKeyMap.end())
{
return int(*(event->text().toAscii().data()));
return int(*(event->text().toLatin1().data()));
}
else
return itr->second;

View File

@@ -16,10 +16,10 @@
#include <osgDB/Registry>
#include <osgText/Font>
#include <QtGui/QFont>
#include <QtGui/QFontMetrics>
#include <QtGui/QImage>
#include <QtGui/QPainter>
#include <QFont>
#include <QFontMetrics>
#include <QImage>
#include <QPainter>
namespace osgQt {

View File

@@ -21,8 +21,8 @@
#include <osg/NodeVisitor>
#include <osg/io_utils>
#include <QtGui/QGraphicsItem>
#include <QtGui/QGraphicsProxyWidget>
#include <QGraphicsItem>
#include <QGraphicsProxyWidget>
#define MYQKEYEVENT 2000
#define MYQPOINTEREVENT 2001

View File

@@ -12,7 +12,7 @@
*/
#include <osgQt/QWidgetImage>
#include <QtGui/QLayout>
#include <QLayout>
namespace osgQt
{