summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/target_link_libraries
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-17 18:34:15 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-17 19:01:11 (GMT)
commit87f44b7525ebc9761b32b98f0c9e1276431e6ec1 (patch)
treebc9f85d94b060bcb9dc4765e94646959a9376e5b /Tests/RunCMake/target_link_libraries
parenta5a5a6857241c21d306661d723b749839f4c6e1a (diff)
downloadCMake-87f44b7525ebc9761b32b98f0c9e1276431e6ec1.zip
CMake-87f44b7525ebc9761b32b98f0c9e1276431e6ec1.tar.gz
CMake-87f44b7525ebc9761b32b98f0c9e1276431e6ec1.tar.bz2
Fix export of STATIC library PRIVATE non-target dependencies
In commit v3.5.0-rc1~43^2 (Fix export of STATIC library PRIVATE dependencies with CMP0022 NEW, 2016-01-15) we taught target_link_libraries to generate `$<LINK_ONLY:$<TARGET_NAME:dep>>` in INTERFACE_LINK_LIBRARIES instead of `$<LINK_ONLY:dep>` so that `dep` can be recognized as a target name and updated during export. However, this approach does not work when `dep` is just a plain library name and not a target because `$<TARGET_NAME:...>` requires the name of a reachable target. Since we do not know during target_link_libraries whether the name will correspond to a reachable target or not, we cannot inject the `$<TARGET_NAME:...>` expression. Revert this change and solve the original problem instead by teaching the export logic to recognize and update target names directly in `$<LINK_ONLY:...>` expressions. Reported-by: Ben Boeckel <ben.boeckel@kitware.com>
Diffstat (limited to 'Tests/RunCMake/target_link_libraries')
-rw-r--r--Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake7
-rw-r--r--Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake6
5 files changed, 17 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
index 8307607..1466fbf 100644
--- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
new file mode 100644
index 0000000..6bb44ab
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
@@ -0,0 +1 @@
+CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake
new file mode 100644
index 0000000..9b97918
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake
@@ -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)
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake
new file mode 100644
index 0000000..7122ae9
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake
@@ -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)