Merge topic 'fix-static-private-non-target-depends'
87f44b75
Fix export of STATIC library PRIVATE non-target dependencies
This commit is contained in:
commit
2321e63734
|
@ -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)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1 @@
|
|||
CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.
|
|
@ -0,0 +1,7 @@
|
|||
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)
|
|
@ -0,0 +1,6 @@
|
|||
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)
|
Loading…
Reference in New Issue