Merge topic 'fix-tll-static-private'
239b0c6
Don't add invalid content to static lib INTERFACE_LINK_LIBRARIES.
This commit is contained in:
commit
1b21ac405f
|
@ -985,15 +985,20 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf,
|
|||
i += this->PrevLinkedLibraries.size();
|
||||
for( ; i != libs.end(); ++i )
|
||||
{
|
||||
const char *lib = i->first.c_str();
|
||||
// We call this so that the dependencies get written to the cache
|
||||
this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second );
|
||||
this->AddLinkLibrary( mf, selfname, lib, i->second );
|
||||
|
||||
if (this->GetType() == cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
this->AppendProperty("INTERFACE_LINK_LIBRARIES",
|
||||
("$<LINK_ONLY:" +
|
||||
this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) +
|
||||
">").c_str());
|
||||
std::string configLib = this->GetDebugGeneratorExpressions(lib,
|
||||
i->second);
|
||||
if (cmGeneratorExpression::IsValidTargetName(lib)
|
||||
|| cmGeneratorExpression::Find(lib) != std::string::npos)
|
||||
{
|
||||
configLib = "$<LINK_ONLY:" + configLib + ">";
|
||||
}
|
||||
this->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib.c_str());
|
||||
}
|
||||
}
|
||||
this->PrevLinkedLibraries = libs;
|
||||
|
|
|
@ -395,10 +395,15 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
|
|||
{
|
||||
if (this->Target->GetType() == cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
std::string configLib = this->Target
|
||||
->GetDebugGeneratorExpressions(lib, llt);
|
||||
if (cmGeneratorExpression::IsValidTargetName(lib)
|
||||
|| cmGeneratorExpression::Find(lib) != std::string::npos)
|
||||
{
|
||||
configLib = "$<LINK_ONLY:" + configLib + ">";
|
||||
}
|
||||
this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
|
||||
("$<LINK_ONLY:" +
|
||||
this->Target->GetDebugGeneratorExpressions(lib, llt) +
|
||||
">").c_str());
|
||||
configLib.c_str());
|
||||
}
|
||||
// Not a 'public' or 'interface' library. Do not add to interface
|
||||
// property.
|
||||
|
|
|
@ -22,6 +22,9 @@ generate_export_header(staticlib1)
|
|||
add_library(staticlib2 STATIC staticlib2.cpp)
|
||||
generate_export_header(staticlib2)
|
||||
target_link_libraries(staticlib1 LINK_PUBLIC staticlib2)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
target_link_libraries(staticlib1 LINK_PRIVATE "-Wl,-v")
|
||||
endif()
|
||||
|
||||
add_executable(staticlib_exe staticlib_exe.cpp)
|
||||
target_link_libraries(staticlib_exe staticlib1)
|
||||
|
|
|
@ -5,4 +5,8 @@ add_library(foo STATIC empty_vs6_1.cpp)
|
|||
add_library(bar STATIC empty_vs6_2.cpp)
|
||||
add_library(bat STATIC empty_vs6_3.cpp)
|
||||
target_link_libraries(foo bar)
|
||||
target_link_libraries(bar bat)
|
||||
# The last element here needs to contain a space so that it is a single
|
||||
# element which is not a valid target name. As bar is a STATIC library,
|
||||
# this tests that the LINK_ONLY generator expression is not used for
|
||||
# that element, creating an error.
|
||||
target_link_libraries(bar bat "-lz -lm")
|
||||
|
|
Loading…
Reference in New Issue