mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Add initial support for AppImage on Linux
This commit is contained in:
parent
8d543e16ec
commit
fc0a67ffb6
@ -1,6 +1,8 @@
|
||||
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/ExternalProject.cmake)
|
||||
|
||||
include_directories (${CMAKE_INSTALL_PREFIX}/include)
|
||||
@ -135,3 +137,13 @@ install (DIRECTORY resources/image DESTINATION share/planetblupi)
|
||||
install (DIRECTORY resources/movie DESTINATION share/planetblupi)
|
||||
install (DIRECTORY resources/sound DESTINATION share/planetblupi)
|
||||
install (DIRECTORY resources/music DESTINATION share/planetblupi)
|
||||
|
||||
#########
|
||||
## Deploy
|
||||
#########
|
||||
|
||||
if (APPIMAGE_APPRUN_PROGRAM AND APPIMAGE_ASSISTANT_PROGRAM)
|
||||
include (LinuxAppImageBuild)
|
||||
set (CMAKE_PACKAGED_OUTPUT_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
APPIMAGE_PACKAGE (planetblupi "planetblupi" "resources/linux" "share" "" "")
|
||||
endif ()
|
||||
|
144
cmake/LinuxAppImageBuild.cmake
Normal file
144
cmake/LinuxAppImageBuild.cmake
Normal file
@ -0,0 +1,144 @@
|
||||
set ( APPIMAGE_CONFIG_DIR "${CMAKE_SOURCE_DIR}" ) # Specifies where to find template files, in this case this same directory
|
||||
|
||||
set ( APPIMAGE_ASSISTANT_PROGRAM CACHE FILEPATH "AppImageAssistant executable" )
|
||||
set ( APPIMAGE_APPRUN_PROGRAM CACHE FILEPATH "AppImage AppRun executable" )
|
||||
|
||||
set ( APPIMAGE_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deploy/linux-appimage" CACHE PATH "Where to put the AppDir items" )
|
||||
set ( APPIMAGE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/package/linux-appimage" CACHE PATH "AppImage output directory" )
|
||||
set ( APPIMAGE_FOLLOW_STANDARD OFF CACHE BOOL "Whether generator should follow the spec" )
|
||||
|
||||
macro( APPIMAGE_PACKAGE TARGET APPIMAGE_TITLE CONFIGDIR DATA LIBRARIES LIBRARY_FILES )
|
||||
string ( TOLOWER "${APPIMAGE_TITLE}" APPIMAGE_INTERNALNAME )
|
||||
string ( MAKE_C_IDENTIFIER "${APPIMAGE_INTERNALNAME}" APPIMAGE_INTERNALNAME )
|
||||
|
||||
# Some prerequisites
|
||||
# TITLE here is used as the name of the final AppImage as well as the desktop entry's name
|
||||
set ( APPIMAGE_TITLE "${APPIMAGE_TITLE}" )
|
||||
set ( APPIMAGE_INTERNALNAME "${APPIMAGE_INTERNALNAME}" )
|
||||
set ( APPIMAGE_LIBRARIES )
|
||||
set ( APPIMAGE_DATA )
|
||||
set ( APPIMAGE_CONFIG_DIR "${APPIMAGE_CONFIG_DIR}/${CONFIGDIR}" )
|
||||
set ( APPIMAGE_DEFAULT_ICON_FILE "${APPIMAGE_CONFIG_DIR}/icon.svg" )
|
||||
|
||||
# Icon file to be used for the AppImage, only one in this case, preferrably SVG
|
||||
set ( APPIMAGE_ICON "${APPIMAGE_DEFAULT_ICON_FILE}" )
|
||||
# We define a way to reference this icon based on where it is located
|
||||
set ( APPIMAGE_ICON_REF "${APPIMAGE_INTERNALNAME}" )
|
||||
|
||||
# This helps the window manager to recognize the program even if it has no embedded or loaded icon
|
||||
set ( APPIMAGE_EXEC_WM ${TARGET} )
|
||||
|
||||
# Sets the launch variable in .desktop entry
|
||||
set ( APPIMAGE_EXEC ${TARGET} )
|
||||
|
||||
# This directory is used for temporary files, might get messy
|
||||
set ( APPIMAGE_CACHE_DIR "${APPIMAGE_WORKING_DIRECTORY}/${APPIMAGE_INTERNALNAME}_cache" )
|
||||
# Where the AppDir is generated
|
||||
set ( APPIMAGE_INTERMEDIATE_DIR "${APPIMAGE_WORKING_DIRECTORY}/${APPIMAGE_INTERNALNAME}" )
|
||||
set ( APPIMAGE_ICON_TARGET "${APPIMAGE_INTERMEDIATE_DIR}/${APPIMAGE_ICON_REF}" )
|
||||
set ( APPIMAGE_BINARY_DIR "${APPIMAGE_INTERMEDIATE_DIR}/usr/bin" )
|
||||
set ( APPIMAGE_ASSET_DIR "${APPIMAGE_INTERMEDIATE_DIR}/usr/share" )
|
||||
set ( APPIMAGE_LIBRARY_DIR "${APPIMAGE_INTERMEDIATE_DIR}/usr/lib" )
|
||||
set ( APPIMAGE_FINAL_NAME "${APPIMAGE_OUTPUT_DIRECTORY}/${APPIMAGE_TITLE}.AppImage" )
|
||||
|
||||
list ( APPEND APPIMAGE_LIBRARIES
|
||||
${LIBRARIES} )
|
||||
list ( APPEND APPIMAGE_DATA
|
||||
${DATA} )
|
||||
|
||||
# Remove the previous AppImage file to avoid confusion when generating a new one
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E remove "${APPIMAGE_FINAL_NAME}"
|
||||
)
|
||||
|
||||
# Create some necessary directory structure in AppDir
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${APPIMAGE_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${APPIMAGE_BINARY_DIR}"
|
||||
)
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${APPIMAGE_CACHE_DIR}"
|
||||
)
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${APPIMAGE_LIBRARY_DIR}"
|
||||
)
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${APPIMAGE_ASSET_DIR}"
|
||||
)
|
||||
|
||||
# Copy and configure some data for the AppDir
|
||||
configure_file (
|
||||
"${APPIMAGE_ICON}"
|
||||
"${APPIMAGE_ICON_TARGET}"
|
||||
COPYONLY
|
||||
)
|
||||
configure_file (
|
||||
"${APPIMAGE_ICON}"
|
||||
"${APPIMAGE_INTERMEDIATE_DIR}/.DirIcon"
|
||||
COPYONLY
|
||||
)
|
||||
configure_file (
|
||||
"${APPIMAGE_CONFIG_DIR}/application.desktop.in"
|
||||
"${APPIMAGE_INTERMEDIATE_DIR}/${APPIMAGE_INTERNALNAME}.desktop"
|
||||
@ONLY
|
||||
)
|
||||
configure_file (
|
||||
"${APPIMAGE_APPRUN_PROGRAM}"
|
||||
"${APPIMAGE_INTERMEDIATE_DIR}/AppRun"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
# Copy resources into AppDir
|
||||
foreach ( RESC ${DATA} )
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${RESC}" "${APPIMAGE_ASSET_DIR}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Copy bundled libraries into AppDir
|
||||
foreach ( LIB ${LIBRARY_FILES} )
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${LIB}" "${APPIMAGE_LIBRARY_DIR}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach ( LIB ${LIBRARIES} )
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${LIB}>" "${APPIMAGE_LIBRARY_DIR}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Copy the binary to AppDir
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${TARGET}>" "${APPIMAGE_BINARY_DIR}"
|
||||
)
|
||||
|
||||
# Do the actual packaging step with AppImageKit
|
||||
add_custom_command ( TARGET ${TARGET}
|
||||
POST_BUILD
|
||||
COMMAND "${APPIMAGE_ASSISTANT_PROGRAM}" "${APPIMAGE_INTERMEDIATE_DIR}" "${APPIMAGE_FINAL_NAME}"
|
||||
)
|
||||
|
||||
install (
|
||||
FILES
|
||||
"${APPIMAGE_FINAL_NAME}"
|
||||
|
||||
DESTINATION
|
||||
"${CMAKE_PACKAGED_OUTPUT_PREFIX}/linux-appimage"
|
||||
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
)
|
||||
endmacro()
|
7
resources/linux/application.desktop.in
Normal file
7
resources/linux/application.desktop.in
Normal file
@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=@APPIMAGE_TITLE@
|
||||
Exec=@APPIMAGE_EXEC@
|
||||
StartupWMClass=@APPIMAGE_EXEC_WM@
|
||||
Icon=@APPIMAGE_ICON_REF@
|
47
resources/linux/icon.svg
Normal file
47
resources/linux/icon.svg
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 32 32"
|
||||
height="32"
|
||||
width="32"
|
||||
id="svg2"
|
||||
version="1.1">
|
||||
<metadata
|
||||
id="metadata8">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs6" />
|
||||
<image
|
||||
y="0"
|
||||
x="0"
|
||||
id="image10"
|
||||
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAfpJREFU
|
||||
WIWtl9ux2zAMRBdJCkknQmcGO0knd9mJO2E+JFoQ37K9MxzLJAUc8bGigJsys2Rmqawn2az/qo4E
|
||||
CUAyy+UFdNTfg/h1E8HB+DpfbyC5DPF7tSPJ9Hz+gyrw8wOI7PWPBxAjoHqW5/MvSIaVuLKafNv0
|
||||
9T8EO678r8FLlVDVafwlgJTwGtIYiW3bjuvoIQsIg5l9HwC4Tu8IYmUUpovQL6gYOete3jvtMwXw
|
||||
c1+qfnqgnIbZjhgCtG6OMUJEIHKOrKrCzGDn3myAvQFQPj1JqJ51qlolqCHGo9AFaN9kvr2CG8Tq
|
||||
tnUBtk0RBlbSA2jMAkaj0NwiJBOpeDzqthDOJL3fnszqfH9aHfe5J2Ks10GGasH1pEqQCpKp9IWb
|
||||
L6P7yXcAldKqPwL4proAKy+SEDBcqLvsPYBewtZ1ldLl9L5xG0BVpUwksp58Rc1dcIUgQtBLgoXt
|
||||
5u5/822YjaMVIEOUMKXTqNLFMrRUAeTEpFaBesoQAlzOihk+x2pZcgVwWvBJrKqyAuFH43oaMvRU
|
||||
rYH90MHp6p3Ju56Zya13QStYtuQ8OiVgfSb84pGsPhXZkUAll9zibTr7/yzHUCkhlSV/EY365S+n
|
||||
j45kLc2t96qPjmQjjRaph5wt5qkTxsiLJ7jA8k6/UtMRqD3AmsZ09rNhv1L/AXAWRbvl/ijOAAAA
|
||||
AElFTkSuQmCC
|
||||
"
|
||||
preserveAspectRatio="none"
|
||||
height="32"
|
||||
width="32" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
x
Reference in New Issue
Block a user