From f2c0dbd164796aabe5397f4a053c22fe76030b80 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 13 Feb 2007 14:13:51 -0500 Subject: ENH: More work on the packaging. Add Applicaitons, add icons, etc --- Modules/CPack.DS_Store.in | Bin 0 -> 12292 bytes Modules/CPack.VolumeIcon.icns.in | Bin 0 -> 45739 bytes Modules/CPack.background.png.in | Bin 0 -> 50482 bytes Modules/CPack.cmake | 3 ++ Source/CPack/cmCPackOSXX11Generator.cxx | 47 +++++++++++++++++++++++++++++++- Source/CPack/cmCPackOSXX11Generator.h | 3 +- 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Modules/CPack.DS_Store.in create mode 100644 Modules/CPack.VolumeIcon.icns.in create mode 100644 Modules/CPack.background.png.in diff --git a/Modules/CPack.DS_Store.in b/Modules/CPack.DS_Store.in new file mode 100644 index 0000000..5be0eeb Binary files /dev/null and b/Modules/CPack.DS_Store.in differ diff --git a/Modules/CPack.VolumeIcon.icns.in b/Modules/CPack.VolumeIcon.icns.in new file mode 100644 index 0000000..c59217e Binary files /dev/null and b/Modules/CPack.VolumeIcon.icns.in differ diff --git a/Modules/CPack.background.png.in b/Modules/CPack.background.png.in new file mode 100644 index 0000000..3fa92b5 Binary files /dev/null and b/Modules/CPack.background.png.in differ diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 50c55a7..7f496aa 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -123,6 +123,9 @@ cpack_set_if_not_set(CPACK_OUTPUT_CONFIG_FILE cpack_set_if_not_set(CPACK_SOURCE_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake") +cpack_set_if_not_set(CPACK_USE_DESTDIR ON) +cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + cpack_encode_variables() CONFIGURE_FILE("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 95e2801..0a63dd3 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -75,7 +75,16 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, } } + // Disk image directories + std::string diskImageDirectory = toplevel; + std::string diskImageBackgroundImageDir + = diskImageDirectory + "/.background"; + + + // App bundle directories std::string packageDirFileName = toplevel; + packageDirFileName += "/"; + packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); packageDirFileName += ".app"; std::string contentsDirectory = packageDirFileName + "/Contents"; std::string resourcesDirectory = contentsDirectory + "/Resources"; @@ -84,7 +93,33 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, const char* dir = resourcesDirectory.c_str(); const char* appdir = appDirectory.c_str(); const char* contDir = contentsDirectory.c_str(); + const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON"); + if ( iconFile ) + { + std::string iconFileName = cmsys::SystemTools::GetFilenameName( + iconFile); + if ( !cmSystemTools::FileExists(iconFile) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: " + << iconFile << ". Please check CPACK_PACKAGE_ICON setting." + << std::endl); + return 0; + } + std::string destFileName = resourcesDirectory + "/" + iconFileName; + this->ConfigureFile(iconFile, destFileName.c_str(), true); + this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str()); + } + + std::string applicationsLinkName = diskImageDirectory + "/Applications"; + cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str()); + if ( + !this->CopyResourcePlistFile("VolumeIcon.icns", diskImageDirectory.c_str(), + ".VolumeIcon.icns", true ) || + !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(), + ".DS_Store", true ) || + !this->CopyResourcePlistFile("background.png", + diskImageBackgroundImageDir.c_str(), "background.png", true ) || !this->CopyResourcePlistFile("RuntimeScript", dir) || !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir, "Info.plist" ) || @@ -102,9 +137,11 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, tmpFile += "/hdiutilOutput.log"; cmOStringStream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") - << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName + << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory.c_str() << "\" \"" << outFileName << "\""; int retVal = 1; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Compress disk image using command: " << dmgCmd.str().c_str() << std::endl); bool res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); if ( !res || retVal ) @@ -218,3 +255,11 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, return true; } +//---------------------------------------------------------------------- +const char* cmCPackOSXX11Generator::GetInstallPrefix() +{ + this->InstallPrefix = "/"; + this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + this->InstallPrefix += ".app/Contents/Resources"; + return this->InstallPrefix.c_str(); +} diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index caa454b..8d9fef5 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -40,12 +40,13 @@ protected: virtual int InitializeInternal(); int CompressFiles(const char* outFileName, const char* toplevel, const std::vector& files); + virtual const char* GetInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } - virtual const char* GetInstallPrefix() { return ".app/Contents/Resources"; } //bool CopyCreateResourceFile(const char* name, const char* dir); bool CopyResourcePlistFile(const char* name, const char* dir, const char* outputFileName = 0, bool copyOnly = false); + std::string InstallPrefix; }; #endif -- cgit v0.12