Commit 2321e637 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'fix-static-private-non-target-depends'

87f44b75 Fix export of STATIC library PRIVATE non-target dependencies
parents 1b369aa2 87f44b75
......@@ -772,6 +772,27 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
lastPos = endPos;
}
pos = 0;
lastPos = pos;
while (errorString.empty() &&
(pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos)
{
std::string::size_type nameStartPos = pos + sizeof("$<LINK_ONLY:") - 1;
std::string::size_type endPos = input.find(">", nameStartPos);
if (endPos == input.npos)
{
errorString = "$<LINK_ONLY:...> expression incomplete";
break;
}
std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
if (cmGeneratorExpression::IsValidTargetName(libName) &&
this->AddTargetNamespace(libName, target, missingTargets))
{
input.replace(nameStartPos, endPos - nameStartPos, libName);
}
lastPos = nameStartPos + libName.size() + 1;
}
this->ReplaceInstallPrefix(input);
if (!errorString.empty())
......
......@@ -432,11 +432,8 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
{
std::string configLib = this->Target
->GetDebugGeneratorExpressions(lib, llt);
if (cmGeneratorExpression::IsValidTargetName(configLib))
{
configLib = "$<LINK_ONLY:$<TARGET_NAME:" + configLib + ">>";
}
else if (cmGeneratorExpression::Find(configLib) != std::string::npos)
if (cmGeneratorExpression::IsValidTargetName(lib)
|| cmGeneratorExpression::Find(lib) != std::string::npos)
{
configLib = "$<LINK_ONLY:" + configLib + ">";
}
......
......@@ -8,3 +8,5 @@ run_cmake(MixedSignature)
run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
run_cmake(SubDirTarget)
run_cmake(SharedDepNotTarget)
run_cmake(StaticPrivateDepNotExported)
run_cmake(StaticPrivateDepNotTarget)
CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.
cmake_policy(SET CMP0022 NEW)
enable_language(C)
add_library(foo STATIC empty.c)
add_library(not_exported STATIC empty.c)
target_link_libraries(foo PRIVATE not_exported)
install(TARGETS foo EXPORT Exp DESTINATION lib)
install(EXPORT Exp DESTINATION lib/cmake/Exp)
cmake_policy(SET CMP0022 NEW)
enable_language(C)
add_library(foo STATIC empty.c)
target_link_libraries(foo PRIVATE not_a_target)
install(TARGETS foo EXPORT Exp DESTINATION lib)
install(EXPORT Exp DESTINATION lib/cmake/Exp)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment