Skip to content

Commit

Permalink
Fix flatpak (#1466)
Browse files Browse the repository at this point in the history
* refactor: fix flatpak builds
- added FindHelper.cmake
- Bumped Flatpak runtime to 24.08
- Version changes

* fixed find helper for libserialport

* use variables for find_helper libs

* fixed libmpeg2 vs libmpeg2convert

* refactor: desktop and metainfo.xml files
- Merged files between flatpak and normal Linux packages

* Update com.blitterstudio.amiberry.yml

* Update Amiberry.desktop
  • Loading branch information
midwan authored Oct 10, 2024
1 parent 8714e0e commit 940c046
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 56 deletions.
26 changes: 17 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
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")
endif ()

set(VERSION 6.3.5)
## Determine proper semantic version
set(VERSION_MAJOR "7")
set(VERSION_MINOR "0")
set(VERSION_PATCH "0")

set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(PROJECT_NAME "Amiberry")
Expand Down Expand Up @@ -56,9 +62,6 @@ if (WITH_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

# Needed so that cmake uses our find modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
include_directories("/opt/homebrew/include")
Expand All @@ -69,6 +72,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif ()
endif ()

include(FindHelper)

# Define the list of source files
set(SOURCE_FILES
src/a2065.cpp
Expand Down Expand Up @@ -480,9 +485,10 @@ find_package(FLAC REQUIRED)
find_package(mpg123 REQUIRED)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
find_library(LIBSERIALPORT_LIBRARIES serialport REQUIRED)
find_library(PORTMIDI_LIBRARIES portmidi REQUIRED)
find_library(LIBMPEG2 mpeg2 REQUIRED)
find_helper(LIBSERIALPORT libserialport libserialport.h serialport)
find_helper(PORTMIDI portmidi portmidi.h portmidi)
find_helper(LIBMPEG2_CONVERT libmpeg2convert mpeg2convert.h mpeg2convert)
find_helper(LIBMPEG2 libmpeg2 mpeg2.h mpeg2)

set(libmt32emu_SHARED FALSE)
add_subdirectory(external/mt32emu)
Expand All @@ -495,7 +501,7 @@ add_dependencies(${PROJECT_NAME} mt32emu floppybridge capsimage guisan)

target_compile_options(${PROJECT_NAME} PRIVATE -fno-pie)
target_include_directories(${PROJECT_NAME} PRIVATE src src/osdep src/include src/threaddep src/archivers src/ppc/pearpc external/libguisan/include external/mt32emu/src external/floppybridge/src)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2 SDL2_image SDL2_ttf guisan mt32emu ${DBUS_LIBRARIES} FLAC portmidi png MPG123::libmpg123 mpeg2convert mpeg2 serialport z pthread dl)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2 SDL2_image SDL2_ttf guisan mt32emu ${DBUS_LIBRARIES} FLAC ${PORTMIDI_LIBRARIES} png MPG123::libmpg123 ${LIBMPEG2_LIBRARIES} ${LIBMPEG2_CONVERT_LIBRARIES} ${LIBSERIALPORT_LIBRARIES} z pthread dl)
target_link_options(${PROJECT_NAME} PRIVATE -no-pie)

if (USE_OPENGL)
Expand Down Expand Up @@ -616,13 +622,15 @@ else()
# Install icon
install(FILES ${CMAKE_SOURCE_DIR}/data/amiberry.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
# Install Debian files

install(FILES ${CMAKE_SOURCE_DIR}/debian/changelog.gz
DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES ${CMAKE_SOURCE_DIR}/debian/copyright
DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES ${CMAKE_SOURCE_DIR}/docs/amiberry.1.gz
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${CMAKE_SOURCE_DIR}/data/Amiberry.metainfo.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
endif()

# Base package settings
Expand Down
53 changes: 53 additions & 0 deletions cmake/FindHelper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# - Try to find a library using pkg-config if available,
# than portable macros FIND_PATH and FIND_LIBRARY
#
# The following variables will be set :
#
# ${prefix}_FOUND - set to 1 or TRUE if found
# ${prefix}_INCLUDE_DIRS - to be used in INCLUDE_DIRECTORIES(...)
# ${prefix}_LIBRARIES - to be used in TARGET_LINK_LIBRARIES(...)
#
# Copyright (c) 2009-2017, Jérémy Zurcher, <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

macro(FIND_HELPER prefix pkg_name header lib)
if(${prefix}_INCLUDE_DIRS AND ${prefix}_LIBRARIES)
# use cached variables
set(${prefix}_FIND_QUIETLY TRUE)
set(${prefix}_FOUND TRUE)
else()
# use pkg-config if available to set find_path and find_library hints
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_${prefix} ${pkg_name})
else()
message(STATUS "Checking for module '${pkg_name}' without pkgconfig")
endif()
# find_path
find_path(${prefix}_INCLUDE_DIRS
NAMES ${header}
HINTS ${PC_${prefix}_INCLUDEDIR} ${PC_${prefix}_INCLUDE_DIRS}
ENV ${prefix}_INCLUDE
)
# find_library
find_library(${prefix}_LIBRARIES
NAMES ${lib}
HINTS ${PC_${prefix}_LIBDIR} ${PC_${prefix}_LIBRARY_DIRS}
ENV ${prefix}_PATH
)
include(FindPackageHandleStandardArgs)
if ("${${prefix}_INCLUDE_DIRS}" STREQUAL "")
set(${prefix}_INCLUDE_DIRS "/usr/include")
endif ()
find_package_handle_standard_args(${prefix} DEFAULT_MSG ${prefix}_LIBRARIES ${prefix}_INCLUDE_DIRS)
if(NOT "${PC_${prefix}_INCLUDE_DIRS}" STREQUAL "")
set(${prefix}_INCLUDE_DIRS "${${prefix}_INCLUDE_DIRS};${PC_${prefix}_INCLUDE_DIRS}")
endif()
# Update variables in the cache (these are set by find_path/find_library) after modifying
set(${prefix}_INCLUDE_DIRS "${${prefix}_INCLUDE_DIRS}" CACHE PATH "Path to ${pkg_name} include files" FORCE)
set(${prefix}_LIBRARIES "${${prefix}_LIBRARIES}" CACHE FILEPATH "Path to ${pkg_name} libraries" FORCE)
endif()
endmacro()
4 changes: 2 additions & 2 deletions data/Amiberry.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ GenericName = Amiga Emulator
Comment = Optimized Amiga Emulator

# The executable of the application, possibly with arguments
Exec = /usr/bin/amiberry %f
TryExec = /usr/bin/amiberry
Exec = amiberry %f
TryExec = amiberry

# The name of the icon that will be used to display this entry
Icon = amiberry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>com.blitterstudio.amiberry</id>
<launchable type="desktop-id">com.blitterstudio.amiberry.desktop</launchable>
<id>amiberry</id>
<launchable type="desktop-id">Amiberry.desktop</launchable>
<name>Amiberry</name>
<developer_name>BlitterStudio</developer_name>
<summary>An Amiga emulator for Linux</summary>
<summary>A multi-platform Amiga emulator</summary>

<metadata_license>FSFAP</metadata_license>
<content_rating type="oars-1.1" />
Expand Down
33 changes: 0 additions & 33 deletions flatpak/com.blitterstudio.amiberry.desktop

This file was deleted.

15 changes: 6 additions & 9 deletions flatpak/com.blitterstudio.amiberry.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
app-id: com.blitterstudio.amiberry
runtime: org.freedesktop.Platform
runtime-version: "23.08"
runtime-version: "24.08"
sdk: org.freedesktop.Sdk
command: amiberry
rename-desktop-file: Amiberry.desktop
rename-appdata-file: Amiberry.metainfo.xml
rename-icon: amiberry
finish-args:
- --device=all
Expand Down Expand Up @@ -58,11 +60,11 @@ modules:
- -DCMAKE_BUILD_TYPE=Release
sources:
- type: git
url: https://github.com/PortMidi/PortMidi
url: https://github.com/PortMidi/portmidi.git
tag: v2.0.4
commit: b808babecdc5d05205467dab5c1006c5ac0fdfd4
cleanup:
- /bin
- /lib/cmake
- /lib/pkgconfig
- /include
- '*.a'
Expand All @@ -71,12 +73,7 @@ modules:
- name: amiberry
buildsystem: cmake-ninja
builddir: true
post-install:
- install -D -m644 -t /app/share/applications/ flatpak/${FLATPAK_ID}.desktop
- install -D -m644 -t /app/share/metainfo/ flatpak/${FLATPAK_ID}.metainfo.xml

sources:
- type: git
url: https://github.com/BlitterStudio/amiberry
tag: flatpak-preview
commit: 7882b2c8fc77b1540d886eb39b8742f86d0b6032
branch: fix-flatpak

0 comments on commit 940c046

Please sign in to comment.