-
-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
138 lines (119 loc) · 6.23 KB
/
CMakeLists.txt
File metadata and controls
138 lines (119 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
cmake_minimum_required(VERSION 3.16)
project(amiberry
VERSION 8.1.4
LANGUAGES C CXX
DESCRIPTION "Optimized Amiga emulator for various platforms"
HOMEPAGE_URL "https://amiberry.com"
)
# Prevent in-tree builds
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR "In-tree builds are not supported. Use a separate build directory.")
endif()
# Set CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# Feature options
option(USE_PCEM "Use PCem for hardware emulation (no support for RISC-V)" ON)
option(USE_LIBSERIALPORT "Use LibSerialPort for serial port emulation" ON)
option(USE_LIBENET "Use LibENET for network emulation" ON)
option(USE_PORTMIDI "Use PortMidi for MIDI emulation" ON)
option(USE_LIBMPEG2 "Use LibMPEG2 for CD32 FMV support" ON)
option(USE_UAENET_PCAP "Use libpcap for uaenet (Linux/macOS)" ON)
option(USE_UAENET_TAP "Use TAP backend for uaenet (Linux only)" ON)
option(USE_ZSTD "Use Zstandard for CHD compressed disk images" ON)
option(USE_GPIOD "Use GPIOD to control GPIO LEDs" OFF)
option(USE_DBUS "Use DBus to control the emulator" OFF)
option(USE_OPENGL "Use OpenGL for rendering" ON)
option(USE_GLES "Use OpenGL ES instead of desktop OpenGL (for embedded Linux without GLX)" OFF)
option(USE_VULKAN "Use Vulkan for rendering (experimental, mutually exclusive with USE_OPENGL)" OFF)
option(USE_IPC_SOCKET "Use Unix socket for IPC control (cross-platform)" ON)
option(WITH_LTO "Enable Link Time Optimization" OFF)
option(WITH_OPTIMIZE "Enable GCC native CPU optimizations" OFF)
option(BUNDLE_SDL "Bundle SDL3 shared libraries into the package (for distros without SDL3)" OFF)
# Vulkan and OpenGL are mutually exclusive rendering backends
if(USE_VULKAN AND USE_OPENGL)
message(FATAL_ERROR "USE_VULKAN and USE_OPENGL are mutually exclusive. Please enable only one.")
endif()
# Automatically disable PCem on architectures without a PCem backend
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch")
if(USE_PCEM)
message(STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} architecture. Disabling USE_PCEM (no backend available).")
else()
message(STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} architecture. USE_PCEM already disabled.")
endif()
set(USE_PCEM OFF CACHE BOOL "Use PCem for hardware emulation (no backend for this architecture)" FORCE)
endif()
if(ANDROID)
set(USE_UAENET_PCAP OFF CACHE BOOL "Use libpcap for uaenet (Linux/macOS)" FORCE)
set(USE_UAENET_TAP OFF CACHE BOOL "TAP backend not supported on Android" FORCE)
set(USE_DBUS OFF CACHE BOOL "Use DBus to control the emulator" FORCE)
set(USE_IPC_SOCKET OFF CACHE BOOL "Use Unix socket for IPC control" FORCE)
set(USE_GPIOD OFF CACHE BOOL "Use GPIOD to control GPIO LEDs" FORCE)
# Enabled features for Android
set(USE_LIBMPEG2 OFF CACHE BOOL "Use LibMPEG2 for CD32 FMV support" FORCE)
set(USE_MPG123 OFF CACHE BOOL "Disable mpg123 on Android" FORCE)
# Android 15+ (API 35) requires 16KB page size alignment for Play Store
add_link_options("-Wl,-z,max-page-size=16384")
endif()
if(WIN32)
set(USE_GPIOD OFF CACHE BOOL "GPIO not available on Windows" FORCE)
set(USE_DBUS OFF CACHE BOOL "DBus not available on Windows" FORCE)
set(USE_IPC_SOCKET OFF CACHE BOOL "Unix sockets not available on Windows" FORCE)
set(USE_UAENET_PCAP OFF CACHE BOOL "Disable pcap on Windows initially" FORCE)
set(USE_LIBMPEG2 OFF CACHE BOOL "LibMPEG2 not available in vcpkg" FORCE)
set(USE_LIBSERIALPORT OFF CACHE BOOL "LibSerialPort not available in vcpkg for MinGW" FORCE)
set(USE_PORTMIDI OFF CACHE BOOL "PortMidi not available in vcpkg for MinGW" FORCE)
endif()
# TAP backend is Linux-only (not macOS, FreeBSD, Windows, or Android)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(USE_UAENET_TAP OFF CACHE BOOL "TAP backend only available on Linux" FORCE)
endif()
# Mac App Store: enforce sandbox-compatible feature set
if(MACOS_APP_STORE)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(FATAL_ERROR "MACOS_APP_STORE can only be used on macOS builds")
endif()
enable_language(OBJCXX)
add_compile_definitions(MACOS_APP_STORE)
set(USE_LIBSERIALPORT OFF CACHE BOOL "Serial port not available in App Store sandbox" FORCE)
set(USE_IPC_SOCKET OFF CACHE BOOL "IPC socket not available in App Store sandbox" FORCE)
message(STATUS "Mac App Store build enabled: sandbox entitlements, serial/IPC disabled")
endif()
# Pre-release version suffix (project version is set in project() above)
set(VERSION_PRE_RELEASE "" CACHE STRING "Pre-release version")
# Project identity
set(AMIBERRY_DISPLAY_NAME "Amiberry")
set(PROJECT_COMPANY_NAME "BlitterStudio")
set(PROJECT_COMPANY_NAMESPACE "com.blitterstudio")
# FreeBSD-specific paths and libraries
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
list(APPEND AMIBERRY_PLATFORM_LINK_DIRS /usr/local/lib)
find_library(LIBUSB_LIBRARY NAMES usb PATHS /usr/lib REQUIRED)
if(NOT LIBUSB_LIBRARY)
message(FATAL_ERROR "libusb not found in /usr/lib")
endif()
endif()
# Install system and packaging
include(GNUInstallDirs)
include(cmake/StandardProjectSettings.cmake)
include(cmake/SourceFiles.cmake)
include(cmake/Dependencies.cmake)
include(packaging/CMakeLists.txt)
# Link libraries (FreeBSD needs correct order)
if(TARGET amiberry AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
target_link_options(amiberry PRIVATE -L/usr/local/lib)
# Apply FreeBSD pkg-config include/link dirs
if(FREEBSD_INCLUDE_DIRS)
target_include_directories(amiberry PRIVATE ${FREEBSD_INCLUDE_DIRS})
endif()
if(FREEBSD_LIBRARIES)
target_link_libraries(amiberry PRIVATE ${FREEBSD_LIBRARIES})
endif()
# forkpty() lives in libutil on FreeBSD
target_link_libraries(amiberry PRIVATE util)
# libiconv_* symbols come from ports/converters/libiconv
find_library(LIBICONV_LIBRARY NAMES iconv PATHS /usr/local/lib REQUIRED)
target_link_libraries(amiberry PRIVATE ${LIBICONV_LIBRARY})
# existing libs
target_link_libraries(amiberry PRIVATE ${LIBUSB_LIBRARY} serialport ${EXTRA_LIBS})
endif()