Merge branch 'master' of https://github.com/86Box/86Box into qt

This commit is contained in:
ts-korhonen
2021-12-20 22:30:50 +02:00
44 changed files with 751 additions and 584 deletions

View File

@@ -1,136 +1,80 @@
#
# 86Box A hypervisor and IBM PC system emulator that specializes in
# running old operating systems and software designed for IBM
# PC systems and compatibles from 1981 through fairly recent
# system designs based on the PCI bus.
# 86Box A hypervisor and IBM PC system emulator that specializes in
# running old operating systems and software designed for IBM
# PC systems and compatibles from 1981 through fairly recent
# system designs based on the PCI bus.
#
# This file is part of the 86Box distribution.
# This file is part of the 86Box distribution.
#
# CMake build script.
# CMake build script.
#
# Authors: David Hrdlička, <hrdlickadavid@outlook.com>
# dob205
# Authors: David Hrdlička, <hrdlickadavid@outlook.com>
# dob205
#
# Copyright 2020,2021 David Hrdlička.
# Copyright 2021 dob205.
# Copyright 2020,2021 David Hrdlička.
# Copyright 2021 dob205.
#
# Prepare the macOS app bundle icon depending on the release channel
set(APP_ICON_MACOSX)
if (APPLE)
if(RELEASE_BUILD)
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/release/86Box.icns)
elseif(BETA_BUILD)
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/beta/86Box.icns)
elseif(ALPHA_BUILD)
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/dev/86Box.icns)
else()
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/branch/86Box.icns)
endif()
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
endif()
# WIN32 marks us as a GUI app on Windows
# MACOSX_BUNDLE prepares a macOS application bundle including with the app icon
add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c fifo8.c
device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX})
dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c fifo8.c
device.c nvr.c nvr_at.c nvr_ps2.c)
if(CPPTHREADS)
target_sources(86Box PRIVATE thread.cpp)
endif()
if(APPLE)
target_link_libraries(86Box "-framework AppKit")
target_sources(86Box PRIVATE thread.cpp)
endif()
if(NEW_DYNAREC)
add_compile_definitions(USE_NEW_DYNAREC)
add_compile_definitions(USE_NEW_DYNAREC)
endif()
if(RELEASE)
add_compile_definitions(RELEASE_BUILD)
add_compile_definitions(RELEASE_BUILD)
endif()
if(DYNAREC)
add_compile_definitions(USE_DYNAREC)
add_compile_definitions(USE_DYNAREC)
endif()
if(VRAMDUMP)
add_compile_definitions(ENABLE_VRAM_DUMP)
add_compile_definitions(ENABLE_VRAM_DUMP)
endif()
if(DEV_BRANCH)
add_compile_definitions(DEV_BRANCH)
add_compile_definitions(DEV_BRANCH)
endif()
if(VNC)
add_compile_definitions(USE_VNC)
add_library(vnc OBJECT vnc.c vnc_keymap.c)
target_link_libraries(86Box vnc vncserver)
if (WIN32)
target_link_libraries(86Box ws2_32)
endif()
add_compile_definitions(USE_VNC)
add_library(vnc OBJECT vnc.c vnc_keymap.c)
target_link_libraries(86Box vnc vncserver)
if (WIN32)
target_link_libraries(86Box ws2_32)
endif()
endif()
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd
net print scsi sio snd vid voodoo plat ui)
net print scsi sio snd vid voodoo plat ui)
if(WIN32 AND ARCH STREQUAL "i386")
if(MSVC)
target_link_options(86Box PRIVATE "/LARGEADDRESSAWARE")
else()
target_link_options(86Box PRIVATE "LINKER:--large-address-aware")
endif()
if(MINGW)
target_link_options(86Box PRIVATE "LINKER:--large-address-aware")
else()
target_link_options(86Box PRIVATE "LINKER:/LARGEADDRESSAWARE")
endif()
endif()
if(MINGW)
target_link_options(86Box PRIVATE "-static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".dll.a")
target_link_options(86Box PRIVATE "-static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".dll.a")
endif()
# Variables introduced by richardg867 for versioning stuff
if(NOT CMAKE_PROJECT_VERSION_PATCH)
set(CMAKE_PROJECT_VERSION_PATCH 0)
endif()
if(NOT EMU_BUILD_NUM)
set(EMU_BUILD_NUM 0)
endif()
if(NOT EMU_COPYRIGHT_YEAR)
set(EMU_COPYRIGHT_YEAR 2021)
endif()
#some macOS specific configuration steps
if(APPLE)
# Force using the newest library if it's installed by homebrew
set(CMAKE_FIND_FRAMEWORK LAST)
# Force using the newest library if it's installed by homebrew
set(CMAKE_FIND_FRAMEWORK LAST)
# prepare stuff for macOS app bundles
set(CMAKE_MACOSX_BUNDLE 1)
# setting our compilation target to macOS 10.13 High Sierra
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
# set the Info.plist properly
set_target_properties(86Box PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist.in)
set(MACOSX_BUNDLE_GUI_IDENTIFIER net.86Box.86Box)
set(MACOSX_BUNDLE_BUNDLE_NAME 86Box)
set(MACOSX_BUNDLE_BUNDLE_VERSION 3.1.${EMU_BUILD_NUM})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "3.1.${EMU_BUILD_NUM}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "3.1.${EMU_BUILD_NUM}")
set(MACOSX_BUNDLE_ICON_FILE 86Box.icns)
set(MACOSX_BUNDLE_INFO_STRING "A emulator of old computers")
set(MACOSX_BUNDLE_COPYRIGHT "© 2007-${EMU_COPYRIGHT_YEAR} 86Box contributors")
# preparing the code signing for easier distribution, Apple dev certificate needed at one point
#set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES")
#set(XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-")
#set(XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/mac/codesign/dev/app.entitlements)
# setting our compilation target to macOS 10.13 High Sierra
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
endif()
if(QT)
@@ -149,7 +93,9 @@ endif()
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
if(APPLE)
target_link_libraries(86Box Freetype::Freetype) # bundles freetype for the macOS app bundle
# Freetype is dynamically loaded by the emulator, however, we link it
# on macOS so it gets copied to the bundle by the installation process
target_link_libraries(86Box Freetype::Freetype)
endif()
find_package(OpenAL REQUIRED)
@@ -158,16 +104,12 @@ target_link_libraries(86Box ${OPENAL_LIBRARY})
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
if(MINGW)
target_link_libraries(86Box SDL2::SDL2-static)
elseif(WIN32)
target_link_libraries(86Box SDL2::SDL2)
if(WIN32 AND TARGET SDL2::SDL2-static)
target_link_libraries(86Box SDL2::SDL2-static)
elseif(TARGET SDL2::SDL2)
target_link_libraries(86Box SDL2::SDL2)
else()
if (TARGET SDL2::SDL2)
target_link_libraries(86Box SDL2::SDL2)
else()
target_link_libraries(86Box ${SDL2_LIBRARIES})
endif()
target_link_libraries(86Box ${SDL2_LIBRARIES})
endif()
find_package(PNG REQUIRED)
@@ -175,17 +117,17 @@ include_directories(${PNG_INCLUDE_DIRS})
target_link_libraries(86Box PNG::PNG)
if(VCPKG_TOOLCHAIN)
# vcpkg includes a config file for rtmidi
find_package(RtMidi REQUIRED)
target_link_libraries(86Box RtMidi::rtmidi)
# vcpkg includes a config file for rtmidi
find_package(RtMidi REQUIRED)
target_link_libraries(86Box RtMidi::rtmidi)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(RTMIDI REQUIRED IMPORTED_TARGET rtmidi)
target_link_libraries(86Box PkgConfig::RTMIDI)
find_package(PkgConfig REQUIRED)
pkg_check_modules(RTMIDI REQUIRED IMPORTED_TARGET rtmidi)
target_link_libraries(86Box PkgConfig::RTMIDI)
if(WIN32)
target_link_libraries(PkgConfig::RTMIDI INTERFACE winmm)
endif()
if(WIN32)
target_link_libraries(PkgConfig::RTMIDI INTERFACE winmm)
endif()
endif()
configure_file(include/86box/version.h.in include/86box/version.h @ONLY)
@@ -193,9 +135,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(include)
if(NEW_DYNAREC)
include_directories(cpu codegen_new)
include_directories(cpu codegen_new)
else()
include_directories(cpu codegen)
include_directories(cpu codegen)
endif()
add_subdirectory(cdrom)
@@ -203,9 +145,9 @@ add_subdirectory(chipset)
add_subdirectory(cpu)
if(NEW_DYNAREC)
add_subdirectory(codegen_new)
add_subdirectory(codegen_new)
else()
add_subdirectory(codegen)
add_subdirectory(codegen)
endif()
if(MINITRACE)
@@ -214,22 +156,24 @@ if(MINITRACE)
target_link_libraries(86Box minitrace)
endif()
if(APPLE)
install(TARGETS 86Box DESTINATION "bin")
if(WIN32 OR APPLE)
# Copy the binary to the root of the install prefix on Windows and macOS
install(TARGETS 86Box DESTINATION ".")
else()
install(TARGETS 86Box)
# On Linux we want to copy the binary to the `bin` folder.
install(TARGETS 86Box)
endif()
# adjustments for macOS app bundles
# Install our dependencies to the macOS bundle
if(APPLE)
set(APPS ${CMAKE_CURRENT_BINARY_DIR}/86Box.app)
install(CODE "
include(InstallRequiredSystemLibraries)
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"\")"
COMPONENT Runtime)
install(CODE "
include(BundleUtilities)
get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \${CMAKE_INSTALL_PREFIX} ABSOLUTE)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"\" \"\")"
COMPONENT Runtime)
# needed for Qt packaging
if (QT)
# needed for Qt packaging
# get the macdeployqt path
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
@@ -242,16 +186,29 @@ if(APPLE)
-always-overwrite
COMMENT "Running macdeployqt..."
)
endif()
endif()
# Install our dependencies if using vcpkg
if(VCPKG_TOOLCHAIN)
x_vcpkg_install_local_dependencies(TARGETS 86Box DESTINATION "bin")
x_vcpkg_install_local_dependencies(TARGETS 86Box DESTINATION ".")
endif()
# Install the PDB file on Windows builds
if(MSVC)
install(FILES $<TARGET_PDB_FILE:86Box>
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION "bin")
# CMake fully supports PDB files on MSVC-compatible compilers
install(FILES $<TARGET_PDB_FILE:86Box>
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION ".")
elseif(WIN32)
# Other compilers/linkers (such as Clang in GCC-compatible mode) also
# emit PDB files when targeting Windows, however, CMake only supports
# the relevant properties with MSVC and clones. Try to install
# the PDB file assuming it's in the same path as the EXE.
install(FILES "$<TARGET_FILE_DIR:86Box>/$<TARGET_FILE_BASE_NAME:86Box>.pdb"
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION "."
OPTIONAL)
endif()
add_subdirectory(device)
@@ -273,7 +230,7 @@ endif()
if (QT)
add_subdirectory(qt)
elseif(WIN32)
add_subdirectory(win)
add_subdirectory(win)
else()
add_subdirectory(unix)
add_subdirectory(unix)
endif()