Browse Source

BUG: Fix issue #7833: Add file extension handling to CPack generated installers for OSXX11 applications. Also modify the X11 test to build such an installer on Mac builds that test CPack and have X11 available. Thanks to Wes Turner for the patch.

David Cole 17 years ago
parent
commit
c647ed54d9

BIN
Modules/CPack.OSXScriptLauncher.in


BIN
Modules/CPack.OSXScriptLauncher.rsrc.in


+ 13 - 0
Modules/CPack.OSXX11.Info.plist.in

@@ -4,6 +4,19 @@
 <dict>
 <dict>
 	<key>CFBundleDevelopmentRegion</key>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>English</string>
 	<string>English</string>
+  <key>CFBundleDocumentTypes</key>
+  <array>
+    <dict>
+      <key>CFBundleTypeExtensions</key>
+      <array>
+        <string>@CPACK_FILE_ASSOCIATION_EXTENSION@</string>
+      </array>
+      <key>CFBundleTypeName</key>
+      <string>@CPACK_FILE_ASSOCIATION_TYPE@</string>
+      <key>CFBundleTypeRole</key>
+      <string>Editor</string>
+    </dict>
+  </array>
 	<key>CFBundleExecutable</key>
 	<key>CFBundleExecutable</key>
 	<string>@CPACK_PACKAGE_FILE_NAME@</string>
 	<string>@CPACK_PACKAGE_FILE_NAME@</string>
 	<key>CFBundleGetInfoString</key>
 	<key>CFBundleGetInfoString</key>

BIN
Modules/CPack.OSXX11.main.scpt.in


+ 21 - 0
Modules/CPack.RuntimeScript.in

@@ -5,6 +5,26 @@
 CWD="`dirname \"$0\"`"
 CWD="`dirname \"$0\"`"
 TMP=/tmp/$UID/TemporaryItems
 TMP=/tmp/$UID/TemporaryItems
 
 
+version=`sw_vers -productVersion`
+if [ "$?" == "0" ]; then
+  major=${version%%\.*}
+  rest=${version#*\.}
+  minor=${rest%%\.*}
+  build=${rest#*\.}
+else
+  major=10
+  minor=4
+  build=0
+fi
+
+echo $version
+echo "Major = $major"
+echo "Minor = $minor"
+echo "Build = $build"
+
+
+# if 10.5 or greater, then all the open-x11 stuff need not occur
+if ((( $major < 10 )) || ((( $major == 10)) && (( $minor < 5 )))); then
 version=`sw_vers -productVersion`
 version=`sw_vers -productVersion`
 if [ "$?" = "0" ]; then
 if [ "$?" = "0" ]; then
   major=${version%%\.*}
   major=${version%%\.*}
@@ -42,6 +62,7 @@ else
     echo \$DISPLAY > "$TMP/display"
     echo \$DISPLAY > "$TMP/display"
 fi
 fi
 __END_OF_GETDISPLAY_SCRIPT__
 __END_OF_GETDISPLAY_SCRIPT__
+fi
 chmod +x "$TMP/getdisplay.sh"
 chmod +x "$TMP/getdisplay.sh"
 rm -f $TMP/display
 rm -f $TMP/display
 open-x11 $TMP/getdisplay.sh || \
 open-x11 $TMP/getdisplay.sh || \

BIN
Source/CPack/OSXLauncherScript.scpt


+ 9 - 0
Source/CPack/cmCPackOSXX11Generator.cxx

@@ -89,10 +89,15 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName,
   std::string contentsDirectory = packageDirFileName + "/Contents";
   std::string contentsDirectory = packageDirFileName + "/Contents";
   std::string resourcesDirectory = contentsDirectory + "/Resources";
   std::string resourcesDirectory = contentsDirectory + "/Resources";
   std::string appDirectory = contentsDirectory + "/MacOS";
   std::string appDirectory = contentsDirectory + "/MacOS";
+  std::string scriptDirectory = resourcesDirectory + "/Scripts";
+  std::string resourceFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+  resourceFileName += ".rsrc";
 
 
   const char* dir = resourcesDirectory.c_str();
   const char* dir = resourcesDirectory.c_str();
   const char* appdir = appDirectory.c_str();
   const char* appdir = appDirectory.c_str();
+  const char* scrDir = scriptDirectory.c_str();
   const char* contDir = contentsDirectory.c_str();
   const char* contDir = contentsDirectory.c_str();
+  const char* rsrcFile = resourceFileName.c_str();
   const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
   const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
   if ( iconFile )
   if ( iconFile )
     {
     {
@@ -124,6 +129,10 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName,
     !this->CopyResourcePlistFile("RuntimeScript", dir) ||
     !this->CopyResourcePlistFile("RuntimeScript", dir) ||
     !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
     !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
       "Info.plist" ) ||
       "Info.plist" ) ||
+    !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir,
+      "main.scpt", true ) ||
+    !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, 
+      rsrcFile, true) ||
     !this->CopyResourcePlistFile("OSXScriptLauncher", appdir, 
     !this->CopyResourcePlistFile("OSXScriptLauncher", appdir, 
       this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
       this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
   )
   )

+ 8 - 1
Tests/CMakeLists.txt

@@ -407,7 +407,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel
     LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents")
     LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents")
   ENDIF(CTEST_RUN_CPackComponents)
   ENDIF(CTEST_RUN_CPackComponents)
 
 
-  ADD_TEST(X11  ${CMAKE_CTEST_COMMAND}
+  IF(CTEST_TEST_CPACK)
+    SET(X11_build_target_arg --build-target package)
+  ELSE(CTEST_TEST_CPACK)
+    SET(X11_build_target_arg)
+  ENDIF(CTEST_TEST_CPACK)
+
+  ADD_TEST(X11 ${CMAKE_CTEST_COMMAND}
     --build-and-test
     --build-and-test
     "${CMake_SOURCE_DIR}/Tests/X11"
     "${CMake_SOURCE_DIR}/Tests/X11"
     "${CMake_BINARY_DIR}/Tests/X11"
     "${CMake_BINARY_DIR}/Tests/X11"
@@ -415,6 +421,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel
     --build-project UseX11
     --build-project UseX11
     --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
     --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
     --build-two-config
     --build-two-config
+    ${X11_build_target_arg}
     --test-command  UseX11)
     --test-command  UseX11)
   LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
   LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
 
 

+ 8 - 3
Tests/X11/CMakeLists.txt

@@ -6,6 +6,7 @@ INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake)
 MESSAGE("X11_FOUND: ${X11_FOUND}")
 MESSAGE("X11_FOUND: ${X11_FOUND}")
 
 
 ADD_EXECUTABLE (UseX11 X11.c)
 ADD_EXECUTABLE (UseX11 X11.c)
+install(TARGETS UseX11 DESTINATION bin)
 
 
 # so for universal binaries this test will fail if 
 # so for universal binaries this test will fail if 
 # 
 # 
@@ -26,10 +27,14 @@ IF(X11_FOUND)
   IF(APPLE)
   IF(APPLE)
     ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx)
     ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx)
     TARGET_LINK_LIBRARIES(HelloWorldX11 ${X11_LIBRARIES})
     TARGET_LINK_LIBRARIES(HelloWorldX11 ${X11_LIBRARIES})
-    install( TARGETS HelloWorldX11 DESTINATION bin)
-    # build a CPack driven installer package
+    install(TARGETS HelloWorldX11 DESTINATION bin)
+
+    set(CPACK_BINARY_OSXX11 "ON")
+    set(CPACK_BINARY_PACKAGEMAKER "OFF")
     set(CPACK_PACKAGE_NAME HelloWorldX11Package)
     set(CPACK_PACKAGE_NAME HelloWorldX11Package)
     set(CPACK_PACKAGE_EXECUTABLES HelloWorldX11 HelloWorldX11)
     set(CPACK_PACKAGE_EXECUTABLES HelloWorldX11 HelloWorldX11)
-    include(CPack)
   ENDIF(APPLE)
   ENDIF(APPLE)
 ENDIF(X11_FOUND)
 ENDIF(X11_FOUND)
+
+# build a CPack driven installer package
+include(CPack)