cmMakefile: Remove special handling of LINK_DIRECTORIES property.

There is no need to handle it in a special way.
This commit is contained in:
Stephen Kelly 2015-07-18 13:52:46 +02:00
parent 357342602d
commit 881613c4ab
4 changed files with 33 additions and 78 deletions

View File

@ -65,5 +65,5 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
unixPath = tmp; unixPath = tmp;
} }
} }
this->Makefile->AddLinkDirectory(unixPath); this->Makefile->AppendProperty("LINK_DIRECTORIES", unixPath.c_str());
} }

View File

@ -1520,31 +1520,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib)
this->AddLinkLibrary(lib,cmTarget::GENERAL); this->AddLinkLibrary(lib,cmTarget::GENERAL);
} }
void cmMakefile::AddLinkDirectory(const std::string& dir)
{
// Don't add a link directory that is already present. Yes, this
// linear search results in n^2 behavior, but n won't be getting
// much bigger than 20. We cannot use a set because of order
// dependency of the link search path.
if(dir.empty())
{
return;
}
std::string newdir = dir;
// remove trailing slashes
if(*dir.rbegin() == '/')
{
newdir = dir.substr(0, dir.size()-1);
}
if(std::find(this->LinkDirectories.begin(),
this->LinkDirectories.end(), newdir)
== this->LinkDirectories.end())
{
this->LinkDirectories.push_back(dir);
}
}
void cmMakefile::InitializeFromParent(cmMakefile* parent) void cmMakefile::InitializeFromParent(cmMakefile* parent)
{ {
// Initialize definitions with the closure of the parent scope. // Initialize definitions with the closure of the parent scope.
@ -1607,7 +1582,8 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
this->LinkLibraries = parent->LinkLibraries; this->LinkLibraries = parent->LinkLibraries;
// link directories // link directories
this->LinkDirectories = parent->LinkDirectories; this->SetProperty("LINK_DIRECTORIES",
parent->GetProperty("LINK_DIRECTORIES"));
// the initial project name // the initial project name
this->ProjectName = parent->ProjectName; this->ProjectName = parent->ProjectName;
@ -2145,11 +2121,26 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
return; return;
default:; default:;
} }
std::vector<std::string>::iterator j; if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES"))
for(j = this->LinkDirectories.begin();
j != this->LinkDirectories.end(); ++j)
{ {
target.AddLinkDirectory(*j); std::vector<std::string> linkDirs;
cmSystemTools::ExpandListArgument(linkDirsProp, linkDirs);
for(std::vector<std::string>::iterator j = linkDirs.begin();
j != linkDirs.end(); ++j)
{
std::string newdir = *j;
// remove trailing slashes
if(*j->rbegin() == '/')
{
newdir = j->substr(0, j->size()-1);
}
if(std::find(this->LinkDirectories.begin(),
this->LinkDirectories.end(), newdir)
== this->LinkDirectories.end())
{target.AddLinkDirectory(*j);
}
}
} }
target.MergeLinkLibraries( *this, name, this->LinkLibraries ); target.MergeLinkLibraries( *this, name, this->LinkLibraries );
} }
@ -2424,19 +2415,19 @@ void cmMakefile::ExpandVariablesCMP0019()
} }
} }
for(std::vector<std::string>::iterator d = this->LinkDirectories.begin(); if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES"))
d != this->LinkDirectories.end(); ++d)
{ {
if(mightExpandVariablesCMP0019(d->c_str())) if(mightExpandVariablesCMP0019(linkDirsProp))
{ {
std::string orig = *d; std::string d = linkDirsProp;
this->ExpandVariablesInString(*d, true, true); std::string orig = linkDirsProp;
if(pol == cmPolicies::WARN && *d != orig) this->ExpandVariablesInString(d, true, true);
if(pol == cmPolicies::WARN && d != orig)
{ {
w << "Evaluated link directory\n" w << "Evaluated link directories\n"
<< " " << orig << "\n" << " " << orig << "\n"
<< "as\n" << "as\n"
<< " " << *d << "\n"; << " " << d << "\n";
} }
} }
} }
@ -4147,16 +4138,6 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
void cmMakefile::SetProperty(const std::string& prop, const char* value) void cmMakefile::SetProperty(const std::string& prop, const char* value)
{ {
if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
if(value)
{
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
}
this->SetLinkDirectories(varArgsExpanded);
return;
}
if (prop == "INCLUDE_DIRECTORIES") if (prop == "INCLUDE_DIRECTORIES")
{ {
this->IncludeDirectoriesEntries.clear(); this->IncludeDirectoriesEntries.clear();
@ -4237,17 +4218,6 @@ void cmMakefile::AppendProperty(const std::string& prop,
cmValueWithOrigin(value, lfbt)); cmValueWithOrigin(value, lfbt));
return; return;
} }
if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
vi != varArgsExpanded.end(); ++vi)
{
this->AddLinkDirectory(*vi);
}
return;
}
this->Properties.AppendProperty(prop, value, asString); this->Properties.AppendProperty(prop, value, asString);
} }
@ -4300,11 +4270,6 @@ const char *cmMakefile::GetProperty(const std::string& prop,
this->GetListOfMacros(output); this->GetListOfMacros(output);
return output.c_str(); return output.c_str();
} }
else if (prop == "LINK_DIRECTORIES")
{
output = cmJoin(this->LinkDirectories, ";");
return output.c_str();
}
else if (prop == "INCLUDE_DIRECTORIES") else if (prop == "INCLUDE_DIRECTORIES")
{ {
std::string sep; std::string sep;

View File

@ -228,16 +228,6 @@ public:
cmTarget::LinkLibraryType type); cmTarget::LinkLibraryType type);
void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d); void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
/**
* Add a link directory to the build.
*/
void AddLinkDirectory(const std::string&);
void SetLinkDirectories(const std::vector<std::string>& vec)
{
this->LinkDirectories = vec;
}
/** /**
* Add a subdirectory to the build. * Add a subdirectory to the build.
*/ */

View File

@ -21,13 +21,13 @@ CMake Warning \(dev\) in CMakeLists.txt:
/usr/include/VAL_INCLUDE;/usr/include/normal /usr/include/VAL_INCLUDE;/usr/include/normal
Evaluated link directory Evaluated link directories
/usr/lib/\${VAR_LINK_DIRS} /usr/lib/\${VAR_LINK_DIRS};/usr/lib/normal
as as
/usr/lib/VAL_LINK_DIRS /usr/lib/VAL_LINK_DIRS;/usr/lib/normal
Evaluated link library Evaluated link library