MCPcopy Create free account
hub / github.com/Kitware/CMake / PackageFiles

Method PackageFiles

Source/CPack/cmCPackNSISGenerator.cxx:41–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39cmCPackNSISGenerator::~cmCPackNSISGenerator() = default;
40
41int cmCPackNSISGenerator::PackageFiles()
42{
43 // TODO: Fix nsis to force out file name
44
45 std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
46 if (nsisInFileName.empty()) {
47 cmCPackLogger(cmCPackLog::LOG_ERROR,
48 "CPack error: Could not find NSIS installer template file."
49 << std::endl);
50 return false;
51 }
52 std::string nsisInInstallOptions =
53 this->FindTemplate("NSIS.InstallOptions.ini.in");
54 if (nsisInInstallOptions.empty()) {
55 cmCPackLogger(cmCPackLog::LOG_ERROR,
56 "CPack error: Could not find NSIS installer options file."
57 << std::endl);
58 return false;
59 }
60
61 std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
62 std::string tmpFile = cmStrCat(nsisFileName, "/NSISOutput.log");
63 std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini";
64 nsisFileName += "/project.nsi";
65 std::ostringstream str;
66 for (std::string const& file : this->files) {
67 std::string outputDir = "$INSTDIR";
68 std::string fileN = cmSystemTools::RelativePath(this->toplevel, file);
69 if (!this->Components.empty()) {
70 std::string::size_type const pos = fileN.find('/');
71
72 // Use the custom component install directory if we have one
73 if (pos != std::string::npos) {
74 auto componentName = cm::string_view(fileN).substr(0, pos);
75 outputDir = this->CustomComponentInstallDirectory(componentName);
76 } else {
77 outputDir = this->CustomComponentInstallDirectory(fileN);
78 }
79
80 // Strip off the component part of the path.
81 fileN = fileN.substr(pos + 1);
82 }
83 std::replace(fileN.begin(), fileN.end(), '/', '\\');
84
85 str << " Delete \"" << outputDir << "\\" << fileN << "\"" << std::endl;
86 }
87 cmCPackLogger(cmCPackLog::LOG_DEBUG,
88 "Uninstall Files: " << str.str() << std::endl);
89 this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str());
90 std::vector<std::string> dirs;
91 this->GetListOfSubdirectories(this->toplevel.c_str(), dirs);
92 std::ostringstream dstr;
93 for (std::string const& dir : dirs) {
94 std::string componentName;
95 std::string fileN = cmSystemTools::RelativePath(this->toplevel, dir);
96 if (fileN.empty()) {
97 continue;
98 }

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
cmHasPrefixFunction · 0.85
FindTemplateMethod · 0.80
strMethod · 0.80
c_strMethod · 0.80
eraseMethod · 0.80
push_backMethod · 0.80
GetOptionIfSetMethod · 0.80

Tested by

no test coverage detected