Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmTargetCompileFeaturesCommand.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmTargetCompileFeaturesCommand.h"
4
5
#include "cmList.h"
6
#include "cmMakefile.h"
7
#include "cmMessageType.h"
8
#include "cmStandardLevelResolver.h"
9
#include "cmStringAlgorithms.h"
10
#include "cmTargetPropCommandBase.h"
11
12
namespace {
13
14
class TargetCompileFeaturesImpl : public cmTargetPropCommandBase
15
{
16
public:
17
  using cmTargetPropCommandBase::cmTargetPropCommandBase;
18
19
private:
20
  void HandleMissingTarget(std::string const& name) override
21
0
  {
22
0
    this->Makefile->IssueMessage(
23
0
      MessageType::FATAL_ERROR,
24
0
      cmStrCat("Cannot specify compile features for target \"", name,
25
0
               "\" which is not built by this project."));
26
0
  }
27
28
  bool HandleDirectContent(cmTarget* tgt,
29
                           std::vector<std::string> const& content,
30
                           bool /*prepend*/, bool /*system*/) override
31
0
  {
32
0
    cmStandardLevelResolver standardResolver(this->Makefile);
33
0
    for (std::string const& it : content) {
34
0
      std::string error;
35
0
      if (!standardResolver.AddRequiredTargetFeature(tgt, it, &error)) {
36
0
        this->SetError(error);
37
0
        return false; // Not (successfully) handled.
38
0
      }
39
0
    }
40
0
    return true; // Successfully handled.
41
0
  }
42
43
  std::string Join(std::vector<std::string> const& content) override
44
0
  {
45
0
    return cmList::to_string(content);
46
0
  }
47
};
48
49
} // namespace
50
51
bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
52
                                    cmExecutionStatus& status)
53
0
{
54
0
  return TargetCompileFeaturesImpl(status).HandleArguments(args,
55
0
                                                           "COMPILE_FEATURES");
56
0
}