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

87f44b75 Fix export of STATIC library PRIVATE non-target dependencies
This commit is contained in:
Brad King 2016-02-18 10:08:01 -05:00 committed by CMake Topic Stage
commit 2321e63734
7 changed files with 40 additions and 5 deletions

View File

@ -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())

View File

@ -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 + ">";
}

View File

@ -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)

View File

@ -0,0 +1 @@
CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.

View File

@ -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)

View File

@ -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)