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

Method InitializeHandler

Source/CTest/cmCTestBuildCommand.cxx:42–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
43 HandlerArguments& arguments, cmExecutionStatus& status) const
44{
45 cmMakefile& mf = status.GetMakefile();
46 auto const& args = static_cast<BuildArguments&>(arguments);
47 auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest);
48
49 cmValue ctestBuildCommand = mf.GetDefinition("CTEST_BUILD_COMMAND");
50 if (cmNonempty(ctestBuildCommand)) {
51 this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand,
52 args.Quiet);
53 } else {
54 cmValue cmakeGeneratorName = mf.GetDefinition("CTEST_CMAKE_GENERATOR");
55
56 // Build configuration is determined by: CONFIGURATION argument,
57 // or CTEST_BUILD_CONFIGURATION script variable, or
58 // CTEST_CONFIGURATION_TYPE script variable, or ctest -C command
59 // line argument... in that order.
60 //
61 cmValue ctestBuildConfiguration =
62 mf.GetDefinition("CTEST_BUILD_CONFIGURATION");
63 std::string cmakeBuildConfiguration = cmNonempty(args.Configuration)
64 ? args.Configuration
65 : cmNonempty(ctestBuildConfiguration) ? *ctestBuildConfiguration
66 : this->CTest->GetConfigType();
67
68 std::string const& cmakeBuildAdditionalFlags = cmNonempty(args.Flags)
69 ? args.Flags
70 : mf.GetSafeDefinition("CTEST_BUILD_FLAGS");
71 std::string const& cmakeBuildTarget = cmNonempty(args.Target)
72 ? args.Target
73 : mf.GetSafeDefinition("CTEST_BUILD_TARGET");
74
75 if (cmNonempty(cmakeGeneratorName)) {
76 if (cmakeBuildConfiguration.empty()) {
77 cmakeBuildConfiguration = "Release";
78 }
79
80 auto globalGenerator =
81 mf.GetCMakeInstance()->CreateGlobalGenerator(*cmakeGeneratorName);
82 if (!globalGenerator) {
83 std::string e = cmStrCat("could not create generator named \"",
84 *cmakeGeneratorName, '"');
85 mf.IssueMessage(MessageType::FATAL_ERROR, e);
86 cmSystemTools::SetFatalErrorOccurred();
87 return nullptr;
88 }
89 if (cmakeBuildConfiguration.empty()) {
90 cmakeBuildConfiguration = "Debug";
91 }
92
93 std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
94 std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
95 cmakeBuildTarget, cmakeBuildConfiguration, args.ParallelLevel,
96 cmakeBuildAdditionalFlags, false);
97 cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
98 "SetMakeCommand:" << buildCommand << "\n",
99 args.Quiet);

Callers

nothing calls this directly

Calls 15

cmNonemptyFunction · 0.85
moveFunction · 0.85
SetCTestConfigurationMethod · 0.80
GetCTestConfigurationMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.50
GetMakefileMethod · 0.45
GetDefinitionMethod · 0.45
emptyMethod · 0.45
CreateGlobalGeneratorMethod · 0.45
GetCMakeInstanceMethod · 0.45

Tested by

no test coverage detected