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

Method WriteEmbeddedResourceGroup

Source/cmVisualStudio10TargetGenerator.cxx:1250–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1248}
1249
1250void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
1251{
1252 if (!this->ResxObjs.empty()) {
1253 Elem e1(e0, "ItemGroup");
1254 std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
1255 ConvertToWindowsSlash(srcDir);
1256 for (cmSourceFile const* oi : this->ResxObjs) {
1257 std::string obj = oi->GetFullPath();
1258 ConvertToWindowsSlash(obj);
1259 bool useRelativePath = false;
1260 if (this->ProjectType == VsProjectType::csproj && this->InSourceBuild) {
1261 // If we do an in-source build and the resource file is in a
1262 // subdirectory
1263 // of the .csproj file, we have to use relative pathnames, otherwise
1264 // visual studio does not show the file in the IDE. Sorry.
1265 if (cmHasPrefix(obj, srcDir)) {
1266 obj = this->ConvertPath(obj, true);
1267 ConvertToWindowsSlash(obj);
1268 useRelativePath = true;
1269 }
1270 }
1271 Elem e2(e1, "EmbeddedResource");
1272 e2.Attribute("Include", obj);
1273
1274 if (this->ProjectType != VsProjectType::csproj) {
1275 std::string hFileName =
1276 cmStrCat(obj.substr(0, obj.find_last_of('.')), ".h");
1277 e2.Element("DependentUpon", hFileName);
1278
1279 for (std::string const& c : this->Configurations) {
1280 std::string s;
1281 if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE") ||
1282 // Handle variant of VS_GLOBAL_<variable> for RootNamespace.
1283 this->GeneratorTarget->GetProperty("VS_GLOBAL_RootNamespace")) {
1284 s = "$(RootNamespace).";
1285 }
1286 s += "%(Filename).resources";
1287 e2.WritePlatformConfigTag("LogicalName", this->CalcCondition(c), s);
1288 }
1289 } else {
1290 std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
1291 ConvertToWindowsSlash(binDir);
1292 // If the resource was NOT added using a relative path (which should
1293 // be the default), we have to provide a link here
1294 if (!useRelativePath) {
1295 std::string link = this->GetCSharpSourceLink(oi);
1296 if (link.empty()) {
1297 link = cmsys::SystemTools::GetFilenameName(obj);
1298 }
1299 e2.Element("Link", link);
1300 }
1301 // Determine if this is a generated resource from a .Designer.cs file
1302 std::string designerResource = cmStrCat(
1303 cmSystemTools::GetFilenamePath(oi->GetFullPath()), '/',
1304 cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()),
1305 ".Designer.cs");
1306 if (cmsys::SystemTools::FileExists(designerResource)) {
1307 std::string generator = "PublicResXFileCodeGenerator";

Callers 2

Calls 15

ConvertPathMethod · 0.95
CalcConditionMethod · 0.95
GetCSharpSourceLinkMethod · 0.95
ConvertToWindowsSlashFunction · 0.85
cmHasPrefixFunction · 0.85
cmNonemptyFunction · 0.85
AttributeMethod · 0.80
find_last_ofMethod · 0.80
eraseMethod · 0.80
lengthMethod · 0.80
GetKeysMethod · 0.80

Tested by

no test coverage detected