2021-01-12 18:05:25 +01:00
|
|
|
#
|
2021-12-20 15:03:42 +01: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
|
|
|
#
|
2021-12-20 15:03:42 +01:00
|
|
|
# This file is part of the 86Box distribution.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2021-12-20 15:03:42 +01:00
|
|
|
# CMake build script.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2021-12-20 15:03:42 +01:00
|
|
|
# Authors: David Hrdlička, <hrdlickadavid@outlook.com>
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
2023-01-06 15:36:29 -05:00
|
|
|
# Copyright 2020-2021 David Hrdlička.
|
2021-01-12 18:05:25 +01:00
|
|
|
#
|
|
|
|
|
2021-12-02 16:26:33 +06:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-01-30 01:45:04 +01:00
|
|
|
cmake_policy(SET CMP0091 NEW)
|
2021-08-22 18:03:58 +06:00
|
|
|
cmake_policy(SET CMP0079 NEW)
|
|
|
|
|
2022-07-12 23:31:23 +02:00
|
|
|
if(HAIKU)
|
2022-07-13 00:21:54 +02:00
|
|
|
set(OPENAL ON)
|
2022-07-12 23:31:23 +02:00
|
|
|
endif()
|
|
|
|
|
2022-03-08 16:08:24 +01:00
|
|
|
if(NOT DEFINED QT OR QT)
|
2022-02-06 13:30:39 +02:00
|
|
|
list(APPEND VCPKG_MANIFEST_FEATURES "qt-ui")
|
|
|
|
endif()
|
|
|
|
|
2022-07-13 15:56:12 +02:00
|
|
|
if(NOT DEFINED OPENAL OR OPENAL)
|
2022-03-08 16:31:11 +01:00
|
|
|
list(APPEND VCPKG_MANIFEST_FEATURES "openal")
|
|
|
|
endif()
|
|
|
|
|
2022-02-08 01:55:25 +01:00
|
|
|
if(MUNT_EXTERNAL)
|
|
|
|
list(APPEND VCPKG_MANIFEST_FEATURES "munt")
|
|
|
|
endif()
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
project(86Box
|
2023-07-29 17:32:57 +02:00
|
|
|
VERSION 4.1
|
2021-12-20 15:03:42 +01:00
|
|
|
DESCRIPTION "Emulator of x86-based systems"
|
|
|
|
HOMEPAGE_URL "https://86box.net"
|
|
|
|
LANGUAGES C CXX)
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-12-21 18:05:12 +01:00
|
|
|
include(CPack)
|
|
|
|
include(CMakeDependentOption)
|
|
|
|
|
|
|
|
# Basic build options
|
2022-01-10 22:45:52 +01:00
|
|
|
if(VCPKG_TOOLCHAIN)
|
|
|
|
# For vcpkg builds we have to respect the linking method used by the
|
|
|
|
# specified triplet.
|
|
|
|
set(NO_STATIC_OPTION ON)
|
|
|
|
if(VCPKG_TARGET_TRIPLET MATCHES "-static$")
|
|
|
|
# `-static` triplet, use static linking
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
|
|
set(STATIC_BUILD ON)
|
|
|
|
elseif(VCPKG_TARGET_TRIPLET MATCHES "-static-md$")
|
|
|
|
# `-static-md` triplet, use static linking with dynamic CRT
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
|
|
set(STATIC_BUILD ON)
|
|
|
|
elseif()
|
|
|
|
# Regular triplet, use dynamic linking
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
|
|
set(STATIC_BUILD OFF)
|
2021-12-21 18:05:12 +01:00
|
|
|
endif()
|
2022-05-24 23:14:20 +02:00
|
|
|
|
|
|
|
# `vcpkg.json` defaults to Qt6
|
|
|
|
set(USE_QT6 ON)
|
2022-01-10 22:45:52 +01:00
|
|
|
endif()
|
2021-12-21 18:05:12 +01:00
|
|
|
|
2022-01-10 22:45:52 +01:00
|
|
|
if(WIN32)
|
2021-12-21 18:05:12 +01:00
|
|
|
# Prefer static builds on Windows
|
|
|
|
set(PREFER_STATIC ON)
|
|
|
|
|
|
|
|
# Default value for the `WIN32` target property, which specifies whether
|
|
|
|
# to build the application for the Windows GUI or console subsystem
|
|
|
|
option(CMAKE_WIN32_EXECUTABLE "Build a Windows GUI executable" ON)
|
|
|
|
else()
|
|
|
|
# Prefer dynamic builds everywhere else
|
|
|
|
set(PREFER_STATIC OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
option(CMAKE_MACOSX_BUNDLE "Build a macOS bundle (.app)" ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT NO_STATIC_OPTION)
|
|
|
|
if(PREFER_STATIC)
|
|
|
|
option(STATIC_BUILD "Static build" ON)
|
2021-12-20 15:03:42 +01:00
|
|
|
else()
|
2021-12-21 18:05:12 +01:00
|
|
|
option(STATIC_BUILD "Static build" OFF)
|
2021-12-20 15:03:42 +01:00
|
|
|
endif()
|
2021-12-17 07:20:21 +01:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-08-29 03:37:07 +02:00
|
|
|
# Detect the target architecture by trying to compile `src/arch_detect.c`
|
|
|
|
try_compile(RESULT_VAR ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/src/arch_detect.c" OUTPUT_VARIABLE ARCH)
|
|
|
|
string(REGEX MATCH "ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
|
|
|
string(REPLACE "ARCH " "" ARCH "${ARCH}")
|
|
|
|
if (NOT ARCH)
|
2021-12-20 15:03:42 +01:00
|
|
|
set(ARCH unknown)
|
2021-08-29 03:37:07 +02:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
|
|
|
|
add_compile_definitions(CMAKE)
|
2021-09-02 15:33:51 +02:00
|
|
|
add_compile_definitions("$<$<CONFIG:Debug>:DEBUG>")
|
2021-03-21 01:59:46 +01:00
|
|
|
|
|
|
|
if(WIN32)
|
2021-12-20 15:03:42 +01:00
|
|
|
# Disables *_s function warnings
|
|
|
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
2021-03-21 01:59:46 +01:00
|
|
|
|
2021-12-20 15:03:42 +01:00
|
|
|
# Disables POSIX name warnings
|
|
|
|
add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS)
|
2021-03-21 01:59:46 +01:00
|
|
|
|
2021-12-20 15:03:42 +01:00
|
|
|
# Disables WinSock deprecation warnings
|
|
|
|
add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS)
|
2021-03-21 01:59:46 +01:00
|
|
|
endif()
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2023-02-01 19:50:28 +01:00
|
|
|
if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Linux"))
|
|
|
|
set(DISCORD OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-04-13 05:15:20 +05:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2022-07-24 10:01:36 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2022-01-13 04:16:05 +01:00
|
|
|
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
2021-12-03 21:45:22 +01:00
|
|
|
|
2021-12-17 07:22:40 +01:00
|
|
|
# Optional features
|
|
|
|
#
|
|
|
|
# Option Description Def.
|
|
|
|
# ------ ----------- ----
|
|
|
|
option(RELEASE "Release build" OFF)
|
|
|
|
option(DYNAREC "Dynamic recompiler" ON)
|
2022-07-13 00:21:54 +02:00
|
|
|
option(OPENAL "OpenAL" ON)
|
2022-03-11 20:41:00 +01:00
|
|
|
option(RTMIDI "RtMidi" ON)
|
2021-12-17 07:22:40 +01:00
|
|
|
option(FLUIDSYNTH "FluidSynth" ON)
|
|
|
|
option(MUNT "MUNT" ON)
|
2022-04-12 15:55:33 +05:00
|
|
|
option(VNC "VNC renderer" OFF)
|
2021-12-17 07:22:40 +01:00
|
|
|
option(DINPUT "DirectInput" OFF)
|
|
|
|
option(CPPTHREADS "C++11 threads" ON)
|
|
|
|
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
|
|
|
|
option(MINITRACE "Enable Chrome tracing using the modified minitrace library" OFF)
|
2022-03-16 00:33:01 -03:00
|
|
|
option(GDBSTUB "Enable GDB stub server for debugging" OFF)
|
2021-12-17 07:22:40 +01:00
|
|
|
option(DEV_BRANCH "Development branch" OFF)
|
2022-03-17 19:31:45 -03:00
|
|
|
option(QT "Qt GUI" ON)
|
2023-02-01 17:17:56 +01:00
|
|
|
option(DISCORD "Discord Rich Presence support" ON)
|
2021-12-17 07:22:40 +01:00
|
|
|
|
|
|
|
# Development branch features
|
|
|
|
#
|
2022-01-26 19:03:12 -05:00
|
|
|
# Option Description Def. Condition Otherwise
|
|
|
|
# ------ ----------- ---- --------- ---------
|
|
|
|
cmake_dependent_option(AMD_K5 "AMD K5" ON "DEV_BRANCH" OFF)
|
2022-04-12 15:31:44 +05:00
|
|
|
cmake_dependent_option(AN430TX "Intel AN430TX" ON "DEV_BRANCH" OFF)
|
2022-01-26 19:03:12 -05:00
|
|
|
cmake_dependent_option(CYRIX_6X86 "Cyrix 6x86" ON "DEV_BRANCH" OFF)
|
2022-04-12 15:26:16 +05:00
|
|
|
cmake_dependent_option(DESKPRO386 "Compaq Deskpro 386" ON "DEV_BRANCH" OFF)
|
2022-01-26 19:03:12 -05:00
|
|
|
cmake_dependent_option(GUSMAX "Gravis UltraSound MAX" ON "DEV_BRANCH" OFF)
|
2022-02-14 05:11:08 +05:00
|
|
|
cmake_dependent_option(ISAMEM_RAMPAGE "AST Rampage" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(ISAMEM_IAB "Intel Above Board" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(ISAMEM_BRAT "BocaRAM/AT" ON "DEV_BRANCH" OFF)
|
2022-01-26 19:03:12 -05:00
|
|
|
cmake_dependent_option(LASERXT "VTech Laser XT" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(MGA "Matrox Mystique graphics adapters" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(OLIVETTI "Olivetti M290" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(OPEN_AT "OpenAT" ON "DEV_BRANCH" OFF)
|
2022-02-25 21:52:44 -05:00
|
|
|
cmake_dependent_option(PAS16 "Pro Audio Spectrum 16" ON "DEV_BRANCH" OFF)
|
2022-01-26 19:03:12 -05:00
|
|
|
cmake_dependent_option(SIO_DETECT "Super I/O Detection Helper" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(VGAWONDER "ATI VGA Wonder (ATI-18800)" ON "DEV_BRANCH" OFF)
|
|
|
|
cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF)
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-12-31 16:47:49 +06:00
|
|
|
# Ditto but for Qt
|
2022-03-06 19:08:27 +01:00
|
|
|
if(QT)
|
2021-12-31 16:47:49 +06:00
|
|
|
option(USE_QT6 "Use Qt6 instead of Qt5" OFF)
|
2022-08-31 14:59:29 -04:00
|
|
|
if(APPLE)
|
|
|
|
option(MOLTENVK "Use MoltenVK libraries for Vulkan support on macOS. Requires a Vulkan-enabled QT." OFF)
|
|
|
|
endif()
|
2021-12-31 16:47:49 +06:00
|
|
|
endif()
|
|
|
|
|
2021-12-17 07:46:44 +01:00
|
|
|
# Determine the build type
|
2021-12-20 15:03:42 +01:00
|
|
|
set(RELEASE_BUILD OFF)
|
|
|
|
set(BETA_BUILD OFF)
|
|
|
|
set(ALPHA_BUILD OFF)
|
2021-01-12 18:22:40 +01:00
|
|
|
|
2021-11-05 22:02:34 -03:00
|
|
|
string(TOLOWER "${BUILD_TYPE}" BUILD_TYPE_LOWER)
|
|
|
|
if(BUILD_TYPE_LOWER STREQUAL "release")
|
2021-12-20 15:03:42 +01:00
|
|
|
# Release build
|
|
|
|
set(RELEASE_BUILD ON)
|
|
|
|
add_compile_definitions(RELEASE_BUILD)
|
2021-11-05 22:02:34 -03:00
|
|
|
elseif(BUILD_TYPE_LOWER STREQUAL "beta")
|
2021-12-20 15:03:42 +01:00
|
|
|
# Beta build
|
|
|
|
set(BETA_BUILD ON)
|
|
|
|
add_compile_definitions(BETA_BUILD)
|
2021-11-05 22:02:34 -03:00
|
|
|
elseif(BUILD_TYPE_LOWER STREQUAL "alpha")
|
2021-12-20 15:03:42 +01:00
|
|
|
# Alpha build
|
|
|
|
set(ALPHA_BUILD ON)
|
|
|
|
add_compile_definitions(ALPHA_BUILD)
|
2021-11-05 22:02:34 -03:00
|
|
|
endif()
|
|
|
|
|
2022-06-27 15:51:10 -03:00
|
|
|
# Versioning variables
|
2021-12-17 07:46:44 +01:00
|
|
|
if(NOT CMAKE_PROJECT_VERSION_PATCH)
|
2021-12-20 15:03:42 +01:00
|
|
|
set(CMAKE_PROJECT_VERSION_PATCH 0)
|
2021-02-05 01:10:20 +01:00
|
|
|
endif()
|
2021-12-17 07:46:44 +01:00
|
|
|
if(NOT EMU_BUILD_NUM)
|
2021-12-20 15:03:42 +01:00
|
|
|
set(EMU_BUILD_NUM 0)
|
2021-12-17 07:46:44 +01:00
|
|
|
endif()
|
|
|
|
if(NOT EMU_COPYRIGHT_YEAR)
|
2023-11-04 02:50:13 -04:00
|
|
|
set(EMU_COPYRIGHT_YEAR 2023)
|
2021-09-18 18:39:36 +02:00
|
|
|
endif()
|
|
|
|
|
2021-01-12 18:22:40 +01:00
|
|
|
add_subdirectory(src)
|