Merge branch 'out-of-dir-linking-private-deps' into release-3.14

Merge-request: !3276
This commit is contained in:
Brad King 2019-04-30 13:56:08 -04:00
commit b947113b42
5 changed files with 32 additions and 2 deletions

View File

@ -456,8 +456,8 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) { this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::string configLib = std::string configLib =
this->Target->GetDebugGeneratorExpressions(libRef, llt); this->Target->GetDebugGeneratorExpressions(libRef, llt);
if (cmGeneratorExpression::IsValidTargetName(libRef) || if (cmGeneratorExpression::IsValidTargetName(lib) ||
cmGeneratorExpression::Find(libRef) != std::string::npos) { cmGeneratorExpression::Find(lib) != std::string::npos) {
configLib = "$<LINK_ONLY:" + configLib + ">"; configLib = "$<LINK_ONLY:" + configLib + ">";
} }
this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",

View File

@ -134,11 +134,15 @@ assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib")
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Test cross-directory linking. # Test cross-directory linking.
cmake_policy(PUSH) cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0079 NEW) cmake_policy(SET CMP0079 NEW)
add_executable(TopDir TopDir.c) add_executable(TopDir TopDir.c)
add_subdirectory(SubDirA) add_subdirectory(SubDirA)
add_subdirectory(SubDirB) add_subdirectory(SubDirB)
target_link_libraries(SubDirB TopDirImported) target_link_libraries(SubDirB TopDirImported)
add_subdirectory(SubDirC)
target_link_libraries(SubDirC PRIVATE SubDirC2)
target_link_libraries(TopDir SubDirC)
add_library(TopDirImported IMPORTED INTERFACE) add_library(TopDirImported IMPORTED INTERFACE)
target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported) target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported)
cmake_policy(POP) cmake_policy(POP)

View File

@ -0,0 +1,9 @@
add_library(SubDirC STATIC SubDirC.c)
add_library(SubDirC1 INTERFACE)
target_compile_definitions(SubDirC1 INTERFACE DEF_SubDirC1)
add_library(SubDirC2 INTERFACE)
target_compile_definitions(SubDirC2 INTERFACE DEF_SubDirC2)
target_link_libraries(SubDirC PRIVATE SubDirC1)

View File

@ -0,0 +1,11 @@
#ifndef DEF_SubDirC1
# error "DEF_SubDirC1 not defined"
#endif
#ifndef DEF_SubDirC2
# error "DEF_SubDirC2 not defined"
#endif
int SubDirC(void)
{
return 0;
}

View File

@ -7,6 +7,12 @@
#ifdef DEF_TopDirImported #ifdef DEF_TopDirImported
# error "DEF_TopDirImported is defined but should not be!" # error "DEF_TopDirImported is defined but should not be!"
#endif #endif
#ifdef DEF_SubDirC1
# error "DEF_SubDirC1 defined but should not be"
#endif
#ifdef DEF_SubDirC2
# error "DEF_SubDirC2 defined but should not be"
#endif
int main(void) int main(void)
{ {