summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoco875 <pereira.jannin@gmail.com>2024-12-10 23:51:47 +0100
committercoco875 <pereira.jannin@gmail.com>2024-12-10 23:51:47 +0100
commitb7934ae15507211640f6ac7797e8330b9db66a23 (patch)
tree2b718823f9d5d5a7cc32508ed041775a0417abf0
parent537b25ab13ecd07146463711c576ed28cad72165 (diff)
configure the app image
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt17
-rw-r--r--Starship.desktop9
-rw-r--r--cmake/configure-packaging.cmake29
-rw-r--r--cmake/packaging.cmake89
-rw-r--r--logo.pngbin0 -> 12110 bytes
6 files changed, 145 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 197cd865..4f7d42c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,4 +47,5 @@ Starship.log
*.sav
*.lib
*.pdb
-dumps/ \ No newline at end of file
+dumps/
+_packages/*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e14777e0..b922be65 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -555,4 +555,19 @@ add_custom_target(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} pack port starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
-) \ No newline at end of file
+)
+
+set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES)
+set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/Starship.desktop")
+set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_ICON_FILE "${CMAKE_SOURCE_DIR}/logo.png")
+
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(CPACK_GENERATOR "External")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
+ set(CPACK_GENERATOR "ZIP")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ set(CPACK_GENERATOR "Bundle")
+endif()
+
+set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/configure-packaging.cmake)
+include(cmake/packaging.cmake) \ No newline at end of file
diff --git a/Starship.desktop b/Starship.desktop
new file mode 100644
index 00000000..566ac94f
--- /dev/null
+++ b/Starship.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.0
+Name=2SHIP
+Exec=Starship
+Terminal=false
+Icon=logo
+Type=Application
+Categories=Game;
+X-AppImage-Integrate=false \ No newline at end of file
diff --git a/cmake/configure-packaging.cmake b/cmake/configure-packaging.cmake
new file mode 100644
index 00000000..8d6869bd
--- /dev/null
+++ b/cmake/configure-packaging.cmake
@@ -0,0 +1,29 @@
+set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
+set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
+set(CPACK_COMPONENTS_ALL "Starship")
+
+if (CPACK_GENERATOR STREQUAL "External")
+ list(APPEND CPACK_COMPONENTS_ALL "extractor" "appimage")
+endif()
+
+if (CPACK_GENERATOR MATCHES "DEB|RPM")
+# https://unix.stackexchange.com/a/11552/254512
+set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/ship/bin")#/${CMAKE_PROJECT_VERSION}")
+set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
+elseif (CPACK_GENERATOR MATCHES "ZIP")
+set(CPACK_PACKAGING_INSTALL_PREFIX "")
+endif()
+
+if (CPACK_GENERATOR MATCHES "External")
+set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
+SET(CPACK_MONOLITHIC_INSTALL 1)
+set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/bin")
+endif()
+
+if (CPACK_GENERATOR MATCHES "Bundle")
+ set(CPACK_BUNDLE_NAME "Starship")
+ set(CPACK_BUNDLE_PLIST "macosx/Info.plist")
+ set(CPACK_BUNDLE_ICON "macosx/Starship.icns")
+ set(CPACK_BUNDLE_STARTUP_COMMAND "macosx/Starship-macos.sh")
+ set(CPACK_BUNDLE_APPLE_CERT_APP "-")
+endif() \ No newline at end of file
diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake
new file mode 100644
index 00000000..a32192d4
--- /dev/null
+++ b/cmake/packaging.cmake
@@ -0,0 +1,89 @@
+# these are cache variables, so they could be overwritten with -D,
+
+set(CPACK_PACKAGE_NAME "${PROJECT_NAME}"
+ CACHE STRING "The resulting package name"
+)
+
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple C++ application"
+ CACHE STRING "Package description for the package metadata"
+)
+set(CPACK_PACKAGE_VENDOR "Some Company")
+
+set(CPACK_VERBATIM_VARIABLES YES)
+
+set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
+SET(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/_packages")
+
+set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
+set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+
+set(CPACK_PACKAGE_CONTACT "YOUR@E-MAIL.net")
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "YOUR NAME")
+
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
+set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set(CPACK_SYSTEM_NAME ${LSB_RELEASE_CODENAME_SHORT})
+# package name for deb
+# if set, then instead of some-application-0.9.2-Linux.deb
+# you'll get some-application_0.9.2_amd64.deb (note the underscores too)
+#set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+set( CPACK_DEBIAN_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-${ARCHITECTURE}.deb )
+# if you want every group to have its own package,
+# although the same happens if this is not sent (so it defaults to ONE_PER_GROUP)
+# and CPACK_DEB_COMPONENT_INSTALL is set to YES
+set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)#ONE_PER_GROUP)
+# without this you won't be able to pack only specified component
+set(CPACK_DEB_COMPONENT_INSTALL YES)
+
+set(CPACK_EXTERNAL_ENABLE_STAGING YES)
+set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${PROJECT_BINARY_DIR}/appimage-generate.cmake")
+
+file(GENERATE
+ OUTPUT "${PROJECT_BINARY_DIR}/appimage-generate.cmake"
+ CONTENT [[
+include(CMakePrintHelpers)
+cmake_print_variables(CPACK_TEMPORARY_DIRECTORY)
+cmake_print_variables(CPACK_TOPLEVEL_DIRECTORY)
+cmake_print_variables(CPACK_PACKAGE_DIRECTORY)
+cmake_print_variables(CPACK_PACKAGE_FILE_NAME)
+
+find_program(LINUXDEPLOY_EXECUTABLE
+ NAMES linuxdeploy linuxdeploy-x86_64.AppImage
+ PATHS ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy)
+
+if (NOT LINUXDEPLOY_EXECUTABLE)
+ message(STATUS "Downloading linuxdeploy")
+ set(LINUXDEPLOY_EXECUTABLE ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/linuxdeploy)
+ file(DOWNLOAD
+ https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
+ ${LINUXDEPLOY_EXECUTABLE}
+ INACTIVITY_TIMEOUT 10
+ LOG ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/download.log
+ STATUS LINUXDEPLOY_DOWNLOAD)
+ execute_process(COMMAND chmod +x ${LINUXDEPLOY_EXECUTABLE} COMMAND_ECHO STDOUT)
+endif()
+
+execute_process(
+ COMMAND
+ NO_STRIP=true ${CMAKE_COMMAND} -E env
+ OUTPUT=${CPACK_PACKAGE_FILE_NAME}.appimage
+ VERSION=$<IF:$<BOOL:${CPACK_PACKAGE_VERSION}>,${CPACK_PACKAGE_VERSION},0.1.0>
+ ${LINUXDEPLOY_EXECUTABLE}
+ --appimage-extract-and-run
+ --appdir=${CPACK_TEMPORARY_DIRECTORY}
+ --executable=$<TARGET_FILE:Starship>
+ $<$<BOOL:$<TARGET_PROPERTY:Starship,APPIMAGE_DESKTOP_FILE>>:--desktop-file=$<TARGET_PROPERTY:Starship,APPIMAGE_DESKTOP_FILE>>
+ $<$<BOOL:$<TARGET_PROPERTY:Starship,APPIMAGE_ICON_FILE>>:--icon-file=$<TARGET_PROPERTY:Starship,APPIMAGE_ICON_FILE>>
+ --output=appimage
+ --verbosity=2
+)
+]])
+
+endif()
+
+include(CPack) \ No newline at end of file
diff --git a/logo.png b/logo.png
new file mode 100644
index 00000000..56ddadf1
--- /dev/null
+++ b/logo.png
Binary files differ