/src/CMake/Source/cmLinkDirectoriesCommand.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 "cmLinkDirectoriesCommand.h" |
4 | | |
5 | | #include "cmExecutionStatus.h" |
6 | | #include "cmGeneratorExpression.h" |
7 | | #include "cmList.h" |
8 | | #include "cmMakefile.h" |
9 | | #include "cmStringAlgorithms.h" |
10 | | #include "cmSystemTools.h" |
11 | | |
12 | | static void AddLinkDir(cmMakefile& mf, std::string const& dir, |
13 | | std::vector<std::string>& directories); |
14 | | |
15 | | bool cmLinkDirectoriesCommand(std::vector<std::string> const& args, |
16 | | cmExecutionStatus& status) |
17 | 0 | { |
18 | 0 | if (args.empty()) { |
19 | 0 | return true; |
20 | 0 | } |
21 | | |
22 | 0 | cmMakefile& mf = status.GetMakefile(); |
23 | 0 | bool before = mf.IsOn("CMAKE_LINK_DIRECTORIES_BEFORE"); |
24 | |
|
25 | 0 | auto i = args.cbegin(); |
26 | 0 | if ((*i) == "BEFORE") { |
27 | 0 | before = true; |
28 | 0 | ++i; |
29 | 0 | } else if ((*i) == "AFTER") { |
30 | 0 | before = false; |
31 | 0 | ++i; |
32 | 0 | } |
33 | |
|
34 | 0 | std::vector<std::string> directories; |
35 | 0 | for (; i != args.cend(); ++i) { |
36 | 0 | AddLinkDir(mf, *i, directories); |
37 | 0 | } |
38 | |
|
39 | 0 | mf.AddLinkDirectory(cmList::to_string(directories), before); |
40 | |
|
41 | 0 | return true; |
42 | 0 | } |
43 | | |
44 | | static void AddLinkDir(cmMakefile& mf, std::string const& dir, |
45 | | std::vector<std::string>& directories) |
46 | 0 | { |
47 | 0 | std::string unixPath = dir; |
48 | 0 | cmSystemTools::ConvertToUnixSlashes(unixPath); |
49 | 0 | if (!cmSystemTools::FileIsFullPath(unixPath) && |
50 | 0 | !cmGeneratorExpression::StartsWithGeneratorExpression(unixPath)) { |
51 | 0 | unixPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', unixPath); |
52 | 0 | } |
53 | 0 | directories.push_back(unixPath); |
54 | 0 | } |