Add Qt5 option. Use Qt5 by default.

This commit is contained in:
Sacha 2014-08-19 21:34:00 +10:00
parent e9c5c563a5
commit 90f23020f5
7 changed files with 55 additions and 32 deletions

View file

@ -5,7 +5,7 @@ set -e
#if OS is linux or is not set #if OS is linux or is not set
if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
mkdir build && cd build mkdir build && cd build
cmake .. cmake -DUSE_QT5=OFF ..
make -j4 make -j4
elif [ "$TRAVIS_OS_NAME" = osx ]; then elif [ "$TRAVIS_OS_NAME" = osx ]; then
mkdir build && cd build mkdir build && cd build

View file

@ -14,5 +14,5 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
cd - cd -
elif [ "$TRAVIS_OS_NAME" = osx ]; then elif [ "$TRAVIS_OS_NAME" = osx ]; then
brew tap homebrew/versions brew tap homebrew/versions
brew install glew qt glfw3 pkgconfig brew install glew qt5 glfw3 pkgconfig
fi fi

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.6) cmake_minimum_required(VERSION 2.8.7)
project(citra) project(citra)
@ -33,17 +33,29 @@ include_directories(${GLEW_INCLUDE_PATH})
# workaround for GLFW linking on OSX # workaround for GLFW linking on OSX
link_directories(${GLFW_LIBRARY_DIRS}) link_directories(${GLFW_LIBRARY_DIRS})
option(DISABLE_QT4 "Disable Qt4 GUI" OFF) option(DISABLE_QT "Disable Qt GUI" OFF)
if(NOT DISABLE_QT4) option(USE_QT5 "Use Qt5 when available" ON)
include(FindQt4) if (NOT DISABLE_QT)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL) if(USE_QT5)
find_package(Qt5Gui)
find_package(Qt5Widgets)
find_package(Qt5OpenGL)
if(NOT Qt5Gui_FOUND OR NOT Qt5Widgets_FOUND OR NOT Qt5OpenGL_FOUND)
message("Qt5 libraries not found! Using Qt4 instead.")
set(USE_QT5 OFF)
endif()
endif()
if(NOT USE_QT5)
include(FindQt4)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND) if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND)
include(${QT_USE_FILE}) include(${QT_USE_FILE})
include_directories(${QT_INCLUDES}) include_directories(${QT_INCLUDES})
include_directories(externals/qhexedit) else()
else() message("Qt4 libraries not found! Disabling Qt GUI")
message("Qt4 libraries not found! Disabling Qt4 GUI") set(DISABLE_QT ON)
endif()
endif() endif()
endif() endif()
@ -57,7 +69,8 @@ git_branch_name(GIT_BRANCH)
include_directories(src) include_directories(src)
# process subdirectories # process subdirectories
if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4) if(NOT DISABLE_QT)
include_directories(externals/qhexedit)
add_subdirectory(externals/qhexedit) add_subdirectory(externals/qhexedit)
endif() endif()
add_subdirectory(src) add_subdirectory(src)

View file

@ -1,4 +1,5 @@
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SRCS set(SRCS
commands.cpp commands.cpp
@ -10,6 +11,8 @@ set(HEADERS
qhexedit.h qhexedit.h
qhexedit_p.h) qhexedit_p.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(qhexedit STATIC ${SRCS} ${HEADERS}) add_library(qhexedit STATIC ${SRCS} ${HEADERS})
if(USE_QT5)
target_link_libraries(qhexedit Qt5::Core Qt5::Widgets)
endif()

View file

@ -1,5 +1,3 @@
#include <QtGui>
#include "qhexedit_p.h" #include "qhexedit_p.h"
#include "commands.h" #include "commands.h"
@ -437,7 +435,7 @@ void QHexEditPrivate::keyPressEvent(QKeyEvent *event)
if (!_readOnly) if (!_readOnly)
{ {
/* Hex input */ /* Hex input */
int key = int(event->text()[0].toAscii()); int key = int(event->text()[0].toLatin1());
if ((key>='0' && key<='9') || (key>='a' && key <= 'f')) if ((key>='0' && key<='9') || (key>='a' && key <= 'f'))
{ {
if (getSelectionBegin() != getSelectionEnd()) if (getSelectionBegin() != getSelectionEnd())

View file

@ -5,6 +5,9 @@
#include <QtGui> #include <QtGui>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtWidgets>
#endif
#include "xbytearray.h" #include "xbytearray.h"
class QHexEditPrivate : public QWidget class QHexEditPrivate : public QWidget

View file

@ -14,7 +14,7 @@ set(SRCS
config/controller_config.cpp config/controller_config.cpp
config/controller_config_util.cpp) config/controller_config_util.cpp)
set (HEADERS set(HEADERS
bootmanager.hxx bootmanager.hxx
debugger/callstack.hxx debugger/callstack.hxx
debugger/disassembler.hxx debugger/disassembler.hxx
@ -26,24 +26,30 @@ set (HEADERS
config/controller_config.hxx config/controller_config.hxx
config/controller_config_util.hxx) config/controller_config_util.hxx)
qt4_wrap_ui(UI_HDRS set(UIS
debugger/callstack.ui debugger/callstack.ui
debugger/disassembler.ui debugger/disassembler.ui
debugger/registers.ui debugger/registers.ui
hotkeys.ui hotkeys.ui
main.ui main.ui
config/controller_config.ui) config/controller_config.ui)
# add uic results to include directories if(USE_QT5)
include_directories(${CMAKE_CURRENT_BINARY_DIR}) qt5_wrap_ui(UI_HDRS ${UIS})
else()
qt4_wrap_ui(UI_HDRS ${UIS})
endif()
add_executable(citra-qt ${SRCS} ${UI_HDRS}) add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
if (APPLE) if(APPLE)
set(ICONV_LIBRARY iconv) set(ICONV_LIBRARY iconv)
else() else()
set(RT_LIBRARY rt) set(RT_LIBRARY rt)
endif() endif()
target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${GLEW_LIBRARY})
if(USE_QT5)
target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL)
endif()
#install(TARGETS citra-qt RUNTIME DESTINATION ${bindir}) #install(TARGETS citra-qt RUNTIME DESTINATION ${bindir})