mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Fix export of STATIC library PRIVATE dependencies with CMP0022 NEW
The target_link_libraries command records the PRIVATE dependencies of a STATIC library in INTERFACE_LINK_LIBRARIES as "$<LINK_ONLY:dep>". This hides the target name from export namespacing logic inside a generator expression. When user-written generator expressions reference a target name they must put it inside a "$<TARGET_NAME:dep>" expression to allow the export logic to rename the target. In the case that the private dependency is not already a generator expression, target_link_libraries must use "$<LINK_ONLY:$<TARGET_NAME:dep>>" to allow the export logic to rename the target. Reported-by: Tamás Kenéz <tamas.kenez@gmail.com>
This commit is contained in:
@@ -432,8 +432,11 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
|
||||
{
|
||||
std::string configLib = this->Target
|
||||
->GetDebugGeneratorExpressions(lib, llt);
|
||||
if (cmGeneratorExpression::IsValidTargetName(lib)
|
||||
|| cmGeneratorExpression::Find(lib) != std::string::npos)
|
||||
if (cmGeneratorExpression::IsValidTargetName(configLib))
|
||||
{
|
||||
configLib = "$<LINK_ONLY:$<TARGET_NAME:" + configLib + ">>";
|
||||
}
|
||||
else if (cmGeneratorExpression::Find(configLib) != std::string::npos)
|
||||
{
|
||||
configLib = "$<LINK_ONLY:" + configLib + ">";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user