diff options
Diffstat (limited to 'Source/CPack')
23 files changed, 241 insertions, 127 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 0644ecb..4a99e50 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -24,7 +24,7 @@ #endif #define cmCPackLogger(logType, msg) \ do { \ - cmOStringStream cmCPackLog_msg; \ + std::ostringstream cmCPackLog_msg; \ cmCPackLog_msg << msg; \ if(Generator) { \ Generator->Logger->Log(logType, __FILE__, __LINE__, \ diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 3c45639..38cef87 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -25,7 +25,7 @@ #endif #define cmCPackLogger(logType, msg) \ do { \ - cmOStringStream cmCPackLog_msg; \ + std::ostringstream cmCPackLog_msg; \ cmCPackLog_msg << msg; \ if(Generator) { \ Generator->Logger->Log(logType, __FILE__, __LINE__, \ diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 7e00027..59c38e9 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1150,12 +1150,7 @@ void cmCPackWIXGenerator::CollectExtensions( std::vector<std::string> list; cmSystemTools::ExpandListArgument(variableContent, list); - - for(std::vector<std::string>::const_iterator i = list.begin(); - i != list.end(); ++i) - { - extensions.insert(*i); - } + extensions.insert(list.begin(), list.end()); } void cmCPackWIXGenerator::AddCustomFlags( diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 6e7b8d7..e2437b5 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -56,7 +56,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, localToplevel += "/"+ component->Name; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); // Change to local toplevel - cmSystemTools::ChangeDirectory(localToplevel.c_str()); + cmSystemTools::ChangeDirectory(localToplevel); std::string filePrefix; if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) { @@ -80,7 +80,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, } } // Go back to previous dir - cmSystemTools::ChangeDirectory(dir.c_str()); + cmSystemTools::ChangeDirectory(dir); return 1; } @@ -270,7 +270,7 @@ int cmCPackArchiveGenerator::PackageFiles() DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); std::vector<std::string>::const_iterator fileIt; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(toplevel.c_str()); + cmSystemTools::ChangeDirectory(toplevel); for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { // Get the relative path to the file @@ -288,7 +288,7 @@ int cmCPackArchiveGenerator::PackageFiles() return 0; } } - cmSystemTools::ChangeDirectory(dir.c_str()); + cmSystemTools::ChangeDirectory(dir); // The destructor of cmArchiveWrite will close and finish the write return 1; } diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 6c994f1..e751568 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -39,6 +39,21 @@ int cmCPackBundleGenerator::InitializeInternal() return 0; } + if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) + { + const std::string codesign_path = cmSystemTools::FindProgram("codesign", + std::vector<std::string>(), false); + + if(codesign_path.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate codesign command" + << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str()); + } + return this->Superclass::InitializeInternal(); } @@ -53,7 +68,7 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() } //---------------------------------------------------------------------- -int cmCPackBundleGenerator::PackageFiles() +int cmCPackBundleGenerator::ConstructBundle() { // Get required arguments ... @@ -97,24 +112,24 @@ int cmCPackBundleGenerator::PackageFiles() // The staging directory contains everything that will end-up inside the // final disk image ... - cmOStringStream staging; + std::ostringstream staging; staging << toplevel; - cmOStringStream contents; + std::ostringstream contents; contents << staging.str() << "/" << cpack_bundle_name << ".app/" << "Contents"; - cmOStringStream application; + std::ostringstream application; application << contents.str() << "/" << "MacOS"; - cmOStringStream resources; + std::ostringstream resources; resources << contents.str() << "/" << "Resources"; // Install a required, user-provided bundle metadata file ... - cmOStringStream plist_source; + std::ostringstream plist_source; plist_source << cpack_bundle_plist; - cmOStringStream plist_target; + std::ostringstream plist_target; plist_target << contents.str() << "/" << "Info.plist"; if(!this->CopyFile(plist_source, plist_target)) @@ -127,10 +142,10 @@ int cmCPackBundleGenerator::PackageFiles() } // Install a user-provided bundle icon ... - cmOStringStream icon_source; + std::ostringstream icon_source; icon_source << cpack_bundle_icon; - cmOStringStream icon_target; + std::ostringstream icon_target; icon_target << resources.str() << "/" << cpack_bundle_name << ".icns"; if(!this->CopyFile(icon_source, icon_target)) @@ -146,10 +161,10 @@ int cmCPackBundleGenerator::PackageFiles() // executable or a script) ... if(!cpack_bundle_startup_command.empty()) { - cmOStringStream command_source; + std::ostringstream command_source; command_source << cpack_bundle_startup_command; - cmOStringStream command_target; + std::ostringstream command_target; command_target << application.str() << "/" << cpack_bundle_name; if(!this->CopyFile(command_source, command_target)) @@ -165,6 +180,22 @@ int cmCPackBundleGenerator::PackageFiles() cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } + return 1; +} + +//---------------------------------------------------------------------- +int cmCPackBundleGenerator::PackageFiles() +{ + if(!this->ConstructBundle()) + { + return 0; + } + + if(!this->SignBundle(toplevel)) + { + return 0; + } + return this->CreateDMG(toplevel, packageFileNames[0]); } @@ -172,3 +203,96 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const { return false; } + + +int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) +{ + const std::string cpack_apple_cert_app = + this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") + ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : ""; + + // codesign the application. + if(!cpack_apple_cert_app.empty()) + { + std::string bundle_path; + bundle_path = src_dir + "/"; + bundle_path += this->GetOption("CPACK_BUNDLE_NAME"); + bundle_path += ".app"; + + // A list of additional files to sign, ie. frameworks and plugins. + const std::string sign_files = + this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") + ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : ""; + + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(sign_files, relFiles); + + // sign the files supplied by the user, ie. frameworks. + for(std::vector<std::string>::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + std::ostringstream temp_sign_file_cmd; + temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_sign_file_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_file_cmd << "\" -i "; + temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID"); + temp_sign_file_cmd << " \""; + temp_sign_file_cmd << bundle_path; + temp_sign_file_cmd << it->c_str() << "\""; + + if(!this->RunCommand(temp_sign_file_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing file:" + << bundle_path << it->c_str() << std::endl); + + return 0; + } + } + + // sign main binary + std::ostringstream temp_sign_binary_cmd; + temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_sign_binary_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_binary_cmd << "\" \"" << bundle_path << "\""; + + if(!this->RunCommand(temp_sign_binary_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing the application binary." + << std::endl); + + return 0; + } + + // sign app bundle + std::ostringstream temp_codesign_cmd; + temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_codesign_cmd << " --deep -f -s \"" << cpack_apple_cert_app << "\""; + if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) + { + temp_codesign_cmd << " --entitlements "; + temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"); + } + temp_codesign_cmd << " \"" << bundle_path << "\""; + + if(!this->RunCommand(temp_codesign_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing the application package." + << std::endl); + + return 0; + } + + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Application has been codesigned" + << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS") + ? "with entitlement sandboxing" : "without entitlement sandboxing") + << std::endl); + } + + return 1; +} diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index ed0187d..9cb2f0a 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -31,6 +31,8 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); + int ConstructBundle(); + int SignBundle(const std::string& src_dir); int PackageFiles(); bool SupportsComponentInstallation() const; diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index 77f11cb..fd20e9b 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -30,7 +30,7 @@ unsigned long cmCPackComponent::GetInstalledSize( std::string path = installDir; path += '/'; path += *fileIt; - this->TotalSize += cmSystemTools::FileLength(path.c_str()); + this->TotalSize += cmSystemTools::FileLength(path); } return this->TotalSize; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 936942b..0a64bd5 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -58,7 +58,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, // Begin the archive for this pack std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) @@ -186,7 +186,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) @@ -390,7 +390,7 @@ int cmCPackDebGenerator::createDeb() packageFiles.begin(); fileIt != packageFiles.end(); ++ fileIt ) { - totalSize += cmSystemTools::FileLength(fileIt->c_str()); + totalSize += cmSystemTools::FileLength(*fileIt); } } out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; @@ -540,7 +540,7 @@ int cmCPackDebGenerator::createDeb() localcopy += filenamename; // if we can copy the file, it means it does exist, let's add it: if( cmsys::SystemTools::CopyFileIfDifferent( - i->c_str(), localcopy.c_str()) ) + *i, localcopy) ) { // debian is picky and need relative to ./ path in the tar.* cmd += " ./"; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 9f0a77e..5da9234 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -169,8 +169,8 @@ int cmCPackDragNDropGenerator::PackageFiles() } //---------------------------------------------------------------------- -bool cmCPackDragNDropGenerator::CopyFile(cmOStringStream& source, - cmOStringStream& target) +bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source, + std::ostringstream& target) { if(!cmSystemTools::CopyFileIfDifferent( source.str().c_str(), @@ -190,7 +190,7 @@ bool cmCPackDragNDropGenerator::CopyFile(cmOStringStream& source, } //---------------------------------------------------------------------- -bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command, +bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, std::string* output) { int exit_code = 1; @@ -255,12 +255,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // The staging directory contains everything that will end-up inside the // final disk image ... - cmOStringStream staging; + std::ostringstream staging; staging << src_dir; // Add a symlink to /Applications so users can drag-and-drop the bundle // into it - cmOStringStream application_link; + std::ostringstream application_link; application_link << staging.str() << "/Applications"; cmSystemTools::CreateSymlink("/Applications", application_link.str().c_str()); @@ -268,10 +268,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally add a custom volume icon ... if(!cpack_package_icon.empty()) { - cmOStringStream package_icon_source; + std::ostringstream package_icon_source; package_icon_source << cpack_package_icon; - cmOStringStream package_icon_destination; + std::ostringstream package_icon_destination; package_icon_destination << staging.str() << "/.VolumeIcon.icns"; if(!this->CopyFile(package_icon_source, package_icon_destination)) @@ -289,10 +289,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // (e.g. for setting background/layout) ... if(!cpack_dmg_ds_store.empty()) { - cmOStringStream package_settings_source; + std::ostringstream package_settings_source; package_settings_source << cpack_dmg_ds_store; - cmOStringStream package_settings_destination; + std::ostringstream package_settings_destination; package_settings_destination << staging.str() << "/.DS_Store"; if(!this->CopyFile(package_settings_source, package_settings_destination)) @@ -309,10 +309,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally add a custom background image ... if(!cpack_dmg_background_image.empty()) { - cmOStringStream package_background_source; + std::ostringstream package_background_source; package_background_source << cpack_dmg_background_image; - cmOStringStream package_background_destination; + std::ostringstream package_background_destination; package_background_destination << staging.str() << "/background.png"; if(!this->CopyFile(package_background_source, @@ -326,7 +326,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, return 0; } - cmOStringStream temp_background_hiding_command; + std::ostringstream temp_background_hiding_command; temp_background_hiding_command << this->GetOption("CPACK_COMMAND_SETFILE"); temp_background_hiding_command << " -a V \""; temp_background_hiding_command << package_background_destination.str(); @@ -346,7 +346,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); temp_image += "/temp.dmg"; - cmOStringStream temp_image_command; + std::ostringstream temp_image_command; temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); temp_image_command << " create"; temp_image_command << " -ov"; @@ -368,9 +368,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally set the custom icon flag for the image ... if(!cpack_package_icon.empty()) { - cmOStringStream temp_mount; + std::ostringstream temp_mount; - cmOStringStream attach_command; + std::ostringstream attach_command; attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); attach_command << " attach"; attach_command << " \"" << temp_image << "\""; @@ -389,7 +389,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, mountpoint_regex.find(attach_output.c_str()); temp_mount << mountpoint_regex.match(1); - cmOStringStream setfile_command; + std::ostringstream setfile_command; setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); setfile_command << " -a C"; setfile_command << " \"" << temp_mount.str() << "\""; @@ -403,7 +403,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, return 0; } - cmOStringStream detach_command; + std::ostringstream detach_command; detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); detach_command << " detach"; detach_command << " \"" << temp_mount.str() << "\""; @@ -471,7 +471,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); temp_udco += "/temp-udco.dmg"; - cmOStringStream udco_image_command; + std::ostringstream udco_image_command; udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); udco_image_command << " convert \"" << temp_image << "\""; udco_image_command << " -format UDCO"; @@ -488,7 +488,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } // unflatten dmg - cmOStringStream unflatten_command; + std::ostringstream unflatten_command; unflatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); unflatten_command << " unflatten "; unflatten_command << "\"" << temp_udco << "\""; @@ -503,7 +503,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } // Rez the SLA - cmOStringStream embed_sla_command; + std::ostringstream embed_sla_command; embed_sla_command << this->GetOption("CPACK_COMMAND_REZ"); const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT"); if(sysroot && sysroot[0] != '\0') @@ -524,7 +524,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } // flatten dmg - cmOStringStream flatten_command; + std::ostringstream flatten_command; flatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); flatten_command << " flatten "; flatten_command << "\"" << temp_udco << "\""; @@ -543,7 +543,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Create the final compressed read-only disk image ... - cmOStringStream final_image_command; + std::ostringstream final_image_command; final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); final_image_command << " convert \"" << temp_image << "\""; final_image_command << " -format "; diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index 808c618..1c84d49 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -33,8 +33,8 @@ protected: bool SupportsComponentInstallation() const; - bool CopyFile(cmOStringStream& source, cmOStringStream& target); - bool RunCommand(cmOStringStream& command, std::string* output = 0); + bool CopyFile(std::ostringstream& source, std::ostringstream& target); + bool RunCommand(std::ostringstream& command, std::string* output = 0); std::string GetComponentInstallDirNameSuffix(const std::string& componentName); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 8139d29..1c670d2 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -160,7 +160,7 @@ int cmCPackGenerator::PrepareNames() "Cannot open description file name: " << descFileName << std::endl); return 0; } - cmOStringStream ostr; + std::ostringstream ostr; std::string line; cmCPackLogger(cmCPackLog::LOG_VERBOSE, @@ -217,7 +217,7 @@ int cmCPackGenerator::InstallProject() { std::string destDir = "DESTDIR="; destDir += tempInstallDirectory; - cmSystemTools::PutEnv(destDir.c_str()); + cmSystemTools::PutEnv(destDir); } else { @@ -277,7 +277,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( { std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX="; tempInstallDirectoryEnv += tempInstallDirectory; - cmSystemTools::PutEnv(tempInstallDirectoryEnv.c_str()); + cmSystemTools::PutEnv(tempInstallDirectoryEnv); std::vector<std::string> installCommandsVector; cmSystemTools::ExpandListArgument(installCommands,installCommandsVector); std::vector<std::string>::iterator it; @@ -399,12 +399,12 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ - if ( cmSystemTools::FileIsSymlink(inFile.c_str())) + if ( cmSystemTools::FileIsSymlink(inFile)) { std::string targetFile; std::string inFileRelative = cmSystemTools::RelativePath(top.c_str(),inFile.c_str()); - cmSystemTools::ReadSymlink(inFile.c_str(),targetFile); + cmSystemTools::ReadSymlink(inFile,targetFile); symlinkedFiles.push_back(std::pair<std::string, std::string>(targetFile,inFileRelative)); } @@ -421,7 +421,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } } /* rebuild symlinks in the installed tree */ - if (symlinkedFiles.size()>0) + if (!symlinkedFiles.empty()) { std::list< std::pair<std::string,std::string> >::iterator symlinkedIt; std::string curDir = cmSystemTools::GetCurrentWorkingDirectory(); @@ -429,7 +429,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( goToDir += "/"+subdir; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir <<std::endl); - cmSystemTools::ChangeDirectory(goToDir.c_str()); + cmSystemTools::ChangeDirectory(goToDir); for (symlinkedIt=symlinkedFiles.begin(); symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) @@ -449,8 +449,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( << symlinkedIt->first << std::endl); } - if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(), - (symlinkedIt->second).c_str())) + if (!cmSystemTools::CreateSymlink(symlinkedIt->first, + symlinkedIt->second)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: " << symlinkedIt->second << "--> " @@ -460,7 +460,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir <<std::endl); - cmSystemTools::ChangeDirectory(curDir.c_str()); + cmSystemTools::ChangeDirectory(curDir); } } } @@ -807,7 +807,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( * in order to put things in subdirs... */ cmSystemTools::PutEnv( - (std::string("DESTDIR=")+tempInstallDirectory).c_str() + std::string("DESTDIR=")+tempInstallDirectory ); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" << dir << "'" << std::endl); @@ -938,7 +938,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { - if (absoluteDestFiles.length()>0) { + if (!absoluteDestFiles.empty()) { absoluteDestFiles +=";"; } absoluteDestFiles += @@ -1368,7 +1368,7 @@ int cmCPackGenerator::PrepareGroupingKind() groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING"); } - if (groupingType.length()>0) + if (!groupingType.empty()) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" << this->Name << "]" diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index ed89b53..907bb1e 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -29,7 +29,7 @@ #define cmCPackLogger(logType, msg) \ do { \ - cmOStringStream cmCPackLog_msg; \ + std::ostringstream cmCPackLog_msg; \ cmCPackLog_msg << msg; \ this->Logger->Log(logType, __FILE__, __LINE__,\ cmCPackLog_msg.str().c_str());\ diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index c8737f4..a07c29a 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -47,9 +47,6 @@ #include "cmCPackLog.h" -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition is always true */ -#endif //---------------------------------------------------------------------- cmCPackGeneratorFactory::cmCPackGeneratorFactory() @@ -161,11 +158,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() //---------------------------------------------------------------------- cmCPackGeneratorFactory::~cmCPackGeneratorFactory() { - std::vector<cmCPackGenerator*>::iterator it; - for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it ) - { - delete *it; - } + cmDeleteAll(this->Generators); } //---------------------------------------------------------------------- diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 7befca0..7633ac2 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -102,7 +102,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, display = true; if ( needTagString ) { - if ( tagString.size() > 0 ) { tagString += ","; } + if (!tagString.empty()) { tagString += ","; } tagString = "VERBOSE"; } } @@ -112,7 +112,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, display = true; if ( needTagString ) { - if ( tagString.size() > 0 ) { tagString += ","; } + if (!tagString.empty()) { tagString += ","; } tagString = "WARNING"; } } @@ -122,7 +122,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, display = true; if ( needTagString ) { - if ( tagString.size() > 0 ) { tagString += ","; } + if (!tagString.empty()) { tagString += ","; } tagString = "ERROR"; } } @@ -132,7 +132,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, display = true; if ( needTagString ) { - if ( tagString.size() > 0 ) { tagString += ","; } + if (!tagString.empty()) { tagString += ","; } tagString = "DEBUG"; } useFileAndLine = true; @@ -143,7 +143,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, display = true; if ( needTagString ) { - if ( tagString.size() > 0 ) { tagString += ","; } + if (!tagString.empty()) { tagString += ","; } tagString = "VERBOSE"; } } diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 812f1de..7a7ff58 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -17,7 +17,7 @@ #define cmCPack_Log(ctSelf, logType, msg) \ do { \ - cmOStringStream cmCPackLog_msg; \ + std::ostringstream cmCPackLog_msg; \ cmCPackLog_msg << msg; \ (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\ } while ( 0 ) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index a5eee6b..8f63ca2 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -71,7 +71,7 @@ int cmCPackNSISGenerator::PackageFiles() tmpFile += "/NSISOutput.log"; std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini"; nsisFileName += "/project.nsi"; - cmOStringStream str; + std::ostringstream str; std::vector<std::string>::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { @@ -91,7 +91,7 @@ int cmCPackNSISGenerator::PackageFiles() std::vector<std::string> dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); std::vector<std::string>::const_iterator sit; - cmOStringStream dstr; + std::ostringstream dstr; for ( sit = dirs.begin(); sit != dirs.end(); ++ sit ) { std::string componentName; @@ -190,7 +190,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string groupDescriptions; std::string installTypesCode; std::string defines; - cmOStringStream macrosOut; + std::ostringstream macrosOut; bool anyDownloadedComponents = false; // Create installation types. The order is significant, so we first fill @@ -503,8 +503,8 @@ int cmCPackNSISGenerator::InitializeInternal() << "not set" << std::endl); } - cmOStringStream str; - cmOStringStream deleteStr; + std::ostringstream str; + std::ostringstream deleteStr; if ( cpackPackageExecutables ) { @@ -565,8 +565,8 @@ int cmCPackNSISGenerator::InitializeInternal() } //---------------------------------------------------------------------- -void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, - cmOStringStream& deleteStr) +void cmCPackNSISGenerator::CreateMenuLinks( std::ostringstream& str, + std::ostringstream& deleteStr) { const char* cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS"); @@ -657,8 +657,8 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, cmsys_stl::string fullPath = topdir; fullPath += "/"; fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); - if(cmsys::SystemTools::FileIsDirectory(fullPath.c_str()) && - !cmsys::SystemTools::FileIsSymlink(fullPath.c_str())) + if(cmsys::SystemTools::FileIsDirectory(fullPath) && + !cmsys::SystemTools::FileIsSymlink(fullPath)) { if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs)) { @@ -694,7 +694,7 @@ bool cmCPackNSISGenerator::SupportsComponentInstallation() const std::string cmCPackNSISGenerator:: CreateComponentDescription(cmCPackComponent *component, - cmOStringStream& macrosOut) + std::ostringstream& macrosOut) { // Basic description of the component std::string componentCode = "Section "; @@ -714,7 +714,7 @@ CreateComponentDescription(cmCPackComponent *component, } else if (!component->InstallationTypes.empty()) { - cmOStringStream out; + std::ostringstream out; std::vector<cmCPackInstallationType *>::iterator installTypeIter; for (installTypeIter = component->InstallationTypes.begin(); installTypeIter != component->InstallationTypes.end(); @@ -734,7 +734,7 @@ CreateComponentDescription(cmCPackComponent *component, // Compute the name of the archive. std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); packagesDir += ".dummy"; - cmOStringStream out; + std::ostringstream out; out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" << component->Name << ".zip"; component->ArchiveFile = out.str(); @@ -771,7 +771,7 @@ CreateComponentDescription(cmCPackComponent *component, << archiveFile << std::endl); if (cmSystemTools::FileExists(archiveFile.c_str(), true)) { - if (!cmSystemTools::RemoveFile(archiveFile.c_str())) + if (!cmSystemTools::RemoveFile(archiveFile)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file " << archiveFile @@ -825,7 +825,7 @@ CreateComponentDescription(cmCPackComponent *component, } out << std::endl; - totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str()); + totalSize += cmSystemTools::FileLength(dirName + *fileIt); } } @@ -859,7 +859,7 @@ CreateComponentDescription(cmCPackComponent *component, { totalSizeInKbytes = 1; } - cmOStringStream out; + std::ostringstream out; out << " AddSize " << totalSizeInKbytes << "\n" << " Push \"" << component->ArchiveFile << "\"\n" << " Call DownloadFile\n" @@ -935,7 +935,7 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription } visited.insert(component); - cmOStringStream out; + std::ostringstream out; std::vector<cmCPackComponent *>::iterator dependIt; for (dependIt = component->Dependencies.begin(); dependIt != component->Dependencies.end(); @@ -967,7 +967,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription } visited.insert(component); - cmOStringStream out; + std::ostringstream out; std::vector<cmCPackComponent *>::iterator dependIt; for (dependIt = component->ReverseDependencies.begin(); dependIt != component->ReverseDependencies.end(); @@ -992,7 +992,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription std::string cmCPackNSISGenerator:: CreateComponentGroupDescription(cmCPackComponentGroup *group, - cmOStringStream& macrosOut) + std::ostringstream& macrosOut) { if (group->Components.empty() && group->Subgroups.empty()) { diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index e46fbda..c7b2ce1 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -38,8 +38,8 @@ public: protected: virtual int InitializeInternal(); - void CreateMenuLinks( cmOStringStream& str, - cmOStringStream& deleteStr); + void CreateMenuLinks( std::ostringstream& str, + std::ostringstream& deleteStr); int PackageFiles(); virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputPostfix() { return "win32"; } @@ -56,7 +56,7 @@ protected: /// macrosOut. std::string CreateComponentDescription(cmCPackComponent *component, - cmOStringStream& macrosOut); + std::ostringstream& macrosOut); /// Produce NSIS code that selects all of the components that this component /// depends on, recursively. @@ -75,7 +75,7 @@ protected: /// added macros will be emitted via macrosOut. std::string CreateComponentGroupDescription(cmCPackComponentGroup *group, - cmOStringStream& macrosOut); + std::ostringstream& macrosOut); /// Translations any newlines found in the string into \\r\\n, so that the /// resulting string can be used within NSIS. diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 28c7f1d..313e08b 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -45,8 +45,8 @@ int cmCPackOSXX11Generator::PackageFiles() { cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " << cpackPackageExecutables << "." << std::endl); - cmOStringStream str; - cmOStringStream deleteStr; + std::ostringstream str; + std::ostringstream deleteStr; std::vector<std::string> cpackPackageExecutablesVector; cmSystemTools::ExpandListArgument(cpackPackageExecutables, cpackPackageExecutablesVector); @@ -165,7 +165,7 @@ int cmCPackOSXX11Generator::PackageFiles() std::string output; std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/hdiutilOutput.log"; - cmOStringStream dmgCmd; + std::ostringstream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory.c_str() diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index e58415c..dfe35c9 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -334,7 +334,7 @@ int cmCPackPackageMakerGenerator::PackageFiles() if (this->Components.empty()) { // Use PackageMaker to build the package. - cmOStringStream pkgCmd; + std::ostringstream pkgCmd; pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") << "\" -build -p \"" << packageDirFileName << "\""; if (this->Components.empty()) @@ -368,7 +368,7 @@ int cmCPackPackageMakerGenerator::PackageFiles() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/hdiutilOutput.log"; - cmOStringStream dmgCmd; + std::ostringstream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName << "\" \"" << packageFileNames[0] << "\""; @@ -703,7 +703,7 @@ cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component) { std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); packagesDir += ".dummy"; - cmOStringStream out; + std::ostringstream out; out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" << component.Name << ".pkg"; return out.str(); @@ -726,7 +726,7 @@ GenerateComponentPackage(const char *packageFile, packageFile << std::endl); // The command that will be used to run PackageMaker - cmOStringStream pkgCmd; + std::ostringstream pkgCmd; if (this->PackageCompatibilityVersion < getVersion(10, 5) || this->PackageMakerVersion < 3.0) @@ -816,7 +816,7 @@ WriteDistributionFile(const char* metapackageFile) // Create the choice outline, which provides a tree-based view of // the components in their groups. - cmOStringStream choiceOut; + std::ostringstream choiceOut; choiceOut << "<choices-outline>" << std::endl; // Emit the outline for the groups @@ -878,7 +878,8 @@ WriteDistributionFile(const char* metapackageFile) //---------------------------------------------------------------------- void cmCPackPackageMakerGenerator:: -CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out) +CreateChoiceOutline(const cmCPackComponentGroup& group, + std::ostringstream& out) { out << "<line choice=\"" << group.Name << "Choice\">" << std::endl; std::vector<cmCPackComponentGroup*>::const_iterator groupIt; @@ -901,7 +902,7 @@ CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out) //---------------------------------------------------------------------- void cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group, - cmOStringStream& out) + std::ostringstream& out) { out << "<choice id=\"" << group.Name << "Choice\" " << "title=\"" << group.DisplayName << "\" " @@ -919,7 +920,7 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group, //---------------------------------------------------------------------- void cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, - cmOStringStream& out) + std::ostringstream& out) { std::string packageId = "com."; packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); @@ -980,6 +981,7 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); dirName += '/'; dirName += component.Name; + dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); unsigned long installedSize = component.GetInstalledSizeInKbytes(dirName.c_str()); @@ -1004,7 +1006,7 @@ void cmCPackPackageMakerGenerator:: AddDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent *>& visited, - cmOStringStream& out) + std::ostringstream& out) { if (visited.find(&component) != visited.end()) { @@ -1028,7 +1030,7 @@ void cmCPackPackageMakerGenerator:: AddReverseDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent *>& visited, - cmOStringStream& out) + std::ostringstream& out) { if (visited.find(&component) != visited.end()) { diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 4f9e2a8..7d349c6 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -84,30 +84,30 @@ protected: // dependency attributes for inter-component dependencies. void AddDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent *>& visited, - cmOStringStream& out); + std::ostringstream& out); // Subroutine of WriteDistributionFile that writes out the // reverse dependency attributes for inter-component dependencies. void AddReverseDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent *>& visited, - cmOStringStream& out); + std::ostringstream& out); // Generates XML that encodes the hierarchy of component groups and // their components in a form that can be used by distribution // metapackages. void CreateChoiceOutline(const cmCPackComponentGroup& group, - cmOStringStream& out); + std::ostringstream& out); /// Create the "choice" XML element to describe a component group /// for the installer GUI. void CreateChoice(const cmCPackComponentGroup& group, - cmOStringStream& out); + std::ostringstream& out); /// Create the "choice" XML element to describe a component for the /// installer GUI. void CreateChoice(const cmCPackComponent& component, - cmOStringStream& out); + std::ostringstream& out); // Escape the given string to make it usable as an XML attribute // value. diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index c6171dc..71ab3a0 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -57,7 +57,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, // Begin the archive for this pack std::string localToplevel(initialToplevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), @@ -166,7 +166,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne() // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 6c1d201..e5da5cf 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -71,8 +71,6 @@ int cmCPackSTGZGenerator::PackageFiles() retval &= cmSystemTools::SetPermissions((*it).c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE | S_IEXEC -#elif defined( __BORLANDC__ ) - S_IRUSR | S_IWUSR | S_IXUSR #else S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 0173361..6106472 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -115,7 +115,7 @@ int main (int argc, char const* const* argv) cmSystemTools::EnableMSVCDebugHook(); - if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) + if (cmSystemTools::GetCurrentWorkingDirectory().empty()) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Current working directory cannot be established." << std::endl); @@ -265,7 +265,7 @@ int main (int argc, char const* const* argv) if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) { cpackConfigFile = - cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); + cmSystemTools::CollapseFullPath(cpackConfigFile); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile << std::endl); @@ -424,7 +424,7 @@ int main (int argc, char const* const* argv) = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR"); const char* projVersionPatch = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"); - cmOStringStream ostr; + std::ostringstream ostr; ostr << projVersionMajor << "." << projVersionMinor << "." << projVersionPatch; mf->AddDefinition("CPACK_PACKAGE_VERSION", |