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

Method WriteDeviceLinkRules

Source/cmNinjaNormalTargetGenerator.cxx:386–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386void cmNinjaNormalTargetGenerator::WriteDeviceLinkRules(
387 std::string const& config)
388{
389 cmMakefile const* mf = this->GetMakefile();
390
391 cmNinjaRule rule(this->LanguageLinkerCudaDeviceRule(config));
392 rule.Command = this->GetLocalGenerator()->BuildCommandLine(
393 { cmStrCat(mf->GetRequiredDefinition("CMAKE_CUDA_DEVICE_LINKER"),
394 " -arch=$ARCH $REGISTER -o=$out $in") },
395 config, config);
396 rule.Comment = "Rule for CUDA device linking.";
397 rule.Description = "Linking CUDA $out";
398 this->GetGlobalGenerator()->AddRule(rule);
399
400 cmRulePlaceholderExpander::RuleVariables vars;
401 vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
402 vars.CMTargetType =
403 cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()).c_str();
404 vars.Language = "CUDA";
405 vars.Object = "$out";
406 vars.Fatbinary = "$FATBIN";
407 vars.RegisterFile = "$REGISTER";
408 vars.LinkFlags = "$LINK_FLAGS";
409 std::string linker =
410 this->GetGeneratorTarget()->GetLinkerTool("CUDA", config);
411 vars.Linker = linker.c_str();
412
413 std::string flags = this->GetFlags("CUDA", config);
414 vars.Flags = flags.c_str();
415 vars.Config = "$CONFIG";
416
417 std::string compileCmd = this->GetMakefile()->GetRequiredDefinition(
418 "CMAKE_CUDA_DEVICE_LINK_COMPILE");
419 auto rulePlaceholderExpander =
420 this->GetLocalGenerator()->CreateRulePlaceholderExpander(
421 cmBuildStep::Link);
422 rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
423 compileCmd, vars);
424
425 rule.Name = this->LanguageLinkerCudaDeviceCompileRule(config);
426 rule.Command = this->GetLocalGenerator()->BuildCommandLine({ compileCmd },
427 config, config);
428 rule.Comment = "Rule for compiling CUDA device stubs.";
429 rule.Description = "Compiling CUDA device stub $out";
430 this->GetGlobalGenerator()->AddRule(rule);
431
432 rule.Name = this->LanguageLinkerCudaFatbinaryRule(config);
433 rule.Command = this->GetLocalGenerator()->BuildCommandLine(
434 { cmStrCat(mf->GetRequiredDefinition("CMAKE_CUDA_FATBINARY"),
435 " -64 -cmdline=--compile-only -compress-all -link "
436 "--embedded-fatbin=$out $PROFILES") },
437 config, config);
438 rule.Comment = "Rule for CUDA fatbinaries.";
439 rule.Description = "Creating fatbinary $out";
440 this->GetGlobalGenerator()->AddRule(rule);
441}
442
443static void NinjaSafeComment(std::string& comment)

Callers 1

Calls 15

BuildCommandLineMethod · 0.80
AddRuleMethod · 0.80
c_strMethod · 0.80
GetLinkerToolMethod · 0.80
GetFlagsMethod · 0.80
ExpandRuleVariablesMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
GetLocalGeneratorMethod · 0.45

Tested by

no test coverage detected