2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-11-13 16:37:58 -05:00
|
|
|
# 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.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-11-13 16:37:58 -05:00
|
|
|
# This file is part of the 86Box distribution.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-11-13 16:37:58 -05:00
|
|
|
# CMake build script.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-11-13 16:37:58 -05:00
|
|
|
# Authors: David Hrdlička, <hrdlickadavid@outlook.com>
|
|
|
|
|
# dob205
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-11-13 16:37:58 -05:00
|
|
|
# Copyright 2020-2022 David Hrdlička.
|
|
|
|
|
# Copyright 2021 dob205.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2022-08-31 14:59:29 -04:00
|
|
|
if(APPLE)
|
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
endif()
|
2021-01-12 18:05:25 +01:00
|
|
|
|
2022-02-14 13:04:05 +01:00
|
|
|
add_executable(86Box 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
|
2023-02-01 17:17:56 +01:00
|
|
|
dma.c ddma.c nmi.c pic.c pit.c pit_fast.c port_6x.c port_92.c ppi.c pci.c
|
2023-08-18 05:57:32 +02:00
|
|
|
mca.c usb.c fifo.c fifo8.c device.c nvr.c nvr_at.c nvr_ps2.c
|
|
|
|
|
machine_status.c ini.c)
|
2021-12-03 20:12:44 +01:00
|
|
|
|
2022-04-07 02:17:14 +06:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
|
add_compile_definitions(_FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE=1 _LARGEFILE64_SOURCE=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-17 06:59:53 +01:00
|
|
|
if(CPPTHREADS)
|
2021-12-20 15:03:42 +01:00
|
|
|
target_sources(86Box PRIVATE thread.cpp)
|
2021-11-19 20:42:03 +06:00
|
|
|
endif()
|
|
|
|
|
|
2022-03-12 20:20:25 -03:00
|
|
|
if(GDBSTUB)
|
|
|
|
|
add_compile_definitions(USE_GDBSTUB)
|
|
|
|
|
target_sources(86Box PRIVATE gdbstub.c)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
if(NEW_DYNAREC)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_compile_definitions(USE_NEW_DYNAREC)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(RELEASE)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_compile_definitions(RELEASE_BUILD)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(DYNAREC)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_compile_definitions(USE_DYNAREC)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(DEV_BRANCH)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_compile_definitions(DEV_BRANCH)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
2023-02-01 17:17:56 +01:00
|
|
|
if(DISCORD)
|
|
|
|
|
add_compile_definitions(DISCORD)
|
|
|
|
|
target_sources(86Box PRIVATE discord.c)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
if(VNC)
|
2022-12-29 21:59:21 -05:00
|
|
|
find_package(LibVNCServer)
|
|
|
|
|
if(LibVNCServer_FOUND)
|
|
|
|
|
add_compile_definitions(USE_VNC)
|
|
|
|
|
add_library(vnc OBJECT vnc.c vnc_keymap.c)
|
|
|
|
|
target_link_libraries(86Box vnc LibVNCServer::vncserver)
|
|
|
|
|
if(WIN32)
|
|
|
|
|
target_link_libraries(86Box ws2_32)
|
|
|
|
|
endif()
|
2021-12-20 15:03:42 +01:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
2022-08-06 14:23:11 +02:00
|
|
|
if(INSTRUMENT)
|
|
|
|
|
add_compile_definitions(USE_INSTRUMENT)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd
|
2021-12-20 15:03:42 +01:00
|
|
|
net print scsi sio snd vid voodoo plat ui)
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-09-02 15:33:51 +02:00
|
|
|
if(WIN32 AND ARCH STREQUAL "i386")
|
2021-12-20 15:03:42 +01:00
|
|
|
if(MINGW)
|
|
|
|
|
target_link_options(86Box PRIVATE "LINKER:--large-address-aware")
|
|
|
|
|
else()
|
|
|
|
|
target_link_options(86Box PRIVATE "LINKER:/LARGEADDRESSAWARE")
|
|
|
|
|
endif()
|
2021-09-02 15:33:51 +02:00
|
|
|
endif()
|
|
|
|
|
|
2021-12-21 18:05:12 +01:00
|
|
|
if(STATIC_BUILD)
|
|
|
|
|
if(MINGW OR UNIX)
|
|
|
|
|
target_link_options(86Box PRIVATE "-static")
|
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
|
|
|
|
endif()
|
2021-11-19 17:40:28 +01:00
|
|
|
endif()
|
|
|
|
|
|
2021-10-07 10:00:11 +02:00
|
|
|
if(APPLE)
|
2021-12-20 15:03:42 +01:00
|
|
|
# Force using the newest library if it's installed by homebrew
|
|
|
|
|
set(CMAKE_FIND_FRAMEWORK LAST)
|
2021-11-10 10:01:37 +01:00
|
|
|
|
2022-08-31 14:59:29 -04:00
|
|
|
# setting our compilation target to macOS 10.15 Catalina if targeting Qt6,
|
|
|
|
|
# macOS 10.14 Mojave for vulkan support, 10.13 High Sierra otherwise
|
2021-12-31 16:47:49 +06:00
|
|
|
if (USE_QT6)
|
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
|
|
|
|
|
else()
|
2022-08-31 14:59:29 -04:00
|
|
|
if(MOLTENVK)
|
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
|
|
|
|
endif()
|
2021-12-31 16:47:49 +06:00
|
|
|
endif()
|
2021-10-07 10:00:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
find_package(Freetype REQUIRED)
|
|
|
|
|
include_directories(${FREETYPE_INCLUDE_DIRS})
|
2023-06-13 00:59:48 +06:00
|
|
|
if(FREETYPE_INCLUDE_DIR_ft2build)
|
|
|
|
|
include_directories(${FREETYPE_INCLUDE_DIR_ft2build})
|
|
|
|
|
endif()
|
2021-11-10 10:01:37 +01:00
|
|
|
if(APPLE)
|
2021-12-20 15:03:42 +01:00
|
|
|
# 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)
|
2021-11-10 10:01:37 +01:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-09-02 15:33:51 +02:00
|
|
|
find_package(SDL2 REQUIRED)
|
2021-01-12 18:22:40 +01:00
|
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
2021-12-21 18:05:12 +01:00
|
|
|
if(STATIC_BUILD AND TARGET SDL2::SDL2-static)
|
2021-12-20 15:03:42 +01:00
|
|
|
target_link_libraries(86Box SDL2::SDL2-static)
|
2021-12-17 07:47:24 +01:00
|
|
|
elseif(TARGET SDL2::SDL2)
|
2021-12-20 15:03:42 +01:00
|
|
|
target_link_libraries(86Box SDL2::SDL2)
|
2021-09-18 01:15:39 +06:00
|
|
|
else()
|
2021-12-20 15:03:42 +01:00
|
|
|
target_link_libraries(86Box ${SDL2_LIBRARIES})
|
2021-09-02 15:33:51 +02:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
|
|
|
|
|
find_package(PNG REQUIRED)
|
|
|
|
|
include_directories(${PNG_INCLUDE_DIRS})
|
|
|
|
|
target_link_libraries(86Box PNG::PNG)
|
|
|
|
|
|
|
|
|
|
configure_file(include/86box/version.h.in include/86box/version.h @ONLY)
|
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
|
|
|
|
|
|
|
|
include_directories(include)
|
|
|
|
|
if(NEW_DYNAREC)
|
2021-12-20 15:03:42 +01:00
|
|
|
include_directories(cpu codegen_new)
|
2021-01-12 18:22:40 +01:00
|
|
|
else()
|
2021-12-20 15:03:42 +01:00
|
|
|
include_directories(cpu codegen)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
add_subdirectory(cdrom)
|
|
|
|
|
add_subdirectory(chipset)
|
|
|
|
|
|
|
|
|
|
add_subdirectory(cpu)
|
|
|
|
|
if(NEW_DYNAREC)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_subdirectory(codegen_new)
|
2021-01-12 18:22:40 +01:00
|
|
|
else()
|
2021-12-20 15:03:42 +01:00
|
|
|
add_subdirectory(codegen)
|
2021-01-12 18:22:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
2021-02-10 20:22:51 +00:00
|
|
|
if(MINITRACE)
|
|
|
|
|
add_compile_definitions(MTR_ENABLED)
|
|
|
|
|
add_library(minitrace OBJECT minitrace/minitrace.c)
|
|
|
|
|
target_link_libraries(86Box minitrace)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-21 18:05:12 +01:00
|
|
|
if(WIN32 OR (APPLE AND CMAKE_MACOSX_BUNDLE))
|
2021-12-20 15:03:42 +01:00
|
|
|
# Copy the binary to the root of the install prefix on Windows and macOS
|
|
|
|
|
install(TARGETS 86Box DESTINATION ".")
|
2021-11-10 10:40:51 +01:00
|
|
|
else()
|
2021-12-20 15:03:42 +01:00
|
|
|
# On Linux we want to copy the binary to the `bin` folder.
|
|
|
|
|
install(TARGETS 86Box)
|
2021-11-10 10:40:51 +01:00
|
|
|
endif()
|
2021-11-10 10:01:37 +01:00
|
|
|
|
2022-02-03 22:30:42 +02:00
|
|
|
|
2021-12-17 07:47:24 +01:00
|
|
|
# Install our dependencies if using vcpkg
|
2021-01-31 17:13:14 +01:00
|
|
|
if(VCPKG_TOOLCHAIN)
|
2021-12-20 15:03:42 +01:00
|
|
|
x_vcpkg_install_local_dependencies(TARGETS 86Box DESTINATION ".")
|
2021-01-31 17:13:14 +01:00
|
|
|
endif()
|
|
|
|
|
|
2022-01-13 04:17:30 +01:00
|
|
|
|
|
|
|
|
# Install other dependencies
|
2022-02-07 23:05:59 +01:00
|
|
|
if(WIN32)
|
2022-01-13 04:17:30 +01:00
|
|
|
install(CODE "
|
|
|
|
|
include(BundleUtilities)
|
|
|
|
|
get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \${CMAKE_INSTALL_PREFIX} ABSOLUTE)
|
|
|
|
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/$<TARGET_FILE_NAME:86Box>\" \"\" \"\")"
|
|
|
|
|
COMPONENT Runtime)
|
2022-02-07 23:05:59 +01:00
|
|
|
elseif(APPLE AND NOT QT)
|
|
|
|
|
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)
|
2022-01-13 04:17:30 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
2021-12-19 14:50:24 +01:00
|
|
|
# Install the PDB file on Windows builds
|
2021-02-14 00:41:55 +01:00
|
|
|
if(MSVC)
|
2021-12-20 15:03:42 +01:00
|
|
|
# CMake fully supports PDB files on MSVC-compatible compilers
|
|
|
|
|
install(FILES $<TARGET_PDB_FILE:86Box>
|
|
|
|
|
CONFIGURATIONS Debug RelWithDebInfo
|
|
|
|
|
DESTINATION ".")
|
2021-12-19 14:50:24 +01:00
|
|
|
elseif(WIN32)
|
2021-12-20 15:03:42 +01:00
|
|
|
# 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)
|
2021-02-14 00:41:55 +01:00
|
|
|
endif()
|
|
|
|
|
|
2022-03-11 12:03:54 +06:00
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
add_subdirectory(device)
|
|
|
|
|
add_subdirectory(disk)
|
|
|
|
|
add_subdirectory(floppy)
|
|
|
|
|
add_subdirectory(game)
|
|
|
|
|
add_subdirectory(machine)
|
|
|
|
|
add_subdirectory(mem)
|
|
|
|
|
add_subdirectory(network)
|
|
|
|
|
add_subdirectory(printer)
|
|
|
|
|
add_subdirectory(sio)
|
|
|
|
|
add_subdirectory(scsi)
|
|
|
|
|
add_subdirectory(sound)
|
|
|
|
|
add_subdirectory(video)
|
2021-11-28 20:50:02 +01:00
|
|
|
if (APPLE)
|
2022-02-20 19:11:58 -05:00
|
|
|
add_subdirectory(mac)
|
2021-11-28 20:50:02 +01:00
|
|
|
endif()
|
2021-11-25 10:20:56 +01:00
|
|
|
|
|
|
|
|
if (QT)
|
2022-01-08 15:36:52 +02:00
|
|
|
add_subdirectory(qt)
|
2021-11-19 16:42:43 +01:00
|
|
|
elseif(WIN32)
|
2021-12-20 15:03:42 +01:00
|
|
|
add_subdirectory(win)
|
2021-08-22 16:32:52 +06:00
|
|
|
else()
|
2021-12-20 15:03:42 +01:00
|
|
|
add_subdirectory(unix)
|
2021-11-28 20:54:32 +01:00
|
|
|
endif()
|