Attached Files | bundle_generator.patch [^] (16,304 bytes) 2008-06-06 11:38 [Show Content] [Hide Content]? bundle_generator.patch
Index: Modules/CPack.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CPack.cmake,v
retrieving revision 1.37
diff -u -r1.37 CPack.cmake
--- Modules/CPack.cmake 17 Apr 2008 21:23:21 -0000 1.37
+++ Modules/CPack.cmake 6 Jun 2008 06:16:13 -0000
@@ -114,6 +114,7 @@
option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
else(CYGWIN)
if(APPLE)
+ option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
else(APPLE)
@@ -131,6 +132,7 @@
option(CPACK_BINARY_ZIP "Enable to build ZIP packages" ON)
endif(UNIX)
+ cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
@@ -171,7 +173,7 @@
mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11
CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2
CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ
- CPACK_BINARY_NSIS CPACK_BINARY_ZIP
+ CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE
CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ
CPACK_SOURCE_TZ CPACK_SOURCE_ZIP)
Index: Source/CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
retrieving revision 1.398
diff -u -r1.398 CMakeLists.txt
--- Source/CMakeLists.txt 28 Mar 2008 17:22:43 -0000 1.398
+++ Source/CMakeLists.txt 6 Jun 2008 06:16:13 -0000
@@ -374,6 +374,7 @@
IF(APPLE)
SET(CPACK_SRCS ${CPACK_SRCS}
+ CPack/cmCPackBundleGenerator.cxx
CPack/cmCPackOSXX11Generator.cxx
CPack/cmCPackPackageMakerGenerator.cxx
)
Index: Source/CPack/cmCPackBundleGenerator.cxx
===================================================================
RCS file: Source/CPack/cmCPackBundleGenerator.cxx
diff -N Source/CPack/cmCPackBundleGenerator.cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Source/CPack/cmCPackBundleGenerator.cxx 6 Jun 2008 06:16:14 -0000
@@ -0,0 +1,280 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile: cmCPackBundleGenerator.cxx,v $
+ Language: C++
+ Date: $Date: 2007/10/31 12:50:17 $
+ Version: $Revision: 1.5 $
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "cmCPackBundleGenerator.h"
+#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+
+//----------------------------------------------------------------------
+cmCPackBundleGenerator::cmCPackBundleGenerator()
+{
+}
+
+//----------------------------------------------------------------------
+cmCPackBundleGenerator::~cmCPackBundleGenerator()
+{
+}
+
+//----------------------------------------------------------------------
+int cmCPackBundleGenerator::InitializeInternal()
+{
+ const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
+ if(hdiutil_path.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command" << std::endl);
+ return 0;
+ }
+ this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
+
+ const std::string setfile_path = cmSystemTools::FindProgram("SetFile", std::vector<std::string>(1, "/Developer/Tools"), false);
+ if(setfile_path.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command" << std::endl);
+ return 0;
+ }
+ this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
+
+ return this->Superclass::InitializeInternal();
+}
+
+//----------------------------------------------------------------------
+const char* cmCPackBundleGenerator::GetOutputExtension()
+{
+ return ".dmg";
+}
+
+//----------------------------------------------------------------------
+const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
+{
+ this->InstallPrefix = "/";
+ this->InstallPrefix += this->GetOption("CPACK_BUNDLE_NAME");
+ this->InstallPrefix += ".app/Contents/Resources";
+
+ return this->InstallPrefix.c_str();
+}
+
+//----------------------------------------------------------------------
+int cmCPackBundleGenerator::CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files)
+{
+ // The staging directory contains everything that will end-up inside the final disk image ...
+ cmOStringStream staging;
+ staging << toplevel;
+
+ cmOStringStream contents;
+ contents << staging.str() << "/" << this->GetOption("CPACK_BUNDLE_NAME") << ".app/" << "Contents";
+
+ cmOStringStream application;
+ application << contents.str() << "/" << "MacOS";
+
+ cmOStringStream resources;
+ resources << contents.str() << "/" << "Resources";
+
+ // Install a user-provided bundle metadata file ...
+ if(this->GetOption("CPACK_BUNDLE_PLIST"))
+ {
+ cmOStringStream plist_source;
+ plist_source << this->GetOption("CPACK_BUNDLE_PLIST");
+
+ cmOStringStream plist_target;
+ plist_target << contents.str() << "/" << "Info.plist";
+
+ if(!this->CopyFile(plist_source, plist_target))
+ return 0;
+ }
+
+ // Install a user-provided bundle icon ...
+ if(this->GetOption("CPACK_BUNDLE_ICON"))
+ {
+ cmOStringStream icon_source;
+ icon_source << this->GetOption("CPACK_BUNDLE_ICON");
+
+ cmOStringStream icon_target;
+ icon_target << resources.str() << "/" << this->GetOption("CPACK_BUNDLE_NAME") << ".icns";
+
+ if(!this->CopyFile(icon_source, icon_target))
+ return 0;
+ }
+
+ // Install a user-provided startup command (could be an executable or a script) ...
+ if(this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND"))
+ {
+ cmOStringStream command_source;
+ command_source << this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND");
+
+ cmOStringStream command_target;
+ command_target << application.str() << "/" << this->GetOption("CPACK_BUNDLE_NAME");
+
+ if(!this->CopyFile(command_source, command_target))
+ return 0;
+
+ cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
+ }
+
+ // Add a symlink to /Applications so users can drag-and-drop the bundle into it
+ cmOStringStream application_link;
+ application_link << staging.str() << "/Applications";
+ cmSystemTools::CreateSymlink("/Applications", application_link.str().c_str());
+
+ // Optionally add a custom volume icon ...
+ if(this->GetOption("CPACK_PACKAGE_ICON"))
+ {
+ cmOStringStream package_icon_source;
+ package_icon_source << this->GetOption("CPACK_PACKAGE_ICON");
+
+ cmOStringStream package_icon_destination;
+ package_icon_destination << staging.str() << "/.VolumeIcon.icns";
+
+ if(!this->CopyFile(package_icon_source, package_icon_destination))
+ return 0;
+ }
+
+ // Create a temporary read-write disk image ...
+ cmOStringStream temp_image;
+ temp_image << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/temp.dmg";
+
+ cmOStringStream temp_image_command;
+ temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
+ temp_image_command << " create";
+ temp_image_command << " -ov";
+ temp_image_command << " -srcfolder \"" << staging.str() << "\"";
+ temp_image_command << " -volname \"" << this->GetOption("CPACK_PACKAGE_FILE_NAME") << "\"";
+ temp_image_command << " -format UDRW";
+ temp_image_command << " \"" << temp_image.str() << "\"";
+
+ if(!this->RunCommand(temp_image_command))
+ return 0;
+
+ // Optionally set the custom icon flag for the image ...
+ if(this->GetOption("CPACK_PACKAGE_ICON"))
+ {
+ cmOStringStream temp_mount;
+ temp_mount << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/mnt";
+ cmSystemTools::MakeDirectory(temp_mount.str().c_str());
+
+ cmOStringStream attach_command;
+ attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
+ attach_command << " attach";
+ attach_command << " -mountpoint \"" << temp_mount.str() << "\"";
+ attach_command << " \"" << temp_image.str() << "\"";
+
+ if(!this->RunCommand(attach_command))
+ return 0;
+
+ cmOStringStream setfile_command;
+ setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
+ setfile_command << " -a C";
+ setfile_command << " \"" << temp_mount.str() << "\"";
+
+ if(!this->RunCommand(setfile_command))
+ return 0;
+
+ cmOStringStream detach_command;
+ detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
+ detach_command << " detach";
+ detach_command << " \"" << temp_mount.str() << "\"";
+
+ if(!this->RunCommand(detach_command))
+ return 0;
+ }
+
+ // Create the final compressed read-only disk image ...
+ cmOStringStream final_image_command;
+ final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
+ final_image_command << " convert \"" << temp_image.str() << "\"";
+ final_image_command << " -format UDZO";
+ final_image_command << " -imagekey";
+ final_image_command << " zlib-level=9";
+ final_image_command << " -o \"" << outFileName << "\"";
+
+ if(!this->RunCommand(final_image_command))
+ return 0;
+
+/*
+ // 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";
+ std::string appDirectory = contentsDirectory + "/MacOS";
+
+ 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());
+ }
+
+ 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("Bundle.Info.plist", contDir,
+ "Info.plist" ) ||
+ !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
+ )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
+ << std::endl);
+ return 0;
+ }
+*/
+
+ return 1;
+}
+
+bool cmCPackBundleGenerator::CopyFile(cmOStringStream& source, cmOStringStream& target)
+{
+ return cmSystemTools::CopyFileIfDifferent(source.str().c_str(), target.str().c_str());
+}
+
+bool cmCPackBundleGenerator::RunCommand(cmOStringStream& command)
+{
+ std::string output;
+ int exit_code = 1;
+
+ bool result = cmSystemTools::RunSingleCommand(command.str().c_str(), &output, &exit_code, 0, this->GeneratorVerbose, 0);
+ if(!result || exit_code)
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running command: " << command.str().c_str() << std::endl);
+ return false;
+ }
+
+ return true;
+}
+
Index: Source/CPack/cmCPackBundleGenerator.h
===================================================================
RCS file: Source/CPack/cmCPackBundleGenerator.h
diff -N Source/CPack/cmCPackBundleGenerator.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Source/CPack/cmCPackBundleGenerator.h 6 Jun 2008 06:16:14 -0000
@@ -0,0 +1,49 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile: cmCPackBundleGenerator.h,v $
+ Language: C++
+ Date: $Date: 2007/11/05 21:55:45 $
+ Version: $Revision: 1.5 $
+
+ Copyright (c) 2002 Kitware, Inc. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef cmCPackBundleGenerator_h
+#define cmCPackBundleGenerator_h
+
+#include "cmCPackGenerator.h"
+
+/** \class cmCPackBundleGenerator
+ * \brief A generator for OSX bundles
+ *
+ * Based on Gimp.app
+ */
+class cmCPackBundleGenerator : public cmCPackGenerator
+{
+public:
+ cmCPackTypeMacro(cmCPackBundleGenerator, cmCPackGenerator);
+
+ cmCPackBundleGenerator();
+ virtual ~cmCPackBundleGenerator();
+
+protected:
+ virtual int InitializeInternal();
+ virtual const char* GetOutputExtension();
+ virtual const char* GetPackagingInstallPrefix();
+ int CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files);
+
+ bool CopyFile(cmOStringStream& source, cmOStringStream& target);
+ bool RunCommand(cmOStringStream& command);
+
+ std::string InstallPrefix;
+};
+
+#endif
+
Index: Source/CPack/cmCPackGeneratorFactory.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackGeneratorFactory.cxx,v
retrieving revision 1.2
diff -u -r1.2 cmCPackGeneratorFactory.cxx
--- Source/CPack/cmCPackGeneratorFactory.cxx 5 Nov 2007 21:55:45 -0000 1.2
+++ Source/CPack/cmCPackGeneratorFactory.cxx 6 Jun 2008 06:16:14 -0000
@@ -3,7 +3,7 @@
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmCPackGeneratorFactory.cxx,v $
Language: C++
- Date: $Date: 2007-11-05 21:55:45 $
+ Date: $Date: 2007/11/05 21:55:45 $
Version: $Revision: 1.2 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
@@ -25,6 +25,7 @@
#include "cmCPackSTGZGenerator.h"
#include "cmCPackNSISGenerator.h"
#ifdef __APPLE__
+# include "cmCPackBundleGenerator.h"
# include "cmCPackPackageMakerGenerator.h"
# include "cmCPackOSXX11Generator.h"
#endif
@@ -66,6 +67,8 @@
this->RegisterGenerator("TZ", "Tar Compress compression",
cmCPackTarCompressGenerator::CreateGenerator);
#ifdef __APPLE__
+ this->RegisterGenerator("Bundle", "Mac OSX bundle",
+ cmCPackBundleGenerator::CreateGenerator);
this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer",
cmCPackPackageMakerGenerator::CreateGenerator);
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
bundle_generator_2.patch [^] (11,445 bytes) 2008-07-10 16:41 [Show Content] [Hide Content]? bundle_generator_2.patch
? bundle_generator_update.patch
? Source/CPack/.cmCPackBundleGenerator.cxx.swp
Index: Source/CPack/cmCPackBundleGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackBundleGenerator.cxx,v
retrieving revision 1.2
diff -u -r1.2 cmCPackBundleGenerator.cxx
--- Source/CPack/cmCPackBundleGenerator.cxx 19 Jun 2008 10:17:01 -0000 1.2
+++ Source/CPack/cmCPackBundleGenerator.cxx 10 Jul 2008 20:40:47 -0000
@@ -36,7 +36,8 @@
std::vector<std::string>(), false);
if(hdiutil_path.empty())
{
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate hdiutil command"
<< std::endl);
return 0;
}
@@ -46,7 +47,8 @@
std::vector<std::string>(1, "/Developer/Tools"), false);
if(setfile_path.empty())
{
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate SetFile command"
<< std::endl);
return 0;
}
@@ -77,13 +79,57 @@
{
(void) files;
+ // Get required arguments ...
+ const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") ? this->GetOption("CPACK_BUNDLE_NAME") : "";
+ if(cpack_bundle_name.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_NAME must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST") ? this->GetOption("CPACK_BUNDLE_PLIST") : "";
+ if(cpack_bundle_plist.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_PLIST must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON") ? this->GetOption("CPACK_BUNDLE_ICON") : "";
+ if(cpack_bundle_icon.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_ICON must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_startup_command = this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : "";
+ if(cpack_bundle_startup_command.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_STARTUP_COMMAND must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ // Get optional arguments ...
+ const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") ? this->GetOption("CPACK_PACKAGE_ICON") : "";
+
// The staging directory contains everything that will end-up inside the
// final disk image ...
cmOStringStream staging;
staging << toplevel;
cmOStringStream contents;
- contents << staging.str() << "/" << this->GetOption("CPACK_BUNDLE_NAME")
+ contents << staging.str() << "/" << cpack_bundle_name
<< ".app/" << "Contents";
cmOStringStream application;
@@ -92,56 +138,57 @@
cmOStringStream resources;
resources << contents.str() << "/" << "Resources";
- // Install a user-provided bundle metadata file ...
- if(this->GetOption("CPACK_BUNDLE_PLIST"))
- {
- cmOStringStream plist_source;
- plist_source << this->GetOption("CPACK_BUNDLE_PLIST");
+ // Install a required, user-provided bundle metadata file ...
+ cmOStringStream plist_source;
+ plist_source << cpack_bundle_plist;
- cmOStringStream plist_target;
- plist_target << contents.str() << "/" << "Info.plist";
+ cmOStringStream plist_target;
+ plist_target << contents.str() << "/" << "Info.plist";
- if(!this->CopyFile(plist_source, plist_target))
- {
- return 0;
- }
+ if(!this->CopyFile(plist_source, plist_target))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying plist. Check the value of CPACK_BUNDLE_PLIST."
+ << std::endl);
+
+ return 0;
}
// Install a user-provided bundle icon ...
- if(this->GetOption("CPACK_BUNDLE_ICON"))
- {
- cmOStringStream icon_source;
- icon_source << this->GetOption("CPACK_BUNDLE_ICON");
+ cmOStringStream icon_source;
+ icon_source << cpack_bundle_icon;
- cmOStringStream icon_target;
- icon_target << resources.str() << "/"
- << this->GetOption("CPACK_BUNDLE_NAME") << ".icns";
+ cmOStringStream icon_target;
+ icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
- if(!this->CopyFile(icon_source, icon_target))
- {
- return 0;
- }
+ if(!this->CopyFile(icon_source, icon_target))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON."
+ << std::endl);
+
+ return 0;
}
// Install a user-provided startup command (could be an executable or a
// script) ...
- if(this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND"))
- {
- cmOStringStream command_source;
- command_source << this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND");
+ cmOStringStream command_source;
+ command_source << cpack_bundle_startup_command;
- cmOStringStream command_target;
- command_target << application.str() << "/"
- << this->GetOption("CPACK_BUNDLE_NAME");
+ cmOStringStream command_target;
+ command_target << application.str() << "/" << cpack_bundle_name;
- if(!this->CopyFile(command_source, command_target))
- {
- return 0;
- }
+ if(!this->CopyFile(command_source, command_target))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying startup command. Check the value of CPACK_BUNDLE_STARTUP_COMMAND."
+ << std::endl);
- cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
+ return 0;
}
+ cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
+
// Add a symlink to /Applications so users can drag-and-drop the bundle
// into it
cmOStringStream application_link;
@@ -150,16 +197,20 @@
application_link.str().c_str());
// Optionally add a custom volume icon ...
- if(this->GetOption("CPACK_PACKAGE_ICON"))
+ if(!cpack_package_icon.empty())
{
cmOStringStream package_icon_source;
- package_icon_source << this->GetOption("CPACK_PACKAGE_ICON");
+ package_icon_source << cpack_package_icon;
cmOStringStream package_icon_destination;
package_icon_destination << staging.str() << "/.VolumeIcon.icns";
if(!this->CopyFile(package_icon_source, package_icon_destination))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying disk volume icon. Check the value of CPACK_PACKAGE_ICON."
+ << std::endl);
+
return 0;
}
}
@@ -180,11 +231,15 @@
if(!this->RunCommand(temp_image_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error generating temporary disk image."
+ << std::endl);
+
return 0;
}
// Optionally set the custom icon flag for the image ...
- if(this->GetOption("CPACK_PACKAGE_ICON"))
+ if(!cpack_package_icon.empty())
{
cmOStringStream temp_mount;
temp_mount << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/mnt";
@@ -198,6 +253,10 @@
if(!this->RunCommand(attach_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error attaching temporary disk image."
+ << std::endl);
+
return 0;
}
@@ -208,6 +267,10 @@
if(!this->RunCommand(setfile_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error assigning custom icon to temporary disk image."
+ << std::endl);
+
return 0;
}
@@ -218,6 +281,10 @@
if(!this->RunCommand(detach_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error detaching temporary disk image."
+ << std::endl);
+
return 0;
}
}
@@ -233,63 +300,12 @@
if(!this->RunCommand(final_image_command))
{
- return 0;
- }
-
-/*
- // 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";
- std::string appDirectory = contentsDirectory + "/MacOS";
-
- 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());
- }
-
- 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("Bundle.Info.plist", contDir,
- "Info.plist" ) ||
- !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
- this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
- )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error compressing disk image."
<< std::endl);
+
return 0;
}
-*/
return 1;
}
@@ -298,8 +314,21 @@
bool cmCPackBundleGenerator::CopyFile(cmOStringStream& source,
cmOStringStream& target)
{
- return cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
- target.str().c_str());
+ if(!cmSystemTools::CopyFileIfDifferent(
+ source.str().c_str(),
+ target.str().c_str()))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying "
+ << source.str()
+ << " to "
+ << target.str()
+ << std::endl);
+
+ return false;
+ }
+
+ return true;
}
//----------------------------------------------------------------------
@@ -308,12 +337,21 @@
std::string output;
int exit_code = 1;
- bool result = cmSystemTools::RunSingleCommand(command.str().c_str(),
- &output, &exit_code, 0, this->GeneratorVerbose, 0);
+ bool result = cmSystemTools::RunSingleCommand(
+ command.str().c_str(),
+ &output,
+ &exit_code,
+ 0,
+ this->GeneratorVerbose,
+ 0);
+
if(!result || exit_code)
{
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running command: "
- << command.str().c_str() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error executing: "
+ << command.str()
+ << std::endl);
+
return false;
}
bundle_generator_test.patch [^] (5,290 bytes) 2008-07-28 19:29 [Show Content] [Hide Content]? bundle_generator_test.patch
? Tests/BundleGeneratorTest/BundleIcon.icns
Index: Tests/CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CMakeLists.txt,v
retrieving revision 1.59
diff -u -8 -r1.59 CMakeLists.txt
--- Tests/CMakeLists.txt 7 Jul 2008 19:07:54 -0000 1.59
+++ Tests/CMakeLists.txt 28 Jul 2008 23:29:22 -0000
@@ -704,16 +704,29 @@
--build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
"-DCMake_SOURCE_DIR:PATH=${CMAKE_SOURCE_DIR}"
--test-command
${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
ADD_TEST_MACRO(ObjC++ ObjC++)
ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX)
+ IF (APPLE)
+ ADD_TEST(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
+ "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
+ --build-two-config
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-target package
+ --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
+ )
+ ENDIF(APPLE)
+
IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS)
CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
ADD_TEST(CTestTest ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
)
CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
Index: Tests/BundleGeneratorTest/CMakeLists.txt
===================================================================
RCS file: Tests/BundleGeneratorTest/CMakeLists.txt
diff -N Tests/BundleGeneratorTest/CMakeLists.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tests/BundleGeneratorTest/CMakeLists.txt 28 Jul 2008 23:29:22 -0000
@@ -0,0 +1,24 @@
+PROJECT(BundleGeneratorTest)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.7)
+
+# Build a shared library and install it in lib/
+ADD_LIBRARY(Library SHARED Library.cxx)
+INSTALL(TARGETS Library DESTINATION lib)
+
+# Build an executable and install it in bin/
+ADD_EXECUTABLE(Executable Executable.cxx)
+TARGET_LINK_LIBRARIES(Executable Library)
+INSTALL(TARGETS Executable DESTINATION bin)
+
+# Use the bundle-generator for packaging ...
+SET(CPACK_GENERATOR "Bundle")
+SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/BundleIcon.icns")
+SET(CPACK_BUNDLE_NAME "BundleGeneratorTest")
+SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
+SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand")
+SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation")
+SET(CPACK_PACKAGE_NAME "BundleGeneratorTest")
+SET(CPACK_PACKAGE_VERSION "0.1")
+INCLUDE(CPack)
+
Index: Tests/BundleGeneratorTest/Executable.cxx
===================================================================
RCS file: Tests/BundleGeneratorTest/Executable.cxx
diff -N Tests/BundleGeneratorTest/Executable.cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tests/BundleGeneratorTest/Executable.cxx 28 Jul 2008 23:29:22 -0000
@@ -0,0 +1,8 @@
+extern void print_message(const char* const Message);
+
+int main(int argc, char* argv[])
+{
+ print_message("Howdy, World!\n");
+ return 0;
+}
+
Index: Tests/BundleGeneratorTest/Info.plist
===================================================================
RCS file: Tests/BundleGeneratorTest/Info.plist
diff -N Tests/BundleGeneratorTest/Info.plist
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tests/BundleGeneratorTest/Info.plist 28 Jul 2008 23:29:22 -0000
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>CFBundleExecutable</key>
+ <string>BundleGeneratorTest</string>
+ <key>CFBundleIconFile</key>
+ <string>BundleGeneratorTest.icns</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ </dict>
+</plist>
Index: Tests/BundleGeneratorTest/Library.cxx
===================================================================
RCS file: Tests/BundleGeneratorTest/Library.cxx
diff -N Tests/BundleGeneratorTest/Library.cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tests/BundleGeneratorTest/Library.cxx 28 Jul 2008 23:29:22 -0000
@@ -0,0 +1,7 @@
+#include <iostream>
+
+void print_message(const char* const Message)
+{
+ std::cout << Message;
+}
+
Index: Tests/BundleGeneratorTest/StartupCommand
===================================================================
RCS file: Tests/BundleGeneratorTest/StartupCommand
diff -N Tests/BundleGeneratorTest/StartupCommand
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tests/BundleGeneratorTest/StartupCommand 28 Jul 2008 23:29:22 -0000
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/.*//'`"
+RESOURCES="$BUNDLE/Contents/Resources"
+
+echo "BUNDLE: $BUNDLE"
+echo "RESOURCES: $RESOURCES"
+
+export DYLD_LIBRARY_PATH=$RESOURCES/lib
+
+exec "$RESOURCES/bin/Executable"
+
BundleIcon.icns [^] (33,452 bytes) 2008-07-28 19:30 |