2016-10-30 18:24:19 +01:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-10-12 18:41:06 +02:00
|
|
|
#include "cmLinkDirectoriesCommand.h"
|
|
|
|
|
2017-04-14 19:02:05 +02:00
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmPolicies.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
|
|
|
class cmExecutionStatus;
|
|
|
|
|
2008-10-12 18:41:06 +02:00
|
|
|
// cmLinkDirectoriesCommand
|
2016-07-09 11:21:54 +02:00
|
|
|
bool cmLinkDirectoriesCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2008-10-12 18:41:06 +02:00
|
|
|
{
|
2016-10-30 18:24:19 +01:00
|
|
|
if (args.empty()) {
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2008-10-12 18:41:06 +02:00
|
|
|
|
2018-01-26 17:06:56 +01:00
|
|
|
for (std::string const& i : args) {
|
|
|
|
this->AddLinkDir(i);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-17 14:00:29 +02:00
|
|
|
void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
|
|
|
|
{
|
|
|
|
std::string unixPath = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(unixPath);
|
2018-04-23 21:13:27 +02:00
|
|
|
if (!cmSystemTools::FileIsFullPath(unixPath)) {
|
2010-03-17 14:00:29 +02:00
|
|
|
bool convertToAbsolute = false;
|
2015-04-27 22:25:09 +02:00
|
|
|
std::ostringstream e;
|
2016-07-09 11:21:54 +02:00
|
|
|
/* clang-format off */
|
2010-03-17 14:00:29 +02:00
|
|
|
e << "This command specifies the relative path\n"
|
|
|
|
<< " " << unixPath << "\n"
|
|
|
|
<< "as a link directory.\n";
|
2016-07-09 11:21:54 +02:00
|
|
|
/* clang-format on */
|
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) {
|
2010-03-17 14:00:29 +02:00
|
|
|
case cmPolicies::WARN:
|
2015-08-17 11:37:30 +02:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015);
|
2010-03-17 14:00:29 +02:00
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior does not convert
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2015-08-17 11:37:30 +02:00
|
|
|
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0015);
|
2010-03-17 14:00:29 +02:00
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2017-07-20 19:35:53 +02:00
|
|
|
CM_FALLTHROUGH;
|
2010-03-17 14:00:29 +02:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior converts
|
|
|
|
convertToAbsolute = true;
|
|
|
|
break;
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
|
|
|
if (convertToAbsolute) {
|
2015-08-17 11:37:30 +02:00
|
|
|
std::string tmp = this->Makefile->GetCurrentSourceDirectory();
|
2010-03-17 14:00:29 +02:00
|
|
|
tmp += "/";
|
|
|
|
tmp += unixPath;
|
|
|
|
unixPath = tmp;
|
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2015-11-17 17:22:37 +01:00
|
|
|
this->Makefile->AppendProperty("LINK_DIRECTORIES", unixPath.c_str());
|
2010-03-17 14:00:29 +02:00
|
|
|
}
|