summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-30 17:55:48 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-30 17:55:48 (GMT)
commitc9469c78a5545b5a04ecf0f27b50500140aca5e9 (patch)
tree66a11ea1a6fc46fa1c03d6a96a32e39176fe0d90
parent0c2469e3fbf359934f266aa5dbcc69d78a618bab (diff)
parent3d3713121b55320ce8031b838ba5ca5b844f2975 (diff)
downloadCMake-c9469c78a5545b5a04ecf0f27b50500140aca5e9.zip
CMake-c9469c78a5545b5a04ecf0f27b50500140aca5e9.tar.gz
CMake-c9469c78a5545b5a04ecf0f27b50500140aca5e9.tar.bz2
Merge branch 'out-of-dir-linking-private-deps' into release-3.13
Merge-request: !3276
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx4
-rw-r--r--Tests/CMakeCommands/target_link_libraries/CMakeLists.txt4
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt9
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c11
-rw-r--r--Tests/CMakeCommands/target_link_libraries/TopDir.c6
5 files changed, 32 insertions, 2 deletions
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index ad33f98..ded6831 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -452,8 +452,8 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY) {
std::string configLib =
this->Target->GetDebugGeneratorExpressions(libRef, llt);
- if (cmGeneratorExpression::IsValidTargetName(libRef) ||
- cmGeneratorExpression::Find(libRef) != std::string::npos) {
+ if (cmGeneratorExpression::IsValidTargetName(lib) ||
+ cmGeneratorExpression::Find(lib) != std::string::npos) {
configLib = "$<LINK_ONLY:" + configLib + ">";
}
this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 85ce1f7..5c704ac 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -134,11 +134,15 @@ assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib")
#----------------------------------------------------------------------------
# Test cross-directory linking.
cmake_policy(PUSH)
+cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0079 NEW)
add_executable(TopDir TopDir.c)
add_subdirectory(SubDirA)
add_subdirectory(SubDirB)
target_link_libraries(SubDirB TopDirImported)
+add_subdirectory(SubDirC)
+target_link_libraries(SubDirC PRIVATE SubDirC2)
+target_link_libraries(TopDir SubDirC)
add_library(TopDirImported IMPORTED INTERFACE)
target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported)
cmake_policy(POP)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
new file mode 100644
index 0000000..54bcc51
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
@@ -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)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
new file mode 100644
index 0000000..c5536dc
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
@@ -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;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/TopDir.c b/Tests/CMakeCommands/target_link_libraries/TopDir.c
index 4706bb9..d8066e5 100644
--- a/Tests/CMakeCommands/target_link_libraries/TopDir.c
+++ b/Tests/CMakeCommands/target_link_libraries/TopDir.c
@@ -7,6 +7,12 @@
#ifdef DEF_TopDirImported
# error "DEF_TopDirImported is defined but should not be!"
#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)
{