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

Method AddGlobalTarget_Test

Source/cmGlobalGenerator.cxx:3010–3055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3008}
3009
3010void cmGlobalGenerator::AddGlobalTarget_Test(
3011 std::vector<GlobalTargetInfo>& targets)
3012{
3013 auto& mf = this->Makefiles[0];
3014 if (!mf->IsOn("CMAKE_TESTING_ENABLED")) {
3015 return;
3016 }
3017
3018 static auto const reservedTargets = { "test", "RUN_TESTS" };
3019 for (auto const& target : reservedTargets) {
3020 if (!this->CheckReservedTargetName(target,
3021 "when CTest testing is enabled")) {
3022 return;
3023 }
3024 }
3025
3026 char const* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
3027 GlobalTargetInfo gti;
3028 gti.Name = this->GetTestTargetName();
3029 gti.Message = "Running tests...";
3030 gti.UsesTerminal = true;
3031 // Unlike the 'install' target, the 'test' target does not depend on 'all'
3032 // by default. Enable it only if CMAKE_SKIP_TEST_ALL_DEPENDENCY is
3033 // explicitly set to OFF.
3034 if (cmValue noall = mf->GetDefinition("CMAKE_SKIP_TEST_ALL_DEPENDENCY")) {
3035 if (noall.IsOff()) {
3036 gti.Depends.emplace_back(this->GetAllTargetName());
3037 }
3038 }
3039 cmCustomCommandLine singleLine;
3040 singleLine.push_back(cmSystemTools::GetCTestCommand());
3041 cmList args(mf->GetDefinition("CMAKE_CTEST_ARGUMENTS"));
3042 for (auto const& arg : args) {
3043 singleLine.push_back(arg);
3044 }
3045 if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') {
3046 singleLine.push_back("-C");
3047 singleLine.push_back(cmakeCfgIntDir);
3048 } else // TODO: This is a hack. Should be something to do with the
3049 // generator
3050 {
3051 singleLine.push_back("$(ARGS)");
3052 }
3053 gti.CommandLines.push_back(std::move(singleLine));
3054 targets.push_back(std::move(gti));
3055}
3056
3057void cmGlobalGenerator::ReserveGlobalTargetCodegen()
3058{

Callers 1

Calls 11

GetCMakeCFGIntDirMethod · 0.95
GetTestTargetNameMethod · 0.95
GetAllTargetNameMethod · 0.95
cmNonemptyFunction · 0.85
moveFunction · 0.85
emplace_backMethod · 0.80
push_backMethod · 0.80
IsOnMethod · 0.45
GetDefinitionMethod · 0.45
IsOffMethod · 0.45

Tested by

no test coverage detected