Coverage Report

Created: 2026-04-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmEnableLanguageCommand.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 "cmEnableLanguageCommand.h"
4
5
#include "cmDiagnostics.h"
6
#include "cmExecutionStatus.h"
7
#include "cmMakefile.h"
8
#include "cmMessageType.h"
9
#include "cmPolicies.h"
10
#include "cmSystemTools.h"
11
12
bool cmEnableLanguageCommand(std::vector<std::string> const& args,
13
                             cmExecutionStatus& status)
14
0
{
15
0
  if (args.empty()) {
16
0
    status.SetError("called with incorrect number of arguments");
17
0
    return false;
18
0
  }
19
20
0
  cmMakefile& mf = status.GetMakefile();
21
0
  if (!mf.IsNormalDefinitionSet("PROJECT_NAME")) {
22
0
    switch (mf.GetPolicyStatus(cmPolicies::CMP0165)) {
23
0
      case cmPolicies::WARN:
24
0
        mf.IssueDiagnostic(
25
0
          cmDiagnostics::CMD_AUTHOR,
26
0
          "project() should be called prior to this enable_language() call.");
27
0
        break;
28
0
      case cmPolicies::OLD:
29
0
        break;
30
0
      case cmPolicies::NEW:
31
0
        mf.IssueMessage(
32
0
          MessageType::FATAL_ERROR,
33
0
          "project() must be called prior to this enable_language() call.");
34
0
        cmSystemTools::SetFatalErrorOccurred();
35
0
        return false;
36
0
      default:
37
0
        break;
38
0
    }
39
0
  }
40
41
0
  bool optional = false;
42
0
  std::vector<std::string> languages;
43
0
  for (std::string const& it : args) {
44
0
    if (it == "OPTIONAL") {
45
0
      optional = true;
46
0
    } else {
47
0
      languages.push_back(it);
48
0
    }
49
0
  }
50
51
0
  mf.EnableLanguage(languages, optional);
52
0
  return true;
53
0
}