-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPack: Move Apple and Linux installers to CMake/CPack
- Loading branch information
Showing
22 changed files
with
996 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,56 @@ | ||
SET(MACOSX_BUNDLE_ICON_FILE "icon.icns") | ||
SET(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_NAME_UCASE}") | ||
SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION}") | ||
SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME_UCASE}") | ||
SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION}") | ||
SET(MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION}") | ||
SET(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT}") | ||
SET(MACOSX_BUNDLE_MIMETYPE "application/x-lmms-project") | ||
SET(MACOSX_BUNDLE_MIMETYPE_ICON "project.icns") | ||
SET(MACOSX_BUNDLE_MIMETYPE_ID "io.lmms") | ||
SET(MACOSX_BUNDLE_PROJECT_URL "${PROJECT_URL}") | ||
SET(MACOSX_BUNDLE_DMG_TITLE "${MACOSX_BUNDLE_BUNDLE_NAME} ${MACOSX_BUNDLE_LONG_VERSION_STRING}") | ||
# Info.plist | ||
set(MACOS_ICON "${PROJECT_NAME_UCASE}.icns") | ||
set(MACOS_MIMETYPE "application/x-lmms-project") | ||
set(MACOS_MIMETYPE_ICON "project.icns") | ||
set(MACOS_MIMETYPE_ID "io.lmms") | ||
configure_file("lmms.plist.in" "Info.plist" @ONLY) | ||
|
||
# FIXME: appdmg won't allow volume names > 27 char | ||
# See also https://github.com/LinusU/node-appdmg/issues/48 | ||
STRING(SUBSTRING "${MACOSX_BUNDLE_DMG_TITLE}" 0 27 MACOSX_BUNDLE_DMG_TITLE) | ||
# "Bundle"-specific CPack options | ||
set(CPACK_GENERATOR "Bundle" PARENT_SCOPE) | ||
set(CPACK_BUNDLE_NAME "${PROJECT_NAME_UCASE}" PARENT_SCOPE) | ||
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" PARENT_SCOPE) | ||
set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icon.icns" PARENT_SCOPE) | ||
|
||
CONFIGURE_FILE("lmms.plist.in" "${CMAKE_BINARY_DIR}/Info.plist") | ||
CONFIGURE_FILE("install_apple.sh.in" "${CMAKE_BINARY_DIR}/install_apple.sh" @ONLY) | ||
CONFIGURE_FILE("package_apple.json.in" "${CMAKE_BINARY_DIR}/package_apple.json" @ONLY) | ||
# Standard CPack options | ||
# suppress license popup | ||
unset(CPACK_RESOURCE_FILE_LICENSE PARENT_SCOPE) | ||
# disable cpack's strip: causes missing symbols on macOS | ||
set(CPACK_STRIP_FILES_ORIG "${CPACK_STRIP_FILES}" PARENT_SCOPE) | ||
set(CPACK_STRIP_FILES false PARENT_SCOPE) | ||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION}-mac${APPLE_OS_VER}") | ||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}" PARENT_SCOPE) | ||
set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/MacDeployQt.cmake" PARENT_SCOPE) | ||
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME_UCASE} ${VERSION}" PARENT_SCOPE) | ||
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}/background.tiff" PARENT_SCOPE) | ||
set(CPACK_DMG_DS_STORE "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/DS_Store" PARENT_SCOPE) | ||
|
||
# DMG creation target | ||
SET(DMG_FILE "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}-mac${APPLE_OS_VER}.dmg") | ||
FILE(REMOVE "${DMG_FILE}") | ||
ADD_CUSTOM_TARGET(removedmg | ||
COMMAND touch "\"${DMG_FILE}\"" && rm "\"${DMG_FILE}\"" | ||
COMMENT "Removing old DMG") | ||
ADD_CUSTOM_TARGET(dmg | ||
COMMAND appdmg "\"${CMAKE_BINARY_DIR}/package_apple.json\"" "\"${DMG_FILE}\"" | ||
DEPENDS "${CMAKE_BINARY_DIR}/package_apple.json" | ||
COMMENT "Generating DMG") | ||
ADD_DEPENDENCIES(dmg removedmg) | ||
# Custom vars to expose to Cpack | ||
# must be prefixed with "CPACK_" per https://stackoverflow.com/a/46526757/3196753) | ||
set(CPACK_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) | ||
set(CPACK_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE) | ||
set(CPACK_BINARY_DIR "${CMAKE_BINARY_DIR}" PARENT_SCOPE) | ||
set(CPACK_SOURCE_DIR "${CMAKE_SOURCE_DIR}" PARENT_SCOPE) | ||
set(CPACK_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}" PARENT_SCOPE) | ||
set(CPACK_CARLA_LIBRARIES "${CARLA_LIBRARIES}" PARENT_SCOPE) | ||
set(CPACK_PROJECT_NAME "${PROJECT_NAME}" PARENT_SCOPE) | ||
set(CPACK_PROJECT_NAME_UCASE "${PROJECT_NAME_UCASE}" PARENT_SCOPE) | ||
|
||
# see also ../postinstall/CMakeLists.txt | ||
# appdmg is no longer required unless a new .DS_Store file is needed | ||
# Usage: | ||
# make package | ||
# make appdmg | ||
# ... manually copy .DS_Store file | ||
# appdmg won't allow volume names > 27 char https://github.com/LinusU/node-alias/issues/7 | ||
string(SUBSTRING "${PROJECT_NAME_UCASE} ${VERSION}" 0 27 APPDMG_VOLUME_NAME) | ||
# We'll configure this file twice (again in MacDeployQt.cmake once we know CPACK_TEMPORARY_INSTALL_DIRECTORY) | ||
configure_file("appdmg.json.in" "_appdmg.json.in" @ONLY) | ||
add_custom_target(appdmg | ||
COMMAND touch "${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}-appdmg.dmg" | ||
COMMAND rm "${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}-appdmg.dmg" | ||
COMMAND appdmg appdmg.json "${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}-appdmg.dmg" | ||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/appdmg.json" | ||
COMMENT "Generating DMG") | ||
|
||
if(CMAKE_VERSION VERSION_LESS "3.19") | ||
message(WARNING "DMG creation requires at least CMake 3.19") | ||
endif() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Variables must be prefixed with "CPACK_" to be visible here | ||
set(lmms "${CPACK_PROJECT_NAME}") | ||
set(APP "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/${CPACK_PROJECT_NAME_UCASE}.app") | ||
|
||
# 0 = no output, 1 = error/warning, 2 = normal, 3 = debug | ||
set(VERBOSITY 1) | ||
# Set to "STDOUT" to show all verbose commands | ||
set(COMMAND_ECHO NONE) | ||
|
||
# Detect release|debug build | ||
if(NOT CPACK_STRIP_FILES_ORIG) | ||
# -use-debug-libs implies -no-strip | ||
if(CPACK_QMAKE_EXECUTABLE MATCHES "/homebrew/|/usr/local") | ||
message(STATUS "Homebrew does not provide debug qt libraries, replacing \"-use-debug-libs\" with \"-no-strip\" instead") | ||
set(USE_DEBUG_LIBS -no-strip) | ||
else() | ||
set(USE_DEBUG_LIBS -use-debug-libs) | ||
endif() | ||
endif() | ||
|
||
if(CPACK_DEBUG) | ||
set(VERBOSITY 2) | ||
set(COMMAND_ECHO STDOUT) | ||
endif() | ||
|
||
execute_process(COMMAND convert | ||
"${CPACK_CURRENT_SOURCE_DIR}/*.png" | ||
"${CPACK_CURRENT_BINARY_DIR}/background.tiff" | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
|
||
# Copy missing files | ||
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/project.icns" DESTINATION "${APP}/Contents/Resources") | ||
|
||
# Updates appdmg.json with CPACK_TEMPORARY_INSTALL_DIRECTORY | ||
# - .DS_Store can be recreated using appdmg appdmg.json lmms.dmg | ||
# - Find new .DS_Store from the root of the DMG file | ||
# - cp /Volumes/lmms-x.x.x/.DS_Store ../cmake/apple/DS_Store | ||
configure_file("${CPACK_CURRENT_BINARY_DIR}/_appdmg.json.in" "${CPACK_CURRENT_BINARY_DIR}/appdmg.json") | ||
file(REMOVE "${CPACK_CURRENT_BINARY_DIR}/_appdmg.json.in") | ||
|
||
# Create bundle structure | ||
file(MAKE_DIRECTORY "${APP}/Contents/MacOS") | ||
file(MAKE_DIRECTORY "${APP}/Contents/Frameworks") | ||
file(MAKE_DIRECTORY "${APP}/Contents/Resources") | ||
|
||
# Make all libraries writable for macdeployqt | ||
file(CHMOD_RECURSE "${APP}/Contents" PERMISSIONS | ||
OWNER_EXECUTE OWNER_WRITE OWNER_READ | ||
GROUP_EXECUTE GROUP_WRITE GROUP_READ | ||
WORLD_READ) | ||
|
||
# Fix layout | ||
file(RENAME "${APP}/Contents/Resources/lib" "${APP}/Contents/lib") | ||
file(RENAME "${APP}/Contents/Resources/share" "${APP}/Contents/share") | ||
file(RENAME "${APP}/Contents/Resources/bin" "${APP}/Contents/bin") | ||
|
||
# Move binaries into Contents/MacOS | ||
file(RENAME "${APP}/Contents/bin/${lmms}" "${APP}/Contents/MacOS/${lmms}") | ||
file(RENAME "${APP}/Contents/lib/${lmms}/RemoteZynAddSubFx" "${APP}/Contents/MacOS/RemoteZynAddSubFx") | ||
file(REMOVE_RECURSE "${APP}/Contents/bin") | ||
file(REMOVE_RECURSE "${APP}/Contents/share/man1") | ||
file(REMOVE_RECURSE "${APP}/Contents/include") | ||
|
||
# Replace @rpath with @loader_path for Carla | ||
execute_process(COMMAND install_name_tool -change | ||
"@rpath/libcarlabase.dylib" | ||
"@loader_path/libcarlabase.dylib" | ||
"${APP}/Contents/lib/${lmms}/libcarlapatchbay.so" | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
execute_process(COMMAND install_name_tool -change | ||
"@rpath/libcarlabase.dylib" | ||
"@loader_path/libcarlabase.dylib" | ||
"${APP}/Contents/lib/${lmms}/libcarlarack.so" | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
|
||
# Build list of executables to inform macdeployqt about | ||
# e.g. -executable=foo.dylib -executable=bar.dylib | ||
file(GLOB LIBS "${APP}/Contents/lib/${lmms}/*.so") | ||
file(GLOB LADSPA "${APP}/Contents/lib/${lmms}/ladspa/*.so") | ||
list(APPEND LIBS ${LADSPA}) | ||
list(APPEND LIBS "${APP}/Contents/MacOS/RemoteZynAddSubFx") | ||
list(SORT LIBS) | ||
|
||
# Construct macdeployqt parameters | ||
foreach(_lib IN LISTS LIBS) | ||
list(APPEND EXECUTABLES "-executable=${_lib}") | ||
endforeach() | ||
|
||
# Call macdeployqt | ||
get_filename_component(QTBIN "${CPACK_QMAKE_EXECUTABLE}" DIRECTORY) | ||
message(STATUS "Calling ${QTBIN}/macdeployqt ${APP} [... executables]") | ||
execute_process(COMMAND "${QTBIN}/macdeployqt" "${APP}" ${EXECUTABLES} | ||
-verbose=${VERBOSITY} | ||
${USE_DEBUG_LIBS} | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
|
||
# Remove dummy carla libs, relink to a sane location (e.g. /Applications/Carla.app/...) | ||
# (must be done after calling macdeployqt) | ||
file(GLOB CARLALIBS "${APP}/Contents/lib/${lmms}/libcarla*") | ||
foreach(_carlalib IN LISTS CARLALIBS) | ||
foreach(_lib "${CPACK_CARLA_LIBRARIES}") | ||
set(_oldpath "../../Frameworks/lib${_lib}.dylib") | ||
set(_newpath "Carla.app/Contents/MacOS/lib${_lib}.dylib") | ||
execute_process(COMMAND install_name_tool -change | ||
"@loader_path/${_oldpath}" | ||
"@executable_path/../../../${_newpath}" | ||
"${_carlalib}" | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
file(REMOVE "${APP}/Contents/Frameworks/lib${_lib}.dylib") | ||
endforeach() | ||
endforeach() | ||
|
||
# Call ad-hoc codesign manually (CMake offers this as well) | ||
execute_process(COMMAND codesign --force --deep --sign - "${APP}" | ||
COMMAND_ECHO ${COMMAND_ECHO} | ||
COMMAND_ERROR_IS_FATAL ANY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"title": "@APPDMG_VOLUME_NAME@", | ||
"background": "@CMAKE_SOURCE_DIR@/cmake/apple/background.png", | ||
"icon-size": 128, | ||
"contents": [ | ||
{ "x": 139, "y": 200, "type": "file", "path": "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/@PROJECT_NAME_UCASE@.app" }, | ||
{ "x": 568, "y": 200, "type": "link", "path": "/Applications" } | ||
] | ||
} |
File renamed without changes
File renamed without changes
Oops, something went wrong.