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