forked from speed-dreams/speed-dreams-code
WIP for ticket 1047 Automate the Build and Package cycle for MacOS
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6928 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 4f47f101cd9c62184e1469496a0e2bb3eeca6525 Former-commit-id: 8b036490454775236451f00caf9f78684e8d1181
This commit is contained in:
parent
08db1d6975
commit
ccec0ee45f
5 changed files with 194 additions and 4 deletions
|
@ -169,10 +169,14 @@ ENDIF(MSVC)
|
|||
ADD_CUSTOM_TARGET(${_UNINST_TGT_NAME} "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" )
|
||||
|
||||
IF(OPTION_PACKAGING)
|
||||
INCLUDE(cmake/packagemaker.cmake)
|
||||
IF(MSVC)
|
||||
INCLUDE(cmake/packagemaker-nsis.cmake)
|
||||
ENDIF(MSVC)
|
||||
IF(APPLE)
|
||||
INCLUDE(cmake/packagemaker-dmg.cmake)
|
||||
ENDIF(APPLE)
|
||||
ELSE(OPTION_PACKAGING)
|
||||
# Configure CPack.
|
||||
INCLUDE(cmake/packagemaker.cmake)
|
||||
# Configure CPack.
|
||||
INCLUDE(CPack)
|
||||
ENDIF(OPTION_PACKAGING)
|
66
cmake/packagemaker-dmg.cmake
Normal file
66
cmake/packagemaker-dmg.cmake
Normal file
|
@ -0,0 +1,66 @@
|
|||
#==============================================================================
|
||||
#
|
||||
# file : packagemaker-dmg.cmake
|
||||
# copyright : (C) 2020 Joe Thompson
|
||||
# email : beaglejoe@users.sourceforge.net
|
||||
# web : www.speed-dreams.org
|
||||
# version : $Id:$
|
||||
#
|
||||
#==============================================================================
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#==============================================================================
|
||||
|
||||
IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$"))
|
||||
|
||||
MESSAGE(STATUS "TODO - need to clean this up.")
|
||||
#ADD_CUSTOM_TARGET(package_base DEPENDS install)
|
||||
# can't depend on built-in target install, so we ADD_CUSTOM_COMMAND
|
||||
# below to make sure install is done
|
||||
ADD_CUSTOM_TARGET(packing_install)
|
||||
|
||||
#[[
|
||||
ADD_CUSTOM_TARGET(package_all DEPENDS package_base
|
||||
package_full)
|
||||
|
||||
ADD_CUSTOM_TARGET(package_base DEPENDS packing_install)
|
||||
ADD_CUSTOM_TARGET(package_full DEPENDS packing_install)
|
||||
]]
|
||||
|
||||
ADD_CUSTOM_TARGET(package_full)
|
||||
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET packing_install
|
||||
COMMAND "${CMAKE_COMMAND}" --build . --target install --config $<CONFIG>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Building install...")
|
||||
#[[
|
||||
ADD_CUSTOM_COMMAND(TARGET package_base
|
||||
COMMAND ${CMAKE_CPACK_COMMAND} -G "DragNDrop"--config ../CPackDMGBaseConfig.cmake
|
||||
WORKING_DIRECTORY packaging
|
||||
COMMENT "Building base package...")
|
||||
]]
|
||||
|
||||
# COMMAND ${CMAKE_CPACK_COMMAND} -G "DragNDrop" --config ../CPackDMGFullConfig.cmake
|
||||
ADD_CUSTOM_COMMAND(TARGET package_full
|
||||
COMMAND "${CMAKE_COMMAND}" -P packagefulldmg.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Building full package...")
|
||||
|
||||
|
||||
|
||||
ELSE((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$"))
|
||||
MESSAGE(WARNING "Custom DMG creation requires *.app")
|
||||
ENDIF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$"))
|
|
@ -1,6 +1,14 @@
|
|||
##########################################################################################
|
||||
# Settings that are common to all target systems.
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
SET(CPACK_SYSTEM_NAME "win32")
|
||||
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(CPACK_SYSTEM_NAME "macos")
|
||||
ELSE()
|
||||
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
|
||||
ENDIF()
|
||||
|
||||
SET(INTERNAL_NAME "speed-dreams")
|
||||
|
||||
SET(CPACK_PACKAGE_NAME "Speed Dreams")
|
||||
|
@ -88,7 +96,7 @@ IF(WIN32)
|
|||
SET(PACKAGERS_SOURCE "ZIP" CACHE STRING "CPack source package generators to use (separated with ';', among TGZ, TBZ2, TZ, ZIP)")
|
||||
MARK_AS_ADVANCED(PACKAGERS_SOURCE)
|
||||
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_PREFIX}-${CPACK_PACKAGE_VERSION}-win32-setup")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_PREFIX}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-setup")
|
||||
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
|
||||
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_DISPLAY_NAME}")
|
||||
|
||||
|
@ -152,6 +160,20 @@ IF(APPLE)
|
|||
SET(CPACK_INSTALLED_DIRECTORIES "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX};${CMAKE_INSTALL_PREFIX}")
|
||||
SET(CPACK_INSTALL_CMAKE_PROJECTS "")
|
||||
SET(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/packaging/OSX/DS_Store-full")
|
||||
|
||||
# TODO use ${CPACK_PACKAGE_NAME} ${VERSION}" ??
|
||||
SET(DMG_VOL_NAME "Speed Dreams ${VERSION}")
|
||||
SET(CPACK_DMG_VOLUME_NAME "${DMG_VOL_NAME}")
|
||||
|
||||
SET(READ_WRITE_DMG_NAME "${INTERNAL_NAME}-${VERSION}-r${SVN_REV}-${CPACK_SYSTEM_NAME}-rw.dmg")
|
||||
SET(READ_ONLY_DMG_NAME "${INTERNAL_NAME}-${VERSION}-r${SVN_REV}-${CPACK_SYSTEM_NAME}.dmg")
|
||||
SET(SD_BUNDLE_NAME "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/packaging/OSX/packagefulldmg.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/packagefulldmg.cmake" @ONLY)
|
||||
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/packaging/OSX/findersettings.scpt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/findersettings.scpt" @ONLY)
|
||||
|
||||
ENDIF(APPLE)
|
||||
|
||||
|
@ -160,4 +182,4 @@ ENDIF(APPLE)
|
|||
SET(CPACK_GENERATOR ${PACKAGERS_BINARY})
|
||||
SET(CPACK_SOURCE_GENERATOR ${PACKAGERS_SOURCE})
|
||||
|
||||
INCLUDE(CPack)
|
||||
#INCLUDE(CPack)
|
||||
|
|
34
packaging/OSX/findersettings.scpt.in
Normal file
34
packaging/OSX/findersettings.scpt.in
Normal file
|
@ -0,0 +1,34 @@
|
|||
#==============================================================================
|
||||
#
|
||||
# Generated AppleScript file for setting the background image,
|
||||
# 'Finder' window options, and position of icons
|
||||
#
|
||||
#==============================================================================
|
||||
|
||||
tell application "Finder"
|
||||
tell disk "@DMG_VOL_NAME@"
|
||||
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 ".installer-mac-bg-22.png"
|
||||
set arrangement of theViewOptions to not arranged
|
||||
set icon size of theViewOptions to 128
|
||||
delay 5
|
||||
close
|
||||
|
||||
open
|
||||
update without registering applications
|
||||
tell container window
|
||||
set sidebar width to 0
|
||||
set statusbar visible to false
|
||||
set toolbar visible to false
|
||||
set the bounds to {400, 200, 1120, 665}
|
||||
set position of item "@SD_BUNDLE_NAME@" to {229, 292}
|
||||
set position of item "Applications" to {458, 292}
|
||||
end tell
|
||||
update without registering applications
|
||||
delay 5
|
||||
close
|
||||
end tell
|
||||
delay 1
|
||||
end tell
|
64
packaging/OSX/packagefulldmg.cmake.in
Normal file
64
packaging/OSX/packagefulldmg.cmake.in
Normal file
|
@ -0,0 +1,64 @@
|
|||
#==============================================================================
|
||||
#
|
||||
# Generated Script file for creating the DMG file
|
||||
# Apple only
|
||||
#
|
||||
#==============================================================================
|
||||
|
||||
set(_result )
|
||||
message(STATUS "Creating read/write dmg...")
|
||||
execute_process(COMMAND hdiutil create "./@READ_WRITE_DMG_NAME@" -volname "@DMG_VOL_NAME@" -size 4g -fs HFS+
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of hdiutil create = ${_result}")
|
||||
|
||||
message(STATUS "Attaching read/write dmg...")
|
||||
execute_process(COMMAND hdiutil attach "./@READ_WRITE_DMG_NAME@" -nobrowse
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of hdiutil attach = ${_result}")
|
||||
|
||||
|
||||
# Copy the background image (renaming NOTE the leading . in target name)
|
||||
message(STATUS "Copying installer-mac-bg-22.png...")
|
||||
execute_process(COMMAND cp "@CMAKE_SOURCE_DIR@/packaging/OSX/installer-mac-bg-22.png" "/Volumes/@DMG_VOL_NAME@/.installer-mac-bg-22.png"
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of copying installer-mac-bg-22.png = ${_result}")
|
||||
|
||||
# Create a link to Applications folder
|
||||
message(STATUS "Creating link to Applications...")
|
||||
execute_process(COMMAND ln -s /Applications "/Volumes/@DMG_VOL_NAME@/Applications"
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of creating link to Applications = ${_result}")
|
||||
|
||||
# Copy the whole .app folder recursively
|
||||
message(STATUS "Copying the @SD_BUNDLE_NAME@ folder...")
|
||||
execute_process(COMMAND cp -r "@SD_BUNDLE_NAME@/" "/Volumes/@DMG_VOL_NAME@/@SD_BUNDLE_NAME@"
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of copying the @SD_BUNDLE_NAME@ folder = ${_result}")
|
||||
|
||||
# run the generated 'Finder' script
|
||||
message(STATUS "Running the generated 'Finder' script...")
|
||||
execute_process(COMMAND osascript findersettings.scpt
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of running the generated 'Finder' script = ${_result}")
|
||||
|
||||
|
||||
message(STATUS "Detaching read/write dmg...")
|
||||
execute_process(COMMAND hdiutil detach "/Volumes/@DMG_VOL_NAME@/"
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of hdiutil detach = ${_result}")
|
||||
|
||||
|
||||
# create the Read only version
|
||||
message(STATUS "converting read/write dmg to read-only...")
|
||||
execute_process(COMMAND hdiutil convert "./@READ_WRITE_DMG_NAME@" -format UDZO -imagekey zlib-level=9 -o "./@READ_ONLY_DMG_NAME@"
|
||||
RESULT_VARIABLE _result
|
||||
COMMAND_ECHO STDOUT )
|
||||
message(STATUS "Result of hdiutil convert = ${_result}")
|
||||
|
Loading…
Reference in a new issue