2021-11-25 10:20:56 +01:00
|
|
|
# Find includes in corresponding build directories
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
|
set(CMAKE_AUTORCC ON)
|
2022-02-07 20:25:31 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
|
|
if (USE_QT6)
|
|
|
|
|
set(QT_MAJOR 6)
|
|
|
|
|
else()
|
|
|
|
|
set(QT_MAJOR 5)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(QT_STATIC ${STATIC_BUILD})
|
|
|
|
|
|
|
|
|
|
if(QT_STATIC AND MINGW)
|
2022-02-07 20:37:10 +01:00
|
|
|
set(CMAKE_PREFIX_PATH "$ENV{MSYSTEM_PREFIX}/qt${QT_MAJOR}-static")
|
2022-02-07 20:25:31 +01:00
|
|
|
endif()
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2021-11-28 20:54:32 +01:00
|
|
|
find_package(Threads REQUIRED)
|
2022-02-07 20:25:31 +01:00
|
|
|
find_package(Qt${QT_MAJOR} COMPONENTS Core Widgets OpenGL REQUIRED)
|
|
|
|
|
find_package(Qt${QT_MAJOR}LinguistTools REQUIRED)
|
2021-11-28 20:54:32 +01:00
|
|
|
|
2021-12-13 22:45:37 +01:00
|
|
|
add_library(plat STATIC
|
|
|
|
|
qt.c
|
|
|
|
|
qt_main.cpp
|
|
|
|
|
qt_platform.cpp
|
|
|
|
|
)
|
2021-12-17 21:33:11 +02:00
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
add_library(ui STATIC
|
|
|
|
|
qt_ui.cpp
|
|
|
|
|
qt_cdrom.c
|
|
|
|
|
|
|
|
|
|
qt_mainwindow.cpp
|
|
|
|
|
qt_mainwindow.hpp
|
|
|
|
|
qt_mainwindow.ui
|
2021-11-28 20:49:05 +01:00
|
|
|
qt_machinestatus.cpp
|
|
|
|
|
qt_machinestatus.hpp
|
2021-12-03 11:38:00 +01:00
|
|
|
qt_mediamenu.cpp
|
|
|
|
|
qt_mediamenu.hpp
|
2021-12-04 21:33:04 +01:00
|
|
|
qt_rendererstack.cpp
|
|
|
|
|
qt_rendererstack.hpp
|
|
|
|
|
qt_rendererstack.ui
|
2022-01-30 22:13:41 +02:00
|
|
|
qt_renderercommon.cpp
|
|
|
|
|
qt_renderercommon.hpp
|
2021-12-04 21:33:04 +01:00
|
|
|
qt_softwarerenderer.cpp
|
|
|
|
|
qt_softwarerenderer.hpp
|
|
|
|
|
qt_hardwarerenderer.cpp
|
|
|
|
|
qt_hardwarerenderer.hpp
|
2021-11-30 16:26:49 +06:00
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
qt_settings.cpp
|
|
|
|
|
qt_settings.hpp
|
|
|
|
|
qt_settings.ui
|
|
|
|
|
|
|
|
|
|
qt_settingsmachine.cpp
|
|
|
|
|
qt_settingsmachine.hpp
|
|
|
|
|
qt_settingsmachine.ui
|
|
|
|
|
qt_settingsdisplay.cpp
|
|
|
|
|
qt_settingsdisplay.hpp
|
|
|
|
|
qt_settingsdisplay.ui
|
|
|
|
|
qt_settingsinput.cpp
|
|
|
|
|
qt_settingsinput.hpp
|
|
|
|
|
qt_settingsinput.ui
|
|
|
|
|
qt_settingssound.cpp
|
|
|
|
|
qt_settingssound.hpp
|
|
|
|
|
qt_settingssound.ui
|
|
|
|
|
qt_settingsnetwork.cpp
|
|
|
|
|
qt_settingsnetwork.hpp
|
|
|
|
|
qt_settingsnetwork.ui
|
|
|
|
|
qt_settingsports.cpp
|
|
|
|
|
qt_settingsports.hpp
|
|
|
|
|
qt_settingsports.ui
|
|
|
|
|
qt_settingsstoragecontrollers.cpp
|
|
|
|
|
qt_settingsstoragecontrollers.hpp
|
|
|
|
|
qt_settingsstoragecontrollers.ui
|
|
|
|
|
qt_settingsharddisks.cpp
|
|
|
|
|
qt_settingsharddisks.hpp
|
|
|
|
|
qt_settingsharddisks.ui
|
|
|
|
|
qt_settingsfloppycdrom.cpp
|
|
|
|
|
qt_settingsfloppycdrom.hpp
|
|
|
|
|
qt_settingsfloppycdrom.ui
|
|
|
|
|
qt_settingsotherremovable.cpp
|
|
|
|
|
qt_settingsotherremovable.hpp
|
|
|
|
|
qt_settingsotherremovable.ui
|
|
|
|
|
qt_settingsotherperipherals.cpp
|
|
|
|
|
qt_settingsotherperipherals.hpp
|
|
|
|
|
qt_settingsotherperipherals.ui
|
2022-01-09 16:41:03 +06:00
|
|
|
qt_settings_bus_tracking.cpp
|
|
|
|
|
qt_settings_bus_tracking.hpp
|
2021-11-25 10:20:56 +01:00
|
|
|
|
|
|
|
|
qt_deviceconfig.cpp
|
|
|
|
|
qt_deviceconfig.hpp
|
|
|
|
|
qt_deviceconfig.ui
|
2021-12-13 22:45:37 +01:00
|
|
|
qt_joystickconfiguration.cpp
|
|
|
|
|
qt_joystickconfiguration.hpp
|
|
|
|
|
qt_joystickconfiguration.ui
|
2021-11-25 10:20:56 +01:00
|
|
|
|
|
|
|
|
qt_filefield.cpp
|
|
|
|
|
qt_filefield.hpp
|
|
|
|
|
qt_filefield.ui
|
2021-12-03 11:38:00 +01:00
|
|
|
qt_newfloppydialog.cpp
|
|
|
|
|
qt_newfloppydialog.hpp
|
|
|
|
|
qt_newfloppydialog.ui
|
2021-11-25 10:20:56 +01:00
|
|
|
qt_harddiskdialog.cpp
|
|
|
|
|
qt_harddiskdialog.hpp
|
|
|
|
|
qt_harddiskdialog.ui
|
|
|
|
|
|
|
|
|
|
qt_harddrive_common.cpp
|
|
|
|
|
qt_harddrive_common.hpp
|
|
|
|
|
qt_models_common.cpp
|
|
|
|
|
qt_models_common.hpp
|
|
|
|
|
|
2021-12-12 01:16:27 +06:00
|
|
|
qt_specifydimensions.h
|
|
|
|
|
qt_specifydimensions.cpp
|
|
|
|
|
qt_specifydimensions.ui
|
2021-12-12 16:22:35 +06:00
|
|
|
qt_soundgain.hpp
|
|
|
|
|
qt_soundgain.cpp
|
|
|
|
|
qt_soundgain.ui
|
2021-12-12 01:16:27 +06:00
|
|
|
|
2021-12-12 18:19:44 +02:00
|
|
|
qt_styleoverride.cpp
|
|
|
|
|
qt_styleoverride.hpp
|
2021-12-28 16:47:10 +06:00
|
|
|
qt_progsettings.hpp
|
|
|
|
|
qt_progsettings.cpp
|
|
|
|
|
qt_progsettings.ui
|
2022-01-23 22:48:36 +02:00
|
|
|
qt_util.hpp
|
|
|
|
|
qt_util.cpp
|
2021-12-12 18:19:44 +02:00
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
../qt_resources.qrc
|
|
|
|
|
)
|
2021-12-17 21:33:11 +02:00
|
|
|
|
2022-02-04 17:07:44 +05:00
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
enable_language(RC)
|
|
|
|
|
target_sources(86Box PUBLIC ../win/86Box-qt.rc)
|
2022-02-05 13:28:18 +06:00
|
|
|
target_sources(plat PRIVATE win_joystick_rawinput.c)
|
|
|
|
|
target_link_libraries(86Box hid)
|
2022-02-04 17:07:44 +05:00
|
|
|
|
|
|
|
|
# CMake 3.22 messed this up for clang/clang++
|
|
|
|
|
# See https://gitlab.kitware.com/cmake/cmake/-/issues/22611
|
|
|
|
|
if(MSVC OR (NOT MINGW AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22))
|
|
|
|
|
# MSVC linker adds its own manifest to the executable, which fails if
|
|
|
|
|
# we include ours in 86Box.rc. We therefore need to pass the manifest
|
|
|
|
|
# directly as as a source file, so the linker can use that instead.
|
|
|
|
|
set_property(SOURCE ../win/86Box-qt.rc PROPERTY COMPILE_DEFINITIONS NO_INCLUDE_MANIFEST)
|
|
|
|
|
target_sources(86Box PRIVATE ../win/86Box.manifest)
|
|
|
|
|
endif()
|
2022-02-12 19:27:27 +02:00
|
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
|
add_compile_definitions(NTDDI_VERSION=0x06010000)
|
|
|
|
|
endif()
|
2022-02-05 13:28:18 +06:00
|
|
|
else()
|
|
|
|
|
target_sources(plat PRIVATE sdl_joystick.cpp)
|
2022-02-04 17:07:44 +05:00
|
|
|
endif()
|
|
|
|
|
|
2021-12-20 21:54:25 +02:00
|
|
|
if(WIN32 AND NOT MINGW)
|
2021-12-19 23:49:47 +02:00
|
|
|
target_sources(plat PRIVATE ../win/win_opendir.c)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-11-30 20:18:13 +01:00
|
|
|
if (APPLE)
|
|
|
|
|
target_sources(ui PRIVATE macos_event_filter.mm)
|
|
|
|
|
endif()
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2021-12-09 20:59:50 +02:00
|
|
|
if (WIN32)
|
2022-01-22 01:10:11 +02:00
|
|
|
target_sources(ui PRIVATE
|
|
|
|
|
qt_winrawinputfilter.hpp
|
|
|
|
|
qt_winrawinputfilter.cpp
|
|
|
|
|
qt_winmanagerfilter.hpp
|
|
|
|
|
qt_winmanagerfilter.cpp
|
|
|
|
|
)
|
2021-12-09 20:59:50 +02:00
|
|
|
endif()
|
|
|
|
|
|
2021-11-25 10:20:56 +01:00
|
|
|
target_link_libraries(
|
|
|
|
|
plat
|
|
|
|
|
PRIVATE
|
2021-12-31 16:47:49 +06:00
|
|
|
Qt${QT_MAJOR}::Widgets
|
|
|
|
|
Qt${QT_MAJOR}::Gui
|
2021-11-28 20:54:32 +01:00
|
|
|
Threads::Threads
|
2021-11-25 10:20:56 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
|
ui
|
|
|
|
|
PRIVATE
|
2021-12-31 16:47:49 +06:00
|
|
|
Qt${QT_MAJOR}::Widgets
|
|
|
|
|
Qt${QT_MAJOR}::Gui
|
|
|
|
|
Qt${QT_MAJOR}::OpenGL
|
2021-11-28 20:54:32 +01:00
|
|
|
Threads::Threads
|
2021-11-25 10:20:56 +01:00
|
|
|
)
|
2021-11-30 16:26:49 +06:00
|
|
|
|
2021-12-06 17:31:25 +02:00
|
|
|
# needed for static builds
|
|
|
|
|
if (WIN32)
|
2021-12-31 16:47:49 +06:00
|
|
|
qt_import_plugins(plat INCLUDE Qt${QT_MAJOR}::QWindowsIntegrationPlugin Qt${QT_MAJOR}::QICOPlugin QWindowsVistaStylePlugin)
|
2021-12-06 17:31:25 +02:00
|
|
|
endif()
|
|
|
|
|
|
2022-02-07 21:08:28 +01:00
|
|
|
# loads a macro to install Qt5 plugins on macOS
|
|
|
|
|
# based on https://stackoverflow.com/questions/35612687/cmake-macos-x-bundle-with-bundleutiliies-for-qt-application
|
|
|
|
|
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix)
|
|
|
|
|
get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
|
|
|
|
|
if(EXISTS "${_qt_plugin_path}")
|
|
|
|
|
get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
|
|
|
|
|
get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
|
|
|
|
|
get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
|
|
|
|
|
set(_qt_plugin_dest "${_prefix}/PlugIns/${_qt_plugin_type}")
|
|
|
|
|
install(FILES "${_qt_plugin_path}"
|
|
|
|
|
DESTINATION "${_qt_plugin_dest}")
|
2022-02-14 09:51:13 +01:00
|
|
|
list(APPEND ${_qt_plugins_var} "${_qt_plugin_dest}/${_qt_plugin_file}")
|
2022-02-07 21:08:28 +01:00
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
if (APPLE AND CMAKE_MACOSX_BUNDLE)
|
2022-02-07 23:05:59 +01:00
|
|
|
set(prefix "86Box.app/Contents")
|
2022-02-07 21:08:28 +01:00
|
|
|
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
|
|
|
|
|
set(INSTALL_CMAKE_DIR "${prefix}/Resources")
|
|
|
|
|
|
|
|
|
|
# using the install_qt5_plugin to add Qt plugins into the macOS app bundle
|
|
|
|
|
if (USE_QT6)
|
|
|
|
|
install_qt5_plugin("Qt6::QCocoaIntegrationPlugin" QT_PLUGINS ${prefix})
|
|
|
|
|
else()
|
|
|
|
|
install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS ${prefix})
|
|
|
|
|
install_qt5_plugin("Qt5::QMacStylePlugin" QT_PLUGINS ${prefix})
|
|
|
|
|
install_qt5_plugin("Qt5::QICOPlugin" QT_PLUGINS ${prefix})
|
|
|
|
|
install_qt5_plugin("Qt5::QICNSPlugin" QT_PLUGINS ${prefix})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
|
|
|
|
|
"[Paths]\nPlugins = ${_qt_plugin_dir}\n")
|
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
|
|
|
|
|
DESTINATION "${INSTALL_CMAKE_DIR}")
|
|
|
|
|
|
|
|
|
|
# Path used for searching by FIND_XXX(), with appropriate suffixes added
|
|
|
|
|
if(CMAKE_PREFIX_PATH)
|
|
|
|
|
foreach(dir ${CMAKE_PREFIX_PATH})
|
|
|
|
|
list(APPEND DIRS "${dir}/bin" "${dir}/lib")
|
|
|
|
|
endforeach()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Append Qt's lib folder which is two levels above Qt5Widgets_DIR
|
|
|
|
|
list(APPEND DIRS "${Qt5Widgets_DIR}/../..")
|
|
|
|
|
|
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
|
|
2022-02-14 09:16:14 +01:00
|
|
|
install(CODE "
|
2022-02-07 21:08:28 +01:00
|
|
|
include(BundleUtilities)
|
2022-02-14 08:33:03 +01:00
|
|
|
get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX} ABSOLUTE)
|
2022-02-14 09:16:14 +01:00
|
|
|
foreach(PLUGIN ${QT_PLUGINS})
|
|
|
|
|
get_filename_component(PLUGIN_ABSOLUTE \${PLUGIN} ABSOLUTE BASE_DIR \${CMAKE_INSTALL_PREFIX_ABSOLUTE})
|
|
|
|
|
list(APPEND QT_PLUGINS_ABSOLUTE \${PLUGIN_ABSOLUTE})
|
|
|
|
|
endforeach()
|
|
|
|
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"${QT_PLUGINS_ABSOLUTE}\" \"${DIRS}\")")
|
2022-02-07 21:08:28 +01:00
|
|
|
endif()
|
|
|
|
|
|
2021-11-30 20:18:13 +01:00
|
|
|
if (UNIX AND NOT APPLE)
|
2021-11-30 16:26:49 +06:00
|
|
|
find_package(X11 REQUIRED)
|
2022-02-15 02:34:13 +06:00
|
|
|
target_link_libraries(ui PRIVATE X11::X11 X11::Xi)
|
|
|
|
|
target_sources(ui PRIVATE xinput2_mouse.cpp)
|
2021-12-10 01:03:20 +06:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
pkg_check_modules(LIBEVDEV IMPORTED_TARGET libevdev)
|
|
|
|
|
if (LIBEVDEV_FOUND)
|
|
|
|
|
target_compile_definitions(ui PRIVATE EVDEV_INPUT)
|
|
|
|
|
target_link_libraries(ui PUBLIC PkgConfig::LIBEVDEV)
|
|
|
|
|
target_sources(ui PRIVATE evdev_mouse.cpp)
|
|
|
|
|
endif()
|
2021-12-03 16:42:31 +06:00
|
|
|
|
2021-12-02 16:26:33 +06:00
|
|
|
find_package(ECM NO_MODULE)
|
|
|
|
|
if (ECM_FOUND)
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
|
|
|
|
find_package(Wayland COMPONENTS Client)
|
|
|
|
|
if (Wayland_FOUND)
|
|
|
|
|
target_link_libraries(ui PRIVATE Wayland::Client)
|
|
|
|
|
find_package(WaylandScanner REQUIRED)
|
|
|
|
|
if (WaylandScanner_FOUND)
|
|
|
|
|
set(WL_SOURCE_VAR)
|
|
|
|
|
ecm_add_wayland_client_protocol(WL_SOURCE_VAR PROTOCOL ${CMAKE_SOURCE_DIR}/wl_protocols/relative-pointer-unstable-v1.xml BASENAME relative-pointer-unstable-v1)
|
|
|
|
|
ecm_add_wayland_client_protocol(WL_SOURCE_VAR PROTOCOL ${CMAKE_SOURCE_DIR}/wl_protocols/pointer-constraints-unstable-v1.xml BASENAME pointer-constraints-unstable-v1)
|
2021-12-31 16:47:49 +06:00
|
|
|
target_include_directories(ui PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${Qt${QT_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
|
2021-12-02 16:26:33 +06:00
|
|
|
target_sources(ui PRIVATE ${WL_SOURCE_VAR} wl_mouse.cpp)
|
|
|
|
|
target_compile_definitions(ui PRIVATE WAYLAND)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2021-11-30 20:18:13 +01:00
|
|
|
endif()
|
2022-01-04 01:24:10 +06:00
|
|
|
set(QM_FILES)
|
|
|
|
|
file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/languages/*.po")
|
|
|
|
|
foreach(po_file ${po_files})
|
|
|
|
|
get_target_property(LCONVERT_EXECUTABLE Qt${QT_MAJOR}::lconvert IMPORTED_LOCATION)
|
2022-01-06 16:58:11 +06:00
|
|
|
get_filename_component(_lconvert_bin_dir "${LCONVERT_EXECUTABLE}" DIRECTORY)
|
|
|
|
|
find_program(LCONVERT_EXECUTABLE lconvert HINTS "${_lconvert_bin_dir}")
|
2022-01-04 01:24:10 +06:00
|
|
|
|
|
|
|
|
get_filename_component(PO_FILE_NAME ${po_file} NAME_WE)
|
|
|
|
|
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/86box_${PO_FILE_NAME}.qm"
|
2022-01-06 16:58:11 +06:00
|
|
|
COMMAND ${LCONVERT_EXECUTABLE} -i ${po_file} -o ${CMAKE_CURRENT_BINARY_DIR}/86box_${PO_FILE_NAME}.qm
|
2022-01-05 01:33:15 +06:00
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
|
DEPENDS "${po_file}")
|
2022-01-04 01:24:10 +06:00
|
|
|
list(APPEND QM_FILES "${CMAKE_CURRENT_BINARY_DIR}/86box_${PO_FILE_NAME}.qm")
|
2022-01-05 01:17:07 +06:00
|
|
|
list(APPEND QM_FILES "${po_file}")
|
2022-01-04 01:24:10 +06:00
|
|
|
endforeach()
|
2021-12-31 12:36:55 +06:00
|
|
|
configure_file(qt_translations.qrc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
|
|
|
|
|
target_sources(ui PRIVATE ${QM_FILES} ${CMAKE_CURRENT_BINARY_DIR}/qt_translations.qrc)
|