mirror of https://github.com/mgba-emu/mgba.git
Qt: Merge in more preparatory Qt6 scaffolding
This commit is contained in:
parent
14e1552a3b
commit
8a60cd8c47
|
@ -23,14 +23,17 @@ endif()
|
|||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(QT_LIBRARIES)
|
||||
|
||||
find_package(Qt5 COMPONENTS Core Widgets Network Multimedia)
|
||||
set(QT Qt5)
|
||||
|
||||
if(NOT BUILD_GL AND NOT BUILD_GLES2 AND NOT BUILD_GLES3)
|
||||
message(WARNING "OpenGL is recommended to build the Qt port")
|
||||
endif()
|
||||
|
||||
set(FOUND_QT ${Qt5Widgets_FOUND} PARENT_SCOPE)
|
||||
if(NOT Qt5Widgets_FOUND)
|
||||
set(FOUND_QT ${${QT}Widgets_FOUND} PARENT_SCOPE)
|
||||
if(NOT ${QT}Widgets_FOUND)
|
||||
message(WARNING "Cannot find Qt modules")
|
||||
return()
|
||||
endif()
|
||||
|
@ -41,7 +44,9 @@ if(APPLE)
|
|||
list(APPEND QT_DEFINES USE_SHARE_WIDGET)
|
||||
endif()
|
||||
|
||||
if(Qt5Widgets_VERSION MATCHES "^5.15")
|
||||
if(Qt6Widgets_VERSION)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.14")
|
||||
elseif(Qt5Widgets_VERSION MATCHES "^5.15")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.13")
|
||||
elseif(Qt5Widgets_VERSION MATCHES "^5.1[234]")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.12")
|
||||
|
@ -63,7 +68,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
endif()
|
||||
|
||||
get_target_property(QT_TYPE Qt5::Core TYPE)
|
||||
get_target_property(QT_TYPE ${QT}::Core TYPE)
|
||||
if(QT_TYPE STREQUAL STATIC_LIBRARY)
|
||||
set(QT_STATIC ON)
|
||||
list(APPEND QT_DEFINES QT_STATIC)
|
||||
|
@ -181,7 +186,6 @@ set(GB_SRC
|
|||
GBOverride.cpp
|
||||
PrinterView.cpp)
|
||||
|
||||
set(QT_LIBRARIES)
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5")
|
||||
|
||||
set(AUDIO_SRC)
|
||||
|
@ -197,17 +201,17 @@ if(M_CORE_GB)
|
|||
list(APPEND PLATFORM_SRC ${GB_SRC})
|
||||
endif()
|
||||
|
||||
if(Qt5Multimedia_FOUND)
|
||||
if(${QT}Multimedia_FOUND)
|
||||
list(APPEND AUDIO_SRC
|
||||
AudioProcessorQt.cpp
|
||||
AudioDevice.cpp)
|
||||
list(APPEND SOURCE_FILES
|
||||
VideoDumper.cpp)
|
||||
if (WIN32 AND QT_STATIC)
|
||||
list(APPEND QT_LIBRARIES Qt5::QWindowsAudioPlugin Qt5::DSServicePlugin Qt5::QWindowsVistaStylePlugin
|
||||
list(APPEND QT_LIBRARIES ${QT}::QWindowsAudioPlugin ${QT}::DSServicePlugin ${QT}::QWindowsVistaStylePlugin
|
||||
strmiids mfuuid mfplat mf ksguid dxva2 evr d3d9)
|
||||
endif()
|
||||
list(APPEND QT_LIBRARIES Qt5::Multimedia)
|
||||
list(APPEND QT_LIBRARIES ${QT}::Multimedia)
|
||||
list(APPEND QT_DEFINES BUILD_QT_MULTIMEDIA)
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
|
||||
endif()
|
||||
|
@ -242,10 +246,18 @@ if(USE_DISCORD_RPC)
|
|||
list(APPEND SOURCE_FILES DiscordCoordinator.cpp)
|
||||
endif()
|
||||
|
||||
qt5_add_resources(RESOURCES resources.qrc)
|
||||
if(TARGET Qt6::Core)
|
||||
qt_add_resources(RESOURCES resources.qrc)
|
||||
else()
|
||||
qt5_add_resources(RESOURCES resources.qrc)
|
||||
endif()
|
||||
if(BUILD_UPDATER)
|
||||
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/updater.qrc INPUT ${CMAKE_CURRENT_SOURCE_DIR}/updater.qrc.in)
|
||||
qt5_add_resources(UPDATER_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/updater.qrc)
|
||||
if(TARGET Qt6::Core)
|
||||
qt_add_resources(UPDATER_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/updater.qrc)
|
||||
else()
|
||||
qt5_add_resources(UPDATER_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/updater.qrc)
|
||||
endif()
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/updater.qrc PROPERTIES GENERATED ON)
|
||||
list(APPEND RESOURCES ${UPDATER_RESOURCES})
|
||||
endif()
|
||||
|
@ -287,21 +299,29 @@ if(NOT WIN32 AND NOT APPLE)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
find_package(Qt5LinguistTools)
|
||||
if(Qt5LinguistTools_FOUND)
|
||||
find_package(${QT}LinguistTools)
|
||||
if(${QT}LinguistTools_FOUND)
|
||||
set(TRANSLATION_FILES)
|
||||
set(TRANSLATION_QRC "${CMAKE_CURRENT_BINARY_DIR}/ts.qrc")
|
||||
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-*.ts")
|
||||
if(UPDATE_TRANSLATIONS)
|
||||
qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete)
|
||||
if(TARGET Qt6::Core)
|
||||
qt_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete)
|
||||
else()
|
||||
qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete)
|
||||
endif()
|
||||
list(REMOVE_ITEM TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-template.ts")
|
||||
else()
|
||||
list(REMOVE_ITEM TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-template.ts")
|
||||
qt5_add_translation(TRANSLATION_FILES ${TS_FILES})
|
||||
if(TARGET Qt6::Core)
|
||||
qt_add_translation(TRANSLATION_FILES ${TS_FILES})
|
||||
else()
|
||||
qt5_add_translation(TRANSLATION_FILES ${TS_FILES})
|
||||
endif()
|
||||
endif()
|
||||
set(QT_QM_FILES)
|
||||
if(QT_STATIC)
|
||||
get_target_property(QT_CORE_LOCATION Qt5::Core LOCATION)
|
||||
get_target_property(QT_CORE_LOCATION ${QT}::Core LOCATION)
|
||||
get_filename_component(QT_CORE_LOCATION ${QT_CORE_LOCATION} DIRECTORY)
|
||||
get_filename_component(QT_QM_LOCATION "${QT_CORE_LOCATION}/../translations" ABSOLUTE)
|
||||
foreach(TS ${TS_FILES})
|
||||
|
@ -317,11 +337,19 @@ if(Qt5LinguistTools_FOUND)
|
|||
add_custom_command(OUTPUT ${TRANSLATION_QRC}
|
||||
COMMAND ${CMAKE_COMMAND} -DTRANSLATION_QRC:FILEPATH="${TRANSLATION_QRC}" -DQM_BASE="${CMAKE_CURRENT_BINARY_DIR}" "-DTRANSLATION_FILES='${TRANSLATION_FILES}'" -P "${CMAKE_CURRENT_SOURCE_DIR}/ts.cmake"
|
||||
DEPENDS ${TRANSLATION_FILES})
|
||||
qt5_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC})
|
||||
if(TARGET Qt6::Core)
|
||||
qt_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC})
|
||||
else()
|
||||
qt5_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC})
|
||||
endif()
|
||||
list(APPEND RESOURCES ${TRANSLATION_RESOURCES})
|
||||
endif()
|
||||
|
||||
qt5_wrap_ui(UI_SRC ${UI_FILES})
|
||||
if(TARGET Qt6::Core)
|
||||
qt_wrap_ui(UI_SRC ${UI_FILES})
|
||||
else()
|
||||
qt5_wrap_ui(UI_SRC ${UI_FILES})
|
||||
endif()
|
||||
|
||||
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_SRC} ${AUDIO_SRC} ${RESOURCES})
|
||||
set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES};${OS_DEFINES};${QT_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}")
|
||||
|
@ -333,7 +361,7 @@ if(WIN32)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::Network)
|
||||
list(APPEND QT_LIBRARIES ${QT}::Widgets ${QT}::Network)
|
||||
if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY)
|
||||
list(APPEND QT_LIBRARIES ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
|
||||
endif()
|
||||
|
@ -341,20 +369,20 @@ if(QT_STATIC)
|
|||
find_library(QTPCRE NAMES qtpcre2 qtpcre)
|
||||
if(WIN32)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(QWINDOWS_DEPS Qt5EventDispatcherSupport Qt5FontDatabaseSupport Qt5ThemeSupport Qt5WindowsUIAutomationSupport)
|
||||
set(QWINDOWS_DEPS ${QT}EventDispatcherSupport ${QT}FontDatabaseSupport ${QT}ThemeSupport ${QT}WindowsUIAutomationSupport)
|
||||
endif()
|
||||
list(APPEND QT_LIBRARIES Qt5::QWindowsIntegrationPlugin ${QWINDOWS_DEPS} amstrmid dwmapi uxtheme imm32 -static-libgcc -static-libstdc++)
|
||||
set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE};version;winmm;ssl;crypto;ws2_32;iphlpapi;crypt32;userenv;netapi32;wtsapi32")
|
||||
set_target_properties(Qt5::Gui PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
|
||||
list(APPEND QT_LIBRARIES ${QT}::QWindowsIntegrationPlugin ${QWINDOWS_DEPS} amstrmid dwmapi uxtheme imm32 -static-libgcc -static-libstdc++)
|
||||
set_target_properties(${QT}::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE};version;winmm;ssl;crypto;ws2_32;iphlpapi;crypt32;userenv;netapi32;wtsapi32")
|
||||
set_target_properties(${QT}::Gui PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
|
||||
elseif(APPLE)
|
||||
find_package(Cups)
|
||||
find_package(Qt5PrintSupport)
|
||||
list(APPEND QT_LIBRARIES Cups Qt5::PrintSupport Qt5::QCocoaIntegrationPlugin Qt5::CoreAudioPlugin Qt5::AVFServicePlugin Qt5::QCocoaPrinterSupportPlugin)
|
||||
list(APPEND QT_LIBRARIES Qt5AccessibilitySupport Qt5CglSupport Qt5ClipboardSupport Qt5FontDatabaseSupport Qt5GraphicsSupport Qt5ThemeSupport)
|
||||
find_package(${QT}PrintSupport)
|
||||
list(APPEND QT_LIBRARIES Cups ${QT}::PrintSupport ${QT}::QCocoaIntegrationPlugin ${QT}::CoreAudioPlugin ${QT}::AVFServicePlugin ${QT}::QCocoaPrinterSupportPlugin)
|
||||
list(APPEND QT_LIBRARIES ${QT}AccessibilitySupport ${QT}CglSupport ${QT}ClipboardSupport ${QT}FontDatabaseSupport ${QT}GraphicsSupport ${QT}ThemeSupport)
|
||||
list(APPEND QT_LIBRARIES "-framework AVFoundation" "-framework CoreMedia" "-framework SystemConfiguration" "-framework Security")
|
||||
set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE}")
|
||||
set_target_properties(${QT}::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE}")
|
||||
elseif(UNIX)
|
||||
list(APPEND QT_LIBRARIES Qt5::FontDatabaseSupport Qt5::XcbQpa)
|
||||
list(APPEND QT_LIBRARIES ${QT}::FontDatabaseSupport ${QT}::XcbQpa)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
|
||||
|
@ -374,9 +402,9 @@ if(APPLE OR WIN32)
|
|||
endif()
|
||||
if(APPLE)
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
get_target_property(QTCOCOA Qt5::QCocoaIntegrationPlugin LOCATION)
|
||||
get_target_property(COREAUDIO Qt5::CoreAudioPlugin LOCATION)
|
||||
get_target_property(QTAVFSERVICE Qt5::AVFServicePlugin LOCATION)
|
||||
get_target_property(QTCOCOA ${QT}::QCocoaIntegrationPlugin LOCATION)
|
||||
get_target_property(COREAUDIO ${QT}::CoreAudioPlugin LOCATION)
|
||||
get_target_property(QTAVFSERVICE ${QT}::AVFServicePlugin LOCATION)
|
||||
set(BUNDLE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.app)
|
||||
target_sources(${BINARY_NAME}-qt PRIVATE "${PLUGINS}")
|
||||
set_source_files_properties("${QTCOCOA}" PROPERTIES MACOSX_PACKAGE_LOCATION Contents/PlugIns)
|
||||
|
|
|
@ -1027,7 +1027,7 @@ void Window::reloadDisplayDriver() {
|
|||
m_display->stopDrawing();
|
||||
detachWidget(m_display.get());
|
||||
}
|
||||
m_display = std::unique_ptr<Display>(Display::create(this));
|
||||
m_display = std::unique_ptr<QGBA::Display>(Display::create(this));
|
||||
if (!m_display) {
|
||||
LOG(QT, ERROR) << tr("Failed to create an appropriate display device, falling back to software display. "
|
||||
"Games may run slowly, especially with larger windows.");
|
||||
|
@ -1039,12 +1039,12 @@ void Window::reloadDisplayDriver() {
|
|||
m_shaderView = std::make_unique<ShaderSelector>(m_display.get(), m_config);
|
||||
#endif
|
||||
|
||||
connect(m_display.get(), &Display::hideCursor, [this]() {
|
||||
connect(m_display.get(), &QGBA::Display::hideCursor, [this]() {
|
||||
if (static_cast<QStackedLayout*>(m_screenWidget->layout())->currentWidget() == m_display.get()) {
|
||||
m_screenWidget->setCursor(Qt::BlankCursor);
|
||||
}
|
||||
});
|
||||
connect(m_display.get(), &Display::showCursor, [this]() {
|
||||
connect(m_display.get(), &QGBA::Display::showCursor, [this]() {
|
||||
m_screenWidget->unsetCursor();
|
||||
});
|
||||
|
||||
|
@ -2119,7 +2119,7 @@ void Window::setController(CoreController* controller, const QString& fname) {
|
|||
|
||||
void Window::attachDisplay() {
|
||||
m_display->attach(m_controller);
|
||||
connect(m_display.get(), &Display::drawingStarted, this, &Window::changeRenderer);
|
||||
connect(m_display.get(), &QGBA::Display::drawingStarted, this, &Window::changeRenderer);
|
||||
m_display->startDrawing(m_controller);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue