|
|
@@ -1207,71 +1207,6 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void cmMakefile::AddLinkLibrary(const std::string& lib,
|
|
|
- cmTargetLinkLibraryType llt)
|
|
|
-{
|
|
|
- cmTarget::LibraryID tmp;
|
|
|
- tmp.first = lib;
|
|
|
- tmp.second = llt;
|
|
|
- this->LinkLibraries.push_back(tmp);
|
|
|
-}
|
|
|
-
|
|
|
-void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
|
|
|
- const std::string& lib,
|
|
|
- cmTargetLinkLibraryType llt)
|
|
|
-{
|
|
|
- cmTargets::iterator i = this->Targets.find(target);
|
|
|
- if (i != this->Targets.end()) {
|
|
|
- cmTarget* tgt = this->GetGlobalGenerator()->FindTarget(lib);
|
|
|
- if (tgt) {
|
|
|
- // if it is not a static or shared library then you can not link to it
|
|
|
- if (!((tgt->GetType() == cmState::STATIC_LIBRARY) ||
|
|
|
- (tgt->GetType() == cmState::SHARED_LIBRARY) ||
|
|
|
- (tgt->GetType() == cmState::INTERFACE_LIBRARY) ||
|
|
|
- tgt->IsExecutableWithExports())) {
|
|
|
- std::ostringstream e;
|
|
|
- e << "Target \"" << lib << "\" of type "
|
|
|
- << cmState::GetTargetTypeName(tgt->GetType())
|
|
|
- << " may not be linked into another target. "
|
|
|
- << "One may link only to STATIC or SHARED libraries, or "
|
|
|
- << "to executables with the ENABLE_EXPORTS property set.";
|
|
|
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
- }
|
|
|
- }
|
|
|
- i->second.AddLinkLibrary(*this, target, lib, llt);
|
|
|
- } else {
|
|
|
- std::ostringstream e;
|
|
|
- e << "Attempt to add link library \"" << lib << "\" to target \"" << target
|
|
|
- << "\" which is not built in this directory.";
|
|
|
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
|
|
|
- const std::string& d)
|
|
|
-{
|
|
|
- cmTargets::iterator i = this->Targets.find(target);
|
|
|
- if (i != this->Targets.end()) {
|
|
|
- if (this->IsAlias(target)) {
|
|
|
- std::ostringstream e;
|
|
|
- e << "ALIAS target \"" << target << "\" "
|
|
|
- << "may not be linked into another target.";
|
|
|
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
- return;
|
|
|
- }
|
|
|
- i->second.AddLinkDirectory(d);
|
|
|
- } else {
|
|
|
- cmSystemTools::Error(
|
|
|
- "Attempt to add link directories to non-existent target: ",
|
|
|
- target.c_str(), " for directory ", d.c_str());
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void cmMakefile::AddLinkLibrary(const std::string& lib)
|
|
|
-{
|
|
|
- this->AddLinkLibrary(lib, GENERAL_LibraryType);
|
|
|
-}
|
|
|
-
|
|
|
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
|
|
{
|
|
|
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
|
|
@@ -1303,7 +1238,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
|
|
}
|
|
|
|
|
|
// link libraries
|
|
|
- this->LinkLibraries = parent->LinkLibraries;
|
|
|
+ this->SetProperty("LINK_LIBRARIES", parent->GetProperty("LINK_LIBRARIES"));
|
|
|
|
|
|
// link directories
|
|
|
this->SetProperty("LINK_DIRECTORIES",
|
|
|
@@ -1835,8 +1770,7 @@ void cmMakefile::SetProjectName(std::string const& p)
|
|
|
this->StateSnapshot.SetProjectName(p);
|
|
|
}
|
|
|
|
|
|
-void cmMakefile::AddGlobalLinkInformation(const std::string& name,
|
|
|
- cmTarget& target)
|
|
|
+void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
|
|
|
{
|
|
|
// for these targets do not add anything
|
|
|
switch (target.GetType()) {
|
|
|
@@ -1857,13 +1791,34 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
|
|
|
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.AddLinkDirectory(*j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
|
|
|
+ std::vector<std::string> linkLibs;
|
|
|
+ cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs);
|
|
|
+
|
|
|
+ for (std::vector<std::string>::iterator j = linkLibs.begin();
|
|
|
+ j != linkLibs.end(); ++j) {
|
|
|
+ std::string libraryName = *j;
|
|
|
+ cmTargetLinkLibraryType libType = GENERAL_LibraryType;
|
|
|
+ if (libraryName == "optimized") {
|
|
|
+ libType = OPTIMIZED_LibraryType;
|
|
|
+ ++j;
|
|
|
+ libraryName = *j;
|
|
|
+ } else if (libraryName == "debug") {
|
|
|
+ libType = DEBUG_LibraryType;
|
|
|
+ ++j;
|
|
|
+ libraryName = *j;
|
|
|
}
|
|
|
+ // This is equivalent to the target_link_libraries plain signature.
|
|
|
+ target.AddLinkLibrary(*this, libraryName, libType);
|
|
|
+ target.AppendProperty(
|
|
|
+ "INTERFACE_LINK_LIBRARIES",
|
|
|
+ target.GetDebugGeneratorExpressions(libraryName, libType).c_str());
|
|
|
}
|
|
|
}
|
|
|
- target.MergeLinkLibraries(*this, name, this->LinkLibraries);
|
|
|
}
|
|
|
|
|
|
void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName)
|
|
|
@@ -1877,14 +1832,9 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
|
|
|
const std::vector<std::string>& srcs,
|
|
|
bool excludeFromAll)
|
|
|
{
|
|
|
- // wrong type ? default to STATIC
|
|
|
- if ((type != cmState::STATIC_LIBRARY) && (type != cmState::SHARED_LIBRARY) &&
|
|
|
- (type != cmState::MODULE_LIBRARY) && (type != cmState::OBJECT_LIBRARY) &&
|
|
|
- (type != cmState::INTERFACE_LIBRARY)) {
|
|
|
- this->IssueMessage(cmake::INTERNAL_ERROR,
|
|
|
- "cmMakefile::AddLibrary given invalid target type.");
|
|
|
- type = cmState::STATIC_LIBRARY;
|
|
|
- }
|
|
|
+ assert(type == cmState::STATIC_LIBRARY || type == cmState::SHARED_LIBRARY ||
|
|
|
+ type == cmState::MODULE_LIBRARY || type == cmState::OBJECT_LIBRARY ||
|
|
|
+ type == cmState::INTERFACE_LIBRARY);
|
|
|
|
|
|
cmTarget* target = this->AddNewTarget(type, lname);
|
|
|
// Clear its dependencies. Otherwise, dependencies might persist
|
|
|
@@ -1895,7 +1845,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
|
|
|
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
|
|
}
|
|
|
target->AddSources(srcs);
|
|
|
- this->AddGlobalLinkInformation(lname, *target);
|
|
|
+ this->AddGlobalLinkInformation(*target);
|
|
|
return target;
|
|
|
}
|
|
|
|
|
|
@@ -1908,7 +1858,7 @@ cmTarget* cmMakefile::AddExecutable(const char* exeName,
|
|
|
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
|
|
}
|
|
|
target->AddSources(srcs);
|
|
|
- this->AddGlobalLinkInformation(exeName, *target);
|
|
|
+ this->AddGlobalLinkInformation(*target);
|
|
|
return target;
|
|
|
}
|
|
|
|
|
|
@@ -2125,19 +2075,32 @@ void cmMakefile::ExpandVariablesCMP0019()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for (cmTarget::LinkLibraryVectorType::iterator l =
|
|
|
- this->LinkLibraries.begin();
|
|
|
- l != this->LinkLibraries.end(); ++l) {
|
|
|
- if (mightExpandVariablesCMP0019(l->first.c_str())) {
|
|
|
- std::string orig = l->first;
|
|
|
- this->ExpandVariablesInString(l->first, true, true);
|
|
|
- if (pol == cmPolicies::WARN && l->first != orig) {
|
|
|
- /* clang-format off */
|
|
|
+
|
|
|
+ if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
|
|
|
+ std::vector<std::string> linkLibs;
|
|
|
+ cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs);
|
|
|
+
|
|
|
+ for (std::vector<std::string>::iterator l = linkLibs.begin();
|
|
|
+ l != linkLibs.end(); ++l) {
|
|
|
+ std::string libName = *l;
|
|
|
+ if (libName == "optimized") {
|
|
|
+ ++l;
|
|
|
+ libName = *l;
|
|
|
+ } else if (libName == "debug") {
|
|
|
+ ++l;
|
|
|
+ libName = *l;
|
|
|
+ }
|
|
|
+ if (mightExpandVariablesCMP0019(libName.c_str())) {
|
|
|
+ std::string orig = libName;
|
|
|
+ this->ExpandVariablesInString(libName, true, true);
|
|
|
+ if (pol == cmPolicies::WARN && libName != orig) {
|
|
|
+ /* clang-format off */
|
|
|
w << "Evaluated link library\n"
|
|
|
<< " " << orig << "\n"
|
|
|
<< "as\n"
|
|
|
- << " " << l->first << "\n";
|
|
|
- /* clang-format on */
|
|
|
+ << " " << libName << "\n";
|
|
|
+ /* clang-format on */
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|