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

Method GenerateScriptForConfig

Source/cmInstallTargetGenerator.cxx:148–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146cmInstallTargetGenerator::~cmInstallTargetGenerator() = default;
147
148void cmInstallTargetGenerator::GenerateScriptForConfig(
149 std::ostream& os, std::string const& config, Indent indent)
150{
151 // Compute the list of files to install for this target.
152 Files files = this->GetFiles(config);
153
154 // Skip this rule if no files are to be installed for the target.
155 if (files.From.empty()) {
156 return;
157 }
158
159 // Compute the effective install destination.
160 std::string dest = this->GetDestination(config);
161 if (!files.ToDir.empty()) {
162 dest = cmStrCat(dest, '/', files.ToDir);
163 }
164
165 // Tweak files located in the destination directory.
166 std::string toDir = cmStrCat(ConvertToAbsoluteDestination(dest), '/');
167
168 // Add pre-installation tweaks.
169 if (!files.NoTweak) {
170 AddTweak(os, indent, config, toDir, files.To,
171 [this](std::ostream& o, Indent i, std::string const& c,
172 std::string const& f) {
173 this->PreReplacementTweaks(o, i, c, f);
174 });
175 }
176
177 // Write code to install the target file.
178 char const* no_dir_permissions = nullptr;
179 bool optional = this->Optional || this->ImportLibrary;
180 std::string literal_args;
181 if (files.UseSourcePermissions) {
182 literal_args += " USE_SOURCE_PERMISSIONS";
183 }
184 if (files.Rename) {
185 if (files.From.size() != files.To.size()) {
186 this->Target->GetLocalGenerator()->IssueMessage(
187 MessageType::INTERNAL_ERROR,
188 "cmInstallTargetGenerator generated a rename request with mismatched "
189 "names.");
190 return;
191 }
192 std::vector<std::string> FileNames;
193 FileNames.resize(1);
194 for (size_t i = 0; i < files.From.size(); ++i) {
195 if (files.FromDir.empty()) {
196 FileNames[0] = files.From[i];
197 } else {
198 FileNames[0] = cmStrCat(files.FromDir, '/', files.From[i]);
199 }
200 this->AddInstallRule(os, dest, files.Type, FileNames, optional,
201 this->FilePermissions.c_str(), no_dir_permissions,
202 files.To[i].c_str(), literal_args.c_str(), indent);
203 }
204 } else {
205 char const* no_rename = nullptr;

Callers

nothing calls this directly

Calls 12

GetFilesMethod · 0.95
GetDestinationMethod · 0.95
PreReplacementTweaksMethod · 0.95
PostReplacementTweaksMethod · 0.95
AddInstallRuleMethod · 0.80
c_strMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
IssueMessageMethod · 0.45
GetLocalGeneratorMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected