Просмотр исходного кода

Improve appearance of CMake .dmg package on OS X

Configure our use of the CPack DragNDrop generator to specify a custom
background image and script.
Adam Strzelecki 11 лет назад
Родитель
Сommit
4bca940126
3 измененных файлов с 49 добавлено и 0 удалено
  1. 7 0
      CMakeCPackOptions.cmake.in
  2. BIN
      Packaging/CMakeDMGBackground.tif
  3. 42 0
      Packaging/CMakeDMGSetup.scpt

+ 7 - 0
CMakeCPackOptions.cmake.in

@@ -183,6 +183,13 @@ if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
   endif()
 endif()
 
+if("${CPACK_GENERATOR}" STREQUAL "DragNDrop")
+  set(CPACK_DMG_BACKGROUND_IMAGE
+      "@CMake_SOURCE_DIR@/Packaging/CMakeDMGBackground.tif")
+  set(CPACK_DMG_DS_STORE_SETUP_SCRIPT
+      "@CMake_SOURCE_DIR@/Packaging/CMakeDMGSetup.scpt")
+endif()
+
 if("${CPACK_GENERATOR}" STREQUAL "WIX")
   # Reset CPACK_PACKAGE_VERSION to deal with WiX restriction.
   # But the file names still use the full CMake_VERSION value:

BIN
Packaging/CMakeDMGBackground.tif


+ 42 - 0
Packaging/CMakeDMGSetup.scpt

@@ -0,0 +1,42 @@
+on run argv
+  set image_name to item 1 of argv
+
+  tell application "Finder"
+  tell disk image_name
+
+    -- 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.tif"
+      set arrangement of theViewOptions to not arranged
+      set icon size of theViewOptions to 128
+      delay 1
+    close
+
+    -- next setup the position of the app and Applications symlink
+    -- plus hide all the window decoration
+    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, 100, 900, 465 }
+        set position of item "CMake.app" to { 133, 200 }
+        set position of item "Applications" to { 378, 200 }
+      end tell
+      update without registering applications
+      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