Drag'n Drop for macOS / Fix #1109 / ... (#1353)

This commit is contained in:
Markus
2021-10-16 05:07:36 -07:00
committed by GitHub
parent c9a7258160
commit a1dee08195
19 changed files with 384 additions and 186 deletions

View File

@@ -1,4 +1,94 @@
macro(DeployUnix TARGET)
macro(DeployMacOS TARGET)
if (EXISTS ${TARGET_FILE})
message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
get_target_property(QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
execute_process(
COMMAND ${QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
OUTPUT_VARIABLE QT_PLUGIN_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
install(CODE "set(TARGET_FILE \"${TARGET_FILE}\") \n set(TARGET_BUNDLE_NAME \"${TARGET}.app\") \n set(PLUGIN_DIR \"${QT_PLUGIN_DIR}\")" COMPONENT "Hyperion")
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES ${TARGET_FILE}
RESOLVED_DEPENDENCIES_VAR resolved_deps
UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
PRE_INCLUDE_REGEXES ".dylib"
PRE_EXCLUDE_REGEXES ".*"
)
foreach(dependency ${resolved_deps})
file(INSTALL
FILES "${dependency}"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/Frameworks"
TYPE SHARED_LIBRARY
)
endforeach()
list(LENGTH unresolved_deps unresolved_length)
if("${unresolved_length}" GREATER 0)
message(WARNING "The following unresolved dependencies were discovered: ${unresolved_deps}")
endif()
foreach(PLUGIN "platforms" "sqldrivers" "imageformats")
if(EXISTS ${PLUGIN_DIR}/${PLUGIN})
file(GLOB files "${PLUGIN_DIR}/${PLUGIN}/*")
foreach(file ${files})
get_filename_component(plugin ${file} NAME)
list(APPEND QT_PLUGINS "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/plugins/${PLUGIN}/${plugin}")
file(INSTALL
FILES ${file}
DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/plugins/${PLUGIN}"
TYPE SHARED_LIBRARY
)
endforeach()
endif()
endforeach()
include(BundleUtilities)
fixup_bundle("${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}" "${QT_PLUGINS}" "" IGNORE_ITEM "python;python3;Python;Python3;.Python;.Python3")
# Detect the Python version and modules directory
find_package(Python3 3.5 REQUIRED)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(standard_lib=True))"
OUTPUT_VARIABLE PYTHON_MODULES_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Copy Python modules to '/../Frameworks/Python.framework/Versions/Current/lib/PythonMAJOR.MINOR' and ignore the unnecessary stuff listed below
if (PYTHON_MODULES_DIR)
set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
file(
COPY ${PYTHON_MODULES_DIR}/
DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/Frameworks/Python.framework/Versions/Current/lib/python${PYTHON_VERSION_MAJOR_MINOR}"
PATTERN "*.pyc" EXCLUDE # compiled bytecodes
PATTERN "__pycache__" EXCLUDE # any cache
PATTERN "config-${PYTHON_VERSION_MAJOR_MINOR}*" EXCLUDE # static libs
PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation
PATTERN "tkinter" EXCLUDE # Tk interface
PATTERN "turtledemo" EXCLUDE # Tk demo folder
PATTERN "turtle.py" EXCLUDE # Tk demo file
PATTERN "test" EXCLUDE # unittest module
PATTERN "sitecustomize.py" EXCLUDE # site-specific configs
)
endif(PYTHON_MODULES_DIR)
]] COMPONENT "Hyperion")
else()
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$<TARGET_FILE:${TARGET}>"
ARGS ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
VERBATIM
)
endif()
endmacro()
macro(DeployLinux TARGET)
if (EXISTS ${TARGET_FILE})
message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
include(GetPrerequisites)
@@ -80,8 +170,8 @@ macro(DeployUnix TARGET)
endforeach()
endif(OPENSSL_FOUND)
# Detect the Qt5 plugin directory, source: https://github.com/lxde/lxqt-qtplugin/blob/master/src/CMakeLists.txt
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
# Detect the Qt5 plugin directory
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
execute_process(
COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
OUTPUT_VARIABLE QT_PLUGINS_DIR
@@ -139,26 +229,18 @@ macro(DeployUnix TARGET)
# Detect the Python version and modules directory
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(standard_lib=True))"
OUTPUT_VARIABLE PYTHON_MODULES_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PYTHON_MODULES_DIR "${Python3_STDLIB}")
else()
set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(standard_lib=True))"
OUTPUT_VARIABLE PYTHON_MODULES_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# Copy Python modules to 'share/hyperion/lib/pythonXX' and ignore the unnecessary stuff listed below
# Copy Python modules to 'share/hyperion/lib/pythonMAJOR.MINOR' and ignore the unnecessary stuff listed below
if (PYTHON_MODULES_DIR)
install(

View File

@@ -0,0 +1,61 @@
on run argv
set image_name to item 1 of argv
tell application "Finder"
tell disk image_name
-- wait for the image to finish mounting
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5
-- open the image the first time and save a DS_Store with just
-- background and icon setup
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.png"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 100
delay 5
close
-- next setup the position of the app and Applications symlink
-- plus hide all the window decoration
open
tell container window
set sidebar width to 0
set toolbar visible to false
set statusbar visible to false
set the bounds to {300, 100, 1000, 548}
set position of item "Hyperion.app" to {260, 230}
set extension hidden of item "Hyperion.app" to true
set position of item "Applications" to {590, 228}
-- Move these out of the way for users with Finder configured to show all files
set position of item ".background" to {800, 280}
set position of item ".fseventsd" to {800, 280}
set position of item ".VolumeIcon.icns" to {800, 280}
end tell
delay 1
close
-- one last open and close so you can see everything looks correct
open
delay 5
close
end tell
delay 1
end tell
end run

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -1,70 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleVersion</key>
<string>1489366340</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>hyperiond</string>
<key>CFBundleIconFile</key>
<string>Hyperion.icns</string>
<key>CFBundleIdentifier</key>
<string>com.hyperion-project.Hyperion</string>
<key>CFBundleName</key>
<string>Hyperion</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<key>BuildMachineOSBuild</key>
<string>11G63</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>DTCompiler</key>
<string></string>
<key>DTPlatformBuild</key>
<string>4H1003</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>12D75</string>
<key>DTSDKName</key>
<string>macosx10.8</string>
<key>DTXcode</key>
<string>0462</string>
<key>DTXcodeBuild</key>
<string>4H1003</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Hyperion team. All rights reserved.</string>
<!--key>NSMainNibFile</key>
<string>MainMenu</string-->
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUEnableSystemProfiling</key>
<false/>
<key>SUShowReleaseNotes</key>
<true/>
<key>SUAllowsAutomaticUpdates</key>
<true/>
</dict>
<dict>
<key>CFBundleDeveloperRegion</key>
<string>en</string>
<key>CFBundleIdentifier</key>
<string>com.hyperion-project.hyperiond</string>
<key>CFBundleName</key>
<string>Hyperion</string>
<key>CFBundleExecutable</key>
<string>Hyperion</string>
<key>CFBundleIconFile</key>
<string>Hyperion.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>NSHumanReadableCopyright</key>
<string>MIT License</string>
<key>Source Code</key>
<string>"https://github.com/hyperion-project/hyperion.ng"</string>
</dict>
</plist>

Binary file not shown.

View File

@@ -1,5 +0,0 @@
#!/bin/sh
cd "$(dirname "$0")"
# Path to hyperiond!?
cd ../Resources/bin
exec ./hyperiond "$@"

View File

@@ -1,8 +1,9 @@
# cmake file for generating distribution packages
# default packages to build
# Default packages to build
IF (APPLE)
SET ( CPACK_GENERATOR "TGZ")
SET ( CPACK_GENERATOR "DragNDrop")
SET ( CPACK_DMG_FORMAT "UDBZ" )
ELSEIF (UNIX)
SET ( CPACK_GENERATOR "TGZ")
ELSEIF (WIN32)
@@ -11,11 +12,12 @@ ENDIF()
# Determine packages by found generator executables
find_package(RpmBuilder)
find_package(DebBuilder)
IF(RPM_BUILDER_FOUND)
message(STATUS "CPACK: Found RPM builder")
SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "RPM")
ENDIF()
find_package(DebBuilder)
IF(DEB_BUILDER_FOUND)
message(STATUS "CPACK: Found DEB builder")
SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "DEB")
@@ -43,12 +45,12 @@ SET ( CPACK_PACKAGE_CONTACT "packages@hyperion-project.org")
SET ( CPACK_PACKAGE_VENDOR "hyperion-project")
SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" )
SET ( CPACK_PACKAGE_INSTALL_DIRECTORY "Hyperion" )
SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-icon-32px.png")
SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-icon-32px.png" )
SET ( CPACK_PACKAGE_VERSION_MAJOR "${HYPERION_VERSION_MAJOR}")
SET ( CPACK_PACKAGE_VERSION_MINOR "${HYPERION_VERSION_MINOR}")
SET ( CPACK_PACKAGE_VERSION_PATCH "${HYPERION_VERSION_PATCH}")
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" )
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" )
SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" )
SET ( CPACK_CREATE_DESKTOP_LINKS "hyperiond;Hyperion" )
@@ -57,46 +59,46 @@ if (NOT "${HYPERION_VERSION_PRE}" STREQUAL "")
string(APPEND CPACK_PACKAGE_VERSION_PATCH ${HYPERION_VERSION_PRE})
endif()
# Define the install prefix path for cpack
IF ( UNIX )
#SET ( CPACK_PACKAGING_INSTALL_PREFIX "share/hyperion")
ENDIF()
# Specific CPack Package Generators
# https://cmake.org/Wiki/CMake:CPackPackageGenerators
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators
# .deb files for apt
SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/prerm" )
# https://cmake.org/cmake/help/latest/cpack_gen/deb.html
SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4" )
SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" )
# .rpm for rpm
# https://cmake.org/cmake/help/v3.5/module/CPackRPM.html
# https://cmake.org/cmake/help/latest/cpack_gen/rpm.html
SET ( CPACK_RPM_PACKAGE_RELEASE 1 )
SET ( CPACK_RPM_PACKAGE_LICENSE "MIT" )
SET ( CPACK_RPM_PACKAGE_GROUP "Applications" )
SET ( CPACK_RPM_PACKAGE_REQUIRES "libcec >= 4.0.0" )
SET ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/preinst" )
SET ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/postinst" )
SET ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-scripts/prerm" )
SET ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst" )
SET ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst" )
SET ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
# OSX "Bundle" generator TODO Add more osx generators
# https://cmake.org/cmake/help/v3.10/module/CPackBundle.html
SET ( CPACK_BUNDLE_NAME "Hyperion" )
SET ( CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/cmake/osxbundle/Hyperion.icns )
SET ( CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/cmake/osxbundle/Info.plist )
SET ( CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_SOURCE_DIR}/cmake/osxbundle/launch.sh" )
# .dmg for Apple macOS
# https://cmake.org/cmake/help/latest/cpack_gen/dmg.html
IF (APPLE)
SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/osxbundle/PackageIcon.icns" )
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE" )
SET ( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/cmake/osxbundle/Background.png" )
SET ( CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/osxbundle/AppleScript.scpt" )
ENDIF(APPLE)
# Windows NSIS
# Use custom script based on cpack nsis template
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/nsis/template ${CMAKE_MODULE_PATH})
# Some path transformations
if(WIN32)
file(TO_NATIVE_PATH ${CPACK_PACKAGE_ICON} CPACK_PACKAGE_ICON)
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON})
endif()
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/nsis/installer.ico" NSIS_HYP_ICO)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/nsis/header.bmp" NSIS_HYP_LOGO_HORI)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/nsis/logo.bmp" NSIS_HYP_LOGO_VERT)
file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico" NSIS_HYP_ICO)
file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/header.bmp" NSIS_HYP_LOGO_HORI)
file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/logo.bmp" NSIS_HYP_LOGO_VERT)
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_ICO "${NSIS_HYP_ICO}")
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_VERT "${NSIS_HYP_LOGO_VERT}")
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_HORI "${NSIS_HYP_LOGO_HORI}")
@@ -113,19 +115,25 @@ SET ( CPACK_NSIS_HELP_LINK "https://www.hyperion-project.org")
SET ( CPACK_NSIS_URL_INFO_ABOUT "https://www.hyperion-project.org")
SET ( CPACK_NSIS_MUI_FINISHPAGE_RUN "hyperiond.exe")
SET ( CPACK_NSIS_BRANDING_TEXT "Hyperion-${HYPERION_VERSION}")
# custom nsis plugin directory
SET ( CPACK_NSIS_EXTRA_DEFS "!addplugindir ${CMAKE_SOURCE_DIR}/cmake/nsis/plugins")
# additional hyperiond startmenu link, won't be created if the user disables startmenu links
SET ( CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Hyperion (Console).lnk' '$INSTDIR\\\\bin\\\\hyperiond.exe' '-d -c'")
SET ( CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Hyperion (Console).lnk'")
# define the install components
# Define the install components
# See also https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Component-Install-With-CPack
# and https://cmake.org/cmake/help/latest/module/CPackComponent.html
SET ( CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE")
# Components base
SET ( CPACK_COMPONENTS_ALL "Hyperion" "hyperion_remote" )
# optional compiled
# Components base (All builds)
SET ( CPACK_COMPONENTS_ALL "Hyperion" )
SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_remote" )
# Optional compiled
if(ENABLE_QT)
SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_qt" )
endif()
@@ -151,6 +159,11 @@ if(ENABLE_OSX)
SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_osx" )
endif()
# Only include Hyperion to macOS dmg package (without standalone programs)
IF ( CPACK_GENERATOR MATCHES "DragNDrop" )
LIST ( REMOVE_ITEM CPACK_COMPONENTS_ALL "hyperion_remote" "hyperion_qt" "hyperion_osx" )
ENDIF()
SET ( CPACK_ARCHIVE_COMPONENT_INSTALL ON )
SET ( CPACK_DEB_COMPONENT_INSTALL ON )
SET ( CPACK_RPM_COMPONENT_INSTALL ON )
@@ -164,6 +177,7 @@ cpack_add_install_type(Full DISPLAY_NAME "Full")
cpack_add_install_type(Min DISPLAY_NAME "Minimal")
cpack_add_component_group(Runtime EXPANDED DESCRIPTION "Hyperion runtime and hyperion-remote commandline tool")
cpack_add_component_group(Screencapture EXPANDED DESCRIPTION "Standalone Screencapture commandline programs")
# Components base
cpack_add_component(Hyperion
DISPLAY_NAME "Hyperion"
@@ -172,6 +186,7 @@ cpack_add_component(Hyperion
GROUP Runtime
REQUIRED
)
cpack_add_component(hyperion_remote
DISPLAY_NAME "Hyperion Remote"
DESCRIPTION "Hyperion remote cli tool"
@@ -253,4 +268,3 @@ if(ENABLE_OSX)
DEPENDS Hyperion
)
endif()