summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-29 12:47:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-09-29 12:48:16 (GMT)
commite24e0ff6fac02bc8a12514d22ab4d8b80d789f56 (patch)
treee48f4134d4d5f1f685626713d1fa41bf8a8496fb /Source/CPack
parentf920ffd8f382c891bd863977eb453533b39c4bcc (diff)
parent77f674be35717a6eb296246733885b5a7ddf95ec (diff)
downloadCMake-e24e0ff6fac02bc8a12514d22ab4d8b80d789f56.zip
CMake-e24e0ff6fac02bc8a12514d22ab4d8b80d789f56.tar.gz
CMake-e24e0ff6fac02bc8a12514d22ab4d8b80d789f56.tar.bz2
Merge topic 'clang-tidy'
77f674be Fix some occurrences of readability-braces-around-statements f0bab294 Convert some leftover loops to C++11 range-based loop b5d7f5b0 Fix occurrences of readability-non-const-parameter 9a2da339 Fix some occurrences of readability-avoid-const-params-in-decls 870dd06d Fix left-over occurrences of else-after-return 2033abff Fix minor clang-tidy findings 79b8c380 Improve several occurrences of vector::push_back in loops a45928cd Fix some occurrences of missing override keywords ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1292
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackBundleGenerator.cxx7
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx42
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.h4
-rw-r--r--Source/CPack/cmCPackPKGGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx3
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.cxx2
6 files changed, 32 insertions, 30 deletions
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index bbf2a50..f47ca7a 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -213,8 +213,7 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
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) {
+ for (auto const& file : relFiles) {
std::ostringstream temp_sign_file_cmd;
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_sign_file_cmd << " " << sign_parameter << " -s \""
@@ -223,11 +222,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
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 << "\"";
+ temp_sign_file_cmd << file << "\"";
if (!this->RunCommand(temp_sign_file_cmd, &output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error signing file:" << bundle_path << *it << std::endl
+ "Error signing file:" << bundle_path << file << std::endl
<< output << std::endl);
return 0;
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 88204c8..45c7fc6 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -136,17 +136,17 @@ int cmCPackDragNDropGenerator::InitializeInternal()
"CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
return 0;
}
- for (size_t i = 0; i < languages.size(); ++i) {
- std::string license = slaDirectory + "/" + languages[i] + ".license.txt";
+ for (auto const& language : languages) {
+ std::string license = slaDirectory + "/" + language + ".license.txt";
if (!singleLicense && !cmSystemTools::FileExists(license)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
- << languages[i] << ".license.txt" << std::endl);
+ << language << ".license.txt" << std::endl);
return 0;
}
- std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt";
+ std::string menu = slaDirectory + "/" + language + ".menu.txt";
if (!cmSystemTools::FileExists(menu)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
- << languages[i] << ".menu.txt" << std::endl);
+ << language << ".menu.txt" << std::endl);
return 0;
}
}
@@ -185,19 +185,19 @@ int cmCPackDragNDropGenerator::PackageFiles()
// loop to create dmg files
packageFileNames.clear();
- for (size_t i = 0; i < package_files.size(); i++) {
+ for (auto const& package_file : package_files) {
std::string full_package_name = std::string(toplevel) + std::string("/");
- if (package_files[i] == "ALL_IN_ONE") {
+ if (package_file == "ALL_IN_ONE") {
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
} else {
- full_package_name += package_files[i];
+ full_package_name += package_file;
}
full_package_name += std::string(GetOutputExtension());
packageFileNames.push_back(full_package_name);
std::string src_dir = toplevel;
src_dir += "/";
- src_dir += package_files[i];
+ src_dir += package_file;
if (0 == this->CreateDMG(src_dir, full_package_name)) {
return 0;
@@ -226,14 +226,14 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
if (!fout) {
return false;
- } else {
- // Seek to desired size - 1 byte
- fout.seekp(size - 1, std::ios::beg);
- char byte = 0;
- // Write one byte to ensure file grows
- fout.write(&byte, 1);
}
+ // Seek to desired size - 1 byte
+ fout.seekp(size - 1, std::ios::beg);
+ char byte = 0;
+ // Write one byte to ensure file grows
+ fout.write(&byte, 1);
+
return true;
}
@@ -561,7 +561,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i]
<< " is not a recognized language" << std::endl);
}
- char* iso_language_cstr = (char*)malloc(65);
+ char* iso_language_cstr = static_cast<char*>(malloc(65));
CFStringGetCString(iso_language, iso_language_cstr, 64,
kCFStringEncodingMacRoman);
LangCode lang = 0;
@@ -769,7 +769,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
bool cmCPackDragNDropGenerator::WriteLicense(
cmGeneratedFileStream& outputStream, int licenseNumber,
- std::string licenseLanguage, std::string licenseFile, std::string* error)
+ std::string licenseLanguage, const std::string& licenseFile,
+ std::string* error)
{
if (!licenseFile.empty() && !singleLicense) {
licenseNumber = 5002;
@@ -795,8 +796,8 @@ bool cmCPackDragNDropGenerator::WriteLicense(
if (!this->BreakLongLine(line, lines, error)) {
return false;
}
- for (size_t i = 0; i < lines.size(); ++i) {
- outputStream << " \"" << lines[i] << "\"\n";
+ for (auto const& l : lines) {
+ outputStream << " \"" << l << "\"\n";
}
}
outputStream << " \"\\n\"\n";
@@ -865,10 +866,11 @@ bool cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
size_t line_length = max_line_length;
if (i + line_length > line.size()) {
line_length = line.size() - i;
- } else
+ } else {
while (line_length > 0 && line[i + line_length - 1] != ' ') {
line_length = line_length - 1;
}
+ }
if (line_length == 0) {
*error = "Please make sure there are no words "
diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h
index 8565c68..d8c5c83 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.h
+++ b/Source/CPack/cmCPackDragNDropGenerator.h
@@ -45,8 +45,8 @@ private:
bool singleLicense;
bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber,
- std::string licenseLanguage, std::string licenseFile,
- std::string* error);
+ std::string licenseLanguage,
+ const std::string& licenseFile, std::string* error);
bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
std::string* error);
void EscapeQuotesAndBackslashes(std::string& line);
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index 321b6a7..4f5b2a0 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -42,9 +42,9 @@ std::string cmCPackPKGGenerator::GetPackageName(
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< component.Name << ".pkg";
return out.str();
- } else {
- return component.ArchiveFile + ".pkg";
}
+
+ return component.ArchiveFile + ".pkg";
}
void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 6624b16..0299279 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -275,8 +275,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
if (this->PackageMakerVersion > 2.0) {
pkgCmd << " -v";
}
- if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
+ if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str())) {
return 0;
+ }
} else {
// We have built the package in place. Generate the
// distribution.dist file to describe it for the installer.
diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx
index ed4463c..6a6dc82 100644
--- a/Source/CPack/cmCPackProductBuildGenerator.cxx
+++ b/Source/CPack/cmCPackProductBuildGenerator.cxx
@@ -190,7 +190,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: " << scriptDir
<< std::endl);
- return 0;
+ return false;
}
// if preflight, postflight, or postupgrade are set