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

Method EmitComponentFile

Source/CPack/WiX/cmWIXFilesSourceWriter.cxx:136–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136std::string cmWIXFilesSourceWriter::EmitComponentFile(
137 std::string const& directoryId, std::string const& id,
138 std::string const& filePath, cmWIXPatch& patch,
139 cmInstalledFile const* installedFile, int diskId)
140{
141 std::string componentId = std::string("CM_C") + id;
142 std::string fileId = std::string("CM_F") + id;
143
144 // Wix doesn't support automatic GUIDs for components which have both
145 // registry entries and files.
146 std::string guid = this->PerUserInstall
147 ? CreateCmakeGeneratedGuidFromComponentId(componentId)
148 : CreateGuidFromComponentId(componentId);
149
150 BeginElement("DirectoryRef");
151 AddAttribute("Id", directoryId);
152
153 BeginElement("Component");
154 AddAttribute("Id", componentId);
155 AddAttribute("Guid", guid);
156
157 if (diskId) {
158 AddAttribute("DiskId", std::to_string(diskId));
159 }
160
161 if (installedFile) {
162 if (installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) {
163 AddAttribute("NeverOverwrite", "yes");
164 }
165 if (installedFile->GetPropertyAsBool("CPACK_PERMANENT")) {
166 AddAttribute("Permanent", "yes");
167 }
168 }
169
170 patch.ApplyFragment(componentId, *this);
171
172 if (this->PerUserInstall) {
173 // For perUser installs, MSI requires using a registry entry as the key
174 // path for components.
175 BeginElement("RegistryValue");
176
177 AddAttribute("Root", "HKCU");
178 AddAttribute("Key", this->ComponentKeysRegistryPath);
179 AddAttribute("Name", fileId);
180 AddAttribute("Type", "string");
181 AddAttribute("Value", "1");
182 AddAttribute("KeyPath", "yes");
183
184 EndElement("RegistryValue");
185 }
186
187 BeginElement("File");
188 AddAttribute("Id", fileId);
189
190 std::string sourcePath = CMakeToWixPath(filePath);
191#ifdef _WIN32
192 // WiX cannot handle long paths natively, but since v4,
193 // it supports long paths via UNC prefixes.

Callers 1

Calls 6

to_stringFunction · 0.85
CMakeToWixPathFunction · 0.85
ApplyFragmentMethod · 0.80
c_strMethod · 0.80
ApplyMethod · 0.80
GetPropertyAsBoolMethod · 0.45

Tested by

no test coverage detected