From c647ed54d9c071393e95b204aac2bb975ec95fe9 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 21 Jan 2009 11:54:30 -0500 Subject: 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. --- Modules/CPack.OSXScriptLauncher.in | Bin 1345804 -> 29592 bytes Modules/CPack.OSXScriptLauncher.rsrc.in | Bin 0 -> 362 bytes Modules/CPack.OSXX11.Info.plist.in | 13 +++++++++++++ Modules/CPack.OSXX11.main.scpt.in | Bin 0 -> 1870 bytes Modules/CPack.RuntimeScript.in | 21 +++++++++++++++++++++ Source/CPack/OSXLauncherScript.scpt | Bin 0 -> 3102 bytes Source/CPack/cmCPackOSXX11Generator.cxx | 9 +++++++++ Tests/CMakeLists.txt | 9 ++++++++- Tests/X11/CMakeLists.txt | 11 ++++++++--- 9 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 Modules/CPack.OSXScriptLauncher.rsrc.in create mode 100644 Modules/CPack.OSXX11.main.scpt.in create mode 100644 Source/CPack/OSXLauncherScript.scpt diff --git a/Modules/CPack.OSXScriptLauncher.in b/Modules/CPack.OSXScriptLauncher.in index a3e1737..c715860 100755 Binary files a/Modules/CPack.OSXScriptLauncher.in and b/Modules/CPack.OSXScriptLauncher.in differ diff --git a/Modules/CPack.OSXScriptLauncher.rsrc.in b/Modules/CPack.OSXScriptLauncher.rsrc.in new file mode 100644 index 0000000..5f5f17a Binary files /dev/null and b/Modules/CPack.OSXScriptLauncher.rsrc.in differ diff --git a/Modules/CPack.OSXX11.Info.plist.in b/Modules/CPack.OSXX11.Info.plist.in index 30ce2de..851b67b 100644 --- a/Modules/CPack.OSXX11.Info.plist.in +++ b/Modules/CPack.OSXX11.Info.plist.in @@ -4,6 +4,19 @@ CFBundleDevelopmentRegion English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + @CPACK_FILE_ASSOCIATION_EXTENSION@ + + CFBundleTypeName + @CPACK_FILE_ASSOCIATION_TYPE@ + CFBundleTypeRole + Editor + + CFBundleExecutable @CPACK_PACKAGE_FILE_NAME@ CFBundleGetInfoString diff --git a/Modules/CPack.OSXX11.main.scpt.in b/Modules/CPack.OSXX11.main.scpt.in new file mode 100644 index 0000000..de30ea1 Binary files /dev/null and b/Modules/CPack.OSXX11.main.scpt.in differ diff --git a/Modules/CPack.RuntimeScript.in b/Modules/CPack.RuntimeScript.in index 72dd14e..eaecdd8 100755 --- a/Modules/CPack.RuntimeScript.in +++ b/Modules/CPack.RuntimeScript.in @@ -6,6 +6,26 @@ CWD="`dirname \"$0\"`" 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` if [ "$?" = "0" ]; then major=${version%%\.*} rest=${version#*\.} @@ -42,6 +62,7 @@ else echo \$DISPLAY > "$TMP/display" fi __END_OF_GETDISPLAY_SCRIPT__ +fi chmod +x "$TMP/getdisplay.sh" rm -f $TMP/display open-x11 $TMP/getdisplay.sh || \ diff --git a/Source/CPack/OSXLauncherScript.scpt b/Source/CPack/OSXLauncherScript.scpt new file mode 100644 index 0000000..342cf8c Binary files /dev/null and b/Source/CPack/OSXLauncherScript.scpt differ diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 6d04b6e..ba4ad22 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -89,10 +89,15 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, std::string contentsDirectory = packageDirFileName + "/Contents"; std::string resourcesDirectory = contentsDirectory + "/Resources"; 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* appdir = appDirectory.c_str(); + const char* scrDir = scriptDirectory.c_str(); const char* contDir = contentsDirectory.c_str(); + const char* rsrcFile = resourceFileName.c_str(); const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON"); if ( iconFile ) { @@ -124,6 +129,10 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, !this->CopyResourcePlistFile("RuntimeScript", dir) || !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir, "Info.plist" ) || + !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, + "main.scpt", true ) || + !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, + rsrcFile, true) || !this->CopyResourcePlistFile("OSXScriptLauncher", appdir, this->GetOption("CPACK_PACKAGE_FILE_NAME"), true) ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ca87201..9e59660 100644 --- a/Tests/CMakeLists.txt +++ b/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") 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 "${CMake_SOURCE_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-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config + ${X11_build_target_arg} --test-command UseX11) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11") diff --git a/Tests/X11/CMakeLists.txt b/Tests/X11/CMakeLists.txt index 52f4a6f..cc24464 100644 --- a/Tests/X11/CMakeLists.txt +++ b/Tests/X11/CMakeLists.txt @@ -6,6 +6,7 @@ INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake) MESSAGE("X11_FOUND: ${X11_FOUND}") ADD_EXECUTABLE (UseX11 X11.c) +install(TARGETS UseX11 DESTINATION bin) # so for universal binaries this test will fail if # @@ -26,10 +27,14 @@ IF(X11_FOUND) IF(APPLE) ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx) 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_EXECUTABLES HelloWorldX11 HelloWorldX11) - include(CPack) ENDIF(APPLE) ENDIF(X11_FOUND) + +# build a CPack driven installer package +include(CPack) -- cgit v0.12