|
1 | 1 | cmake_minimum_required(VERSION 3.16) |
2 | 2 |
|
3 | | -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 3 | +project(amiberry-lite |
| 4 | + VERSION 5.9.0 |
| 5 | + LANGUAGES C CXX ASM |
| 6 | + DESCRIPTION "Optimized Amiga emulator for various platforms" |
| 7 | + HOMEPAGE_URL "https://amiberry.com" |
| 8 | +) |
| 9 | + |
| 10 | +# Prevent in-tree builds |
4 | 11 | if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) |
5 | | - message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the amiberry source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there") |
6 | | -endif () |
7 | | - |
8 | | -# Use libgpiod to control GPIO LEDs? |
9 | | -option(USE_GPIOD "Use GPIOD" OFF) |
10 | | -# Use DBUS to control the emulator? |
11 | | -option(USE_DBUS "Use DBus" OFF) |
12 | | -# Use OpenGL for rendering? NOTE: Not yet implemented |
13 | | -option(USE_OPENGL "Use OpenGL (currently BROKEN)" OFF) |
14 | | -# Enable Link Time Optimization? |
15 | | -option(WITH_LTO "Enable Link Time Optimization" OFF) |
16 | | - |
17 | | -# Use LibSerialPort for serial port emulation? |
18 | | -option(USE_LIBSERIALPORT "Use LibSerialPort" ON) |
19 | | -# Use LibENET for network emulation? |
20 | | -option(USE_LIBENET "Use LibENET" ON) |
21 | | -# Use PortMidi for MIDI emulation? |
22 | | -option(USE_PORTMIDI "Use PortMidi" ON) |
23 | | -# Use LibMPEG2 for MPEG2 decoding (CD32 FMV)? |
24 | | -option(USE_LIBMPEG2 "Use LibMPEG2" ON) |
| 12 | + message(FATAL_ERROR "In-tree builds are not supported. Use a separate build directory.") |
| 13 | +endif() |
| 14 | + |
| 15 | +# Set CMake module path |
| 16 | +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 17 | + |
| 18 | +# Feature options |
| 19 | +option(USE_PCEM "Use PCem for hardware emulation (no support for RISC-V)" OFF) |
| 20 | +option(USE_LIBSERIALPORT "Use LibSerialPort for serial port emulation" ON) |
| 21 | +option(USE_LIBENET "Use LibENET for network emulation" ON) |
| 22 | +option(USE_PORTMIDI "Use PortMidi for MIDI emulation" ON) |
| 23 | +option(USE_LIBMPEG2 "Use LibMPEG2 for CD32 FMV support" ON) |
| 24 | +option(USE_UAENET_PCAP "Use libpcap for uaenet (Linux/macOS)" OFF) |
25 | 25 | option(USE_ZSTD "Use Zstandard for CHD compressed disk images" ON) |
| 26 | +option(USE_GPIOD "Use GPIOD to control GPIO LEDs" OFF) |
| 27 | +option(USE_DBUS "Use DBus to control the emulator" OFF) |
| 28 | +option(USE_OPENGL "Use OpenGL for rendering (currently BROKEN)" OFF) |
| 29 | +option(WITH_LTO "Enable Link Time Optimization" OFF) |
26 | 30 |
|
27 | | -## Determine proper semantic version |
28 | | -set(VERSION_MAJOR "5") |
29 | | -set(VERSION_MINOR "8") |
30 | | -set(VERSION_PATCH "11") |
31 | | -set(VERSION_PRE_RELEASE "") |
| 31 | +# Automatically disable PCem on RISC-V targets |
| 32 | +if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv") |
| 33 | + if(USE_PCEM) |
| 34 | + message(STATUS "Detected RISC-V architecture (${CMAKE_SYSTEM_PROCESSOR}). Disabling USE_PCEM.") |
| 35 | + else() |
| 36 | + message(STATUS "Detected RISC-V architecture (${CMAKE_SYSTEM_PROCESSOR}). USE_PCEM already disabled.") |
| 37 | + endif() |
| 38 | + set(USE_PCEM OFF CACHE BOOL "Use PCem for hardware emulation (no support for RISC-V)" FORCE) |
| 39 | +endif() |
32 | 40 |
|
| 41 | +# Versioning |
| 42 | +set(VERSION_MAJOR "5" CACHE STRING "Major version") |
| 43 | +set(VERSION_MINOR "9" CACHE STRING "Minor version") |
| 44 | +set(VERSION_PATCH "0" CACHE STRING "Patch version") |
| 45 | +set(VERSION_PRE_RELEASE "" CACHE STRING "Pre-release version") |
33 | 46 | set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") |
34 | 47 |
|
35 | | -project(amiberry-lite |
36 | | - VERSION ${VERSION} |
37 | | - LANGUAGES C CXX ASM |
38 | | - DESCRIPTION "Optimized Amiga emulator for various platforms" |
39 | | - HOMEPAGE_URL "https://amiberry.com" |
40 | | -) |
41 | | -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 48 | +# Use PkgConfig only on FreeBSD |
| 49 | +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") |
| 50 | + # Required packages via pkg-config |
| 51 | + find_package(PkgConfig REQUIRED) |
| 52 | + pkg_check_modules(SDL2 REQUIRED sdl2) |
| 53 | + pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) |
| 54 | + pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) |
| 55 | + pkg_check_modules(FLAC REQUIRED flac) |
| 56 | + pkg_check_modules(PNG REQUIRED libpng) |
| 57 | + |
| 58 | + include_directories( |
| 59 | + ${SDL2_INCLUDE_DIRS} |
| 60 | + ${SDL2_TTF_INCLUDE_DIRS} |
| 61 | + ${SDL2_IMAGE_INCLUDE_DIRS} |
| 62 | + ${FLAC_INCLUDE_DIRS} |
| 63 | + ${PNG_INCLUDE_DIRS} |
| 64 | + ) |
| 65 | + |
| 66 | + link_libraries( |
| 67 | + ${SDL2_LIBRARIES} |
| 68 | + ${SDL2_TTF_LIBRARIES} |
| 69 | + ${SDL2_IMAGE_LIBRARIES} |
| 70 | + ${FLAC_LIBRARIES} |
| 71 | + ${PNG_LIBRARIES} |
| 72 | + ) |
| 73 | +endif() |
| 74 | + |
| 75 | +# macOS-specific identifier (optional cosmetic) |
| 76 | +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
42 | 77 | set(PROJECT_NAME "Amiberry-Lite") |
43 | 78 | set(CMAKE_PROJECT_NAME "Amiberry-Lite") |
44 | | -endif () |
| 79 | +endif() |
| 80 | + |
| 81 | +# Project identity |
45 | 82 | set(PROJECT_COMPANY_NAME "BlitterStudio") |
46 | | -set(PROJECT_COMPANY_NAMESPACE "com.blitterstudio") # Reverse domain name notation |
| 83 | +set(PROJECT_COMPANY_NAMESPACE "com.blitterstudio") |
47 | 84 |
|
48 | | -include(GNUInstallDirs) |
| 85 | +# Global definitions |
| 86 | +add_definitions(-DLIBICONV_PLUG) |
| 87 | + |
| 88 | +# FreeBSD-specific linking and paths |
| 89 | +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") |
| 90 | + link_directories(/usr/local/lib) |
49 | 91 |
|
| 92 | + find_library(LIBUSB_LIBRARY NAMES usb PATHS /usr/lib REQUIRED) |
| 93 | + if(NOT LIBUSB_LIBRARY) |
| 94 | + message(FATAL_ERROR "libusb not found in /usr/lib") |
| 95 | + endif() |
| 96 | +endif() |
| 97 | + |
| 98 | +# Install system and packaging |
| 99 | +include(GNUInstallDirs) |
50 | 100 | include(cmake/StandardProjectSettings.cmake) |
51 | 101 | include(cmake/SourceFiles.cmake) |
52 | 102 | include(cmake/Dependencies.cmake) |
53 | | - |
54 | 103 | add_subdirectory(packaging) |
| 104 | + |
| 105 | +# Link libraries (FreeBSD needs correct order) |
| 106 | +if(TARGET amiberry AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") |
| 107 | + target_link_libraries(amiberry PRIVATE ${LIBUSB_LIBRARY} serialport ${EXTRA_LIBS}) |
| 108 | +endif() |
0 commit comments