summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-01-15 15:02:52 (GMT)
committerBrad King <brad.king@kitware.com>2016-01-15 15:18:53 (GMT)
commitaea1b03617bed037bbd12af36d7ef92feff0ba74 (patch)
tree818a548be8f6d180879ddb2b1c83a126fec55707 /Tests/ExportImport
parente5cbec14a5aec9203bd0e29fa0172fa00c97e521 (diff)
downloadCMake-aea1b03617bed037bbd12af36d7ef92feff0ba74.zip
CMake-aea1b03617bed037bbd12af36d7ef92feff0ba74.tar.gz
CMake-aea1b03617bed037bbd12af36d7ef92feff0ba74.tar.bz2
Fix export of STATIC library PRIVATE dependencies with CMP0022 NEW
The target_link_libraries command records the PRIVATE dependencies of a STATIC library in INTERFACE_LINK_LIBRARIES as "$<LINK_ONLY:dep>". This hides the target name from export namespacing logic inside a generator expression. When user-written generator expressions reference a target name they must put it inside a "$<TARGET_NAME:dep>" expression to allow the export logic to rename the target. In the case that the private dependency is not already a generator expression, target_link_libraries must use "$<LINK_ONLY:$<TARGET_NAME:dep>>" to allow the export logic to rename the target. Reported-by: Tamás Kenéz <tamas.kenez@gmail.com>
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt6
-rw-r--r--Tests/ExportImport/Export/testLibDepends.c7
-rw-r--r--Tests/ExportImport/Export/testStaticLibRequiredPrivate.c1
3 files changed, 13 insertions, 1 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 9c50d6c..c2ecb0b 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -136,6 +136,8 @@ cmake_policy(SET CMP0022 NEW)
add_library(testLibRequired testLibRequired.c)
add_library(testLibDepends testLibDepends.c)
target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired)
+add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c)
+target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate)
cmake_policy(POP)
macro(add_include_lib _libName)
@@ -394,6 +396,10 @@ install(TARGETS
INCLUDES DESTINATION
$<INSTALL_PREFIX>/include/$<TARGET_PROPERTY:NAME>
)
+install(TARGETS
+ testStaticLibRequiredPrivate
+ EXPORT RequiredExp DESTINATION lib
+)
install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest")
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index fb5a002..3c7774ee 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -16,5 +16,10 @@
#endif
extern int testLibRequired(void);
+extern int testStaticLibRequiredPrivate(void);
-int testLibDepends(void) { return testLibRequired(); }
+int testLibDepends(void) {
+ return testLibRequired()
+ + testStaticLibRequiredPrivate()
+ ;
+}
diff --git a/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
new file mode 100644
index 0000000..28a2675
--- /dev/null
+++ b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
@@ -0,0 +1 @@
+int testStaticLibRequiredPrivate(void) { return 0; }