/src/CMake/Source/cmLinkLibrariesCommand.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 "cmLinkLibrariesCommand.h" |
4 | | |
5 | | #include "cmDiagnostics.h" |
6 | | #include "cmExecutionStatus.h" |
7 | | #include "cmMakefile.h" |
8 | | |
9 | | bool cmLinkLibrariesCommand(std::vector<std::string> const& args, |
10 | | cmExecutionStatus& status) |
11 | 0 | { |
12 | 0 | cmMakefile& mf = status.GetMakefile(); |
13 | |
|
14 | 0 | mf.IssueDiagnostic(cmDiagnostics::CMD_NON_TARGET_DIRECTIVE, |
15 | 0 | "Use of non-target directives is not recommended. " |
16 | 0 | "Consider target_link_libraries instead."); |
17 | |
|
18 | 0 | if (args.empty()) { |
19 | 0 | return true; |
20 | 0 | } |
21 | | |
22 | | // add libraries, note that there is an optional prefix |
23 | | // of debug and optimized than can be used |
24 | 0 | for (auto i = args.begin(); i != args.end(); ++i) { |
25 | 0 | if (*i == "debug") { |
26 | 0 | ++i; |
27 | 0 | if (i == args.end()) { |
28 | 0 | status.SetError("The \"debug\" argument must be followed by " |
29 | 0 | "a library"); |
30 | 0 | return false; |
31 | 0 | } |
32 | 0 | mf.AppendProperty("LINK_LIBRARIES", "debug"); |
33 | 0 | } else if (*i == "optimized") { |
34 | 0 | ++i; |
35 | 0 | if (i == args.end()) { |
36 | 0 | status.SetError("The \"optimized\" argument must be followed by " |
37 | 0 | "a library"); |
38 | 0 | return false; |
39 | 0 | } |
40 | 0 | mf.AppendProperty("LINK_LIBRARIES", "optimized"); |
41 | 0 | } |
42 | 0 | mf.AppendProperty("LINK_LIBRARIES", *i); |
43 | 0 | } |
44 | | |
45 | 0 | return true; |
46 | 0 | } |