summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-11-01 14:27:05 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2022-02-07 23:02:32 (GMT)
commit42965799b4747ab1e0afa6546be13444f68c1987 (patch)
tree6149298a0fc9fd0f836cbe92b602d6eb863dc581 /Tests
parent78dd7d5292cef930b3d435e6901cc3b10ee02513 (diff)
downloadCMake-42965799b4747ab1e0afa6546be13444f68c1987.zip
CMake-42965799b4747ab1e0afa6546be13444f68c1987.tar.gz
CMake-42965799b4747ab1e0afa6546be13444f68c1987.tar.bz2
Genex: Add $<LINK_LIBRARY:...>
This generator expression offers the capability, for the link step, to decorate libraries with prefix/suffix flags and/or adding any specific flag for each library. Fixes: #22812, #18751, #20078, #22703
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt12
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake25
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake4
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake3
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake5
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt5
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake8
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake15
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt8
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake4
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c0
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt5
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt16
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-stderr.txt6
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features.cmake15
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt14
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake15
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake5
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake11
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt8
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake14
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt8
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake4
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt13
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake16
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake4
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake81
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake73
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c9
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt18
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake18
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c15
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c18
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c8
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake20
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake34
106 files changed, 789 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1d7e632..d1a1ddd 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -312,6 +312,7 @@ add_RunCMake_test(GenEx-LINK_LANGUAGE)
add_RunCMake_test(GenEx-LINK_LANG_AND_ID)
add_RunCMake_test(GenEx-HOST_LINK)
add_RunCMake_test(GenEx-DEVICE_LINK)
+add_RunCMake_test(GenEx-LINK_LIBRARY)
add_RunCMake_test(GenEx-TARGET_FILE -DLINKER_SUPPORTS_PDB=${LINKER_SUPPORTS_PDB})
add_RunCMake_test(GenEx-GENEX_EVAL)
add_RunCMake_test(GenEx-TARGET_RUNTIME_DLLS)
@@ -652,6 +653,17 @@ add_RunCMake_test(target_link_libraries)
add_RunCMake_test(target_link_libraries-ALIAS)
add_RunCMake_test(target_link_libraries-LINK_LANGUAGE)
add_RunCMake_test(target_link_libraries-LINK_LANG_AND_ID)
+add_RunCMake_test(target_link_libraries-LINK_LIBRARY -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DMINGW=${MINGW}
+ -DMSYS=${MSYS}
+ -DCYGWIN=${CYGWIN}
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DMSVC_VERSION=${MSVC_VERSION}
+ -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}
+ -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}
+ -DCMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}
+ -DCMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}
+ -DCMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG})
add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
-DCMake_TEST_CUDA=${CMake_TEST_CUDA})
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt
new file mode 100644
index 0000000..612169c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.18...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake
new file mode 100644
index 0000000..ab1ac37
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake
@@ -0,0 +1,25 @@
+include(RunCMake)
+
+run_cmake(add_custom_target)
+run_cmake(add_custom_command)
+run_cmake(add_link_options)
+run_cmake(link_directories)
+run_cmake(target_link_options)
+run_cmake(target_link_directories)
+run_cmake(no-arguments)
+run_cmake(empty-arguments)
+run_cmake(forbidden-arguments)
+run_cmake(bad-feature1)
+run_cmake(bad-feature2)
+run_cmake(bad-feature3)
+run_cmake(bad-feature4)
+run_cmake(bad-feature5)
+run_cmake(bad-feature6)
+run_cmake(bad-feature7)
+run_cmake(feature-not-supported)
+run_cmake(library-ignored)
+run_cmake(compatible-features)
+run_cmake(incompatible-features)
+run_cmake(nested-compatible-features)
+run_cmake(nested-incompatible-features)
+run_cmake(only-targets)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt
new file mode 100644
index 0000000..d8ff0eb
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_command.cmake:[0-9]+ \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake
new file mode 100644
index 0000000..3583a67
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake
@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt
new file mode 100644
index 0000000..8ca384d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_target.cmake:[0-9]+ \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake
new file mode 100644
index 0000000..ef00965
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake
@@ -0,0 +1,3 @@
+add_custom_target(drive
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt
new file mode 100644
index 0000000..399a413
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_link_options.cmake:[0-9]+ \(add_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake
new file mode 100644
index 0000000..fdccf95
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_link_options("$<LINK_LIBRARY:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt
new file mode 100644
index 0000000..0ff8aca
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\):
+ Feature 'bad_feat', specified through generator-expression
+ '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link
+ language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake
new file mode 100644
index 0000000..5e540cf
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:bad_feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt
new file mode 100644
index 0000000..9e878cc
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at bad-feature2.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to
+ link target 'lib', is not defined for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake
new file mode 100644
index 0000000..15b5ca0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt
new file mode 100644
index 0000000..69963fe
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature3.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are
+ missing\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake
new file mode 100644
index 0000000..7960465
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt
new file mode 100644
index 0000000..7385115
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature4.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are
+ missing\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake
new file mode 100644
index 0000000..b40cfaf
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "-opt")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt
new file mode 100644
index 0000000..9894577
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature5.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_USING_feat', is
+ malformed \(wrong number of elements\) and cannot be used to link target
+ 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake
new file mode 100644
index 0000000..8ce1ecf
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "-prefix" "<LIBRARY>")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt
new file mode 100644
index 0000000..d8d0e19
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature6.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing
+ for "PATH{}" alternative\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake
new file mode 100644
index 0000000..7b72ad5
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "PATH{}NAME{<LIBRARY>}")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt
new file mode 100644
index 0000000..2a498cd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature7.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing
+ for "NAME{}" alternative\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake
new file mode 100644
index 0000000..173f86c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "NAME{}PATH{<LIBRARY>}")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake
new file mode 100644
index 0000000..e79764c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PRIVATE "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt
new file mode 100644
index 0000000..1530f61
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:,>
+
+ \$<LINK_LIBRARY:...> expects a feature name as first argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake
new file mode 100644
index 0000000..c6e2260
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:,>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt
new file mode 100644
index 0000000..6067bce
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at feature-not-supported.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to
+ link target 'lib', is not supported for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake
new file mode 100644
index 0000000..0666227
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED FALSE)
+set(CMAKE_C_LINK_USING_feat "<LIBRARY>")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt
new file mode 100644
index 0000000..5245dd8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>".
+ The LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>".
+ The LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake
new file mode 100644
index 0000000..1c51c44
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+link_libraries(<LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE <LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-stderr.txt
new file mode 100644
index 0000000..22219a2
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-features.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib' because the link item 'dep1', specified
+ with the feature 'feat1', has already occurred with the feature 'feat2',
+ which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features.cmake
new file mode 100644
index 0000000..d96b214
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt
new file mode 100644
index 0000000..f9a99af
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt
@@ -0,0 +1,14 @@
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_LIBRARY:feat>', will not be applied to the INTERFACE library
+ 'front'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_LIBRARY:feat>', will not be applied to the OBJECT library 'dep'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake
new file mode 100644
index 0000000..e000b97
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat "<LIBRARY>")
+
+add_library(dep OBJECT empty.c)
+
+add_library(lib SHARED empty.c)
+
+add_library(front INTERFACE)
+target_link_libraries(front INTERFACE lib)
+
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat,front,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt
new file mode 100644
index 0000000..aeb32f2
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at link_directories.cmake:[0-9]+ \(link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake
new file mode 100644
index 0000000..b6d9a36
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+link_directories("$<LINK_LIBRARY:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake
new file mode 100644
index 0000000..d3b04e8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake
@@ -0,0 +1,11 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat1 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat1,dep1,$<LINK_LIBRARY:feat1,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt
new file mode 100644
index 0000000..3f6c504
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at nested-incompatible-features.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat2,dep1,\$<LINK_LIBRARY:feat1,dep2>>
+
+ \$<LINK_LIBRARY:...> with different features cannot be nested.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake
new file mode 100644
index 0000000..8565fa9
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,$<LINK_LIBRARY:feat1,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt
new file mode 100644
index 0000000..af58fa0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY>
+
+ \$<LINK_LIBRARY> expression requires at least one parameter.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake
new file mode 100644
index 0000000..0645dc7
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt
new file mode 100644
index 0000000..6b770f0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt
@@ -0,0 +1,13 @@
+CMake Error at only-targets.cmake:[0-9]+ \(target_link_libraries\):
+ Target "lib2" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to:
+
+ external
+
+ which is not a target. Possible reasons include:
+
+ \* There is a typo in the target name.
+ \* A find_package call is missing for an IMPORTED target.
+ \* An ALIAS target is missing.
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake
new file mode 100644
index 0000000..e29ad6c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake
@@ -0,0 +1,16 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1)
+
+add_library(dep1 SHARED empty.c)
+
+add_library(lib1 SHARED empty.c)
+# accepted
+target_link_libraries(lib1 PRIVATE "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib2 SHARED empty.c)
+# invalid
+target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat1,external>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt
new file mode 100644
index 0000000..e0c60c4
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_directories.cmake:[0-9]+ \(target_link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake
new file mode 100644
index 0000000..e8cc670
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_directories(empty PRIVATE "$<LINK_LIBRARY:feat>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt
new file mode 100644
index 0000000..6c9aab1
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_options.cmake:[0-9]+ \(target_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:FEAT>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake
new file mode 100644
index 0000000..800124c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_options(empty PRIVATE $<LINK_LIBRARY:FEAT>)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt
new file mode 100644
index 0000000..915fc41
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake
new file mode 100644
index 0000000..255c9a6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake
new file mode 100644
index 0000000..a8e0da7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake
new file mode 100644
index 0000000..54cef2c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP <base1> <other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake
new file mode 100644
index 0000000..7c38134
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake
new file mode 100644
index 0000000..88b5cf6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAGother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<base1> --LIBFLAG<other> --ITEMFLAG<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake
new file mode 100644
index 0000000..c473637
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake
new file mode 100644
index 0000000..858dcfe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base3> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake
new file mode 100644
index 0000000..ab06726
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base3> --LIBGROUP<base1> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake
new file mode 100644
index 0000000..62aa17c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other2${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1${LINK_EXTERN_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '<base2> --PREFIXGROUP --LIBGROUP<base3> --SUFFIXGROUP <other2> --PREFIXGROUP --LIBGROUP<base1> --SUFFIXGROUP <other1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake
new file mode 100644
index 0000000..255c9a6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake
new file mode 100644
index 0000000..a8e0da7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake
new file mode 100644
index 0000000..32b58fe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake
new file mode 100644
index 0000000..32b58fe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake
new file mode 100644
index 0000000..3223a95
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake
@@ -0,0 +1,81 @@
+
+enable_language(C)
+
+# ensure command line is always displayed and do not use any response file
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE)
+
+if (CMAKE_GENERATOR MATCHES "Borland|NMake")
+ string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+ string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+endif()
+
+add_library(base1 SHARED base.c)
+add_library(base2 SHARED base.c)
+
+set(CMAKE_C_LINK_USING_feat1 "--LIBFLAG<LIBRARY>")
+set(CMAKE_C_LINK_USING_feat1_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat1_1 "--LIBFLAG_C<LIBRARY>")
+set(CMAKE_C_LINK_USING_feat1_1_SUPPORTED FALSE)
+set(CMAKE_LINK_USING_feat1_1 "--LIBFLAG<LIBRARY>")
+set(CMAKE_LINK_USING_feat1_1_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat2 "--PREFIXGROUP" "--LIBGROUP<LIBRARY>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_USING_feat2_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat3 "--PREFIXGROUP" "<LINK_ITEM>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_USING_feat3_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat4 "--PREFIXGROUP" "--LIBFLAG<LIBRARY> --ITEMFLAG<LIB_ITEM>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_USING_feat4_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat5 "--PREFIXGROUP" "PATH{--LIBFLAG<LIBRARY>}NAME{--ITEMFLAG<LIB_ITEM>}" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_USING_feat5_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_USING_feat6 "<LINK_ITEM>")
+set(CMAKE_C_LINK_USING_feat6_SUPPORTED TRUE)
+
+
+add_library(LinkLibrary_simple1 SHARED lib.c)
+target_link_libraries(LinkLibrary_simple1 PRIVATE "$<LINK_LIBRARY:feat1,base1>")
+
+add_library(LinkLibrary_simple2 SHARED lib.c)
+target_link_libraries(LinkLibrary_simple2 PRIVATE "$<LINK_LIBRARY:feat1_1,base1>")
+
+add_library(LinkLibrary_group1 SHARED lib.c)
+target_link_libraries(LinkLibrary_group1 PRIVATE "$<LINK_LIBRARY:feat1,base1,base2>")
+
+add_library(LinkLibrary_group2 SHARED lib.c)
+target_link_libraries(LinkLibrary_group2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base2>")
+
+add_library(LinkLibrary_nested_feature1 SHARED lib.c)
+target_link_libraries(LinkLibrary_nested_feature1 PRIVATE "$<LINK_LIBRARY:feat1,base1,$<LINK_LIBRARY:feat1,base2>>")
+
+add_library(LinkLibrary_nested_feature2 SHARED lib.c)
+target_link_libraries(LinkLibrary_nested_feature2 PRIVATE "$<LINK_LIBRARY:feat2,base1,$<LINK_LIBRARY:feat2,base2>>")
+
+add_library(LinkLibrary_link_items1 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items1 PRIVATE "$<LINK_LIBRARY:feat3,base1,other>")
+
+add_library(LinkLibrary_link_items2 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items2 PRIVATE "$<LINK_LIBRARY:feat2,base1,other>")
+
+add_library(LinkLibrary_link_items3 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items3 PRIVATE "$<LINK_LIBRARY:feat4,base1,other>")
+
+add_library(LinkLibrary_link_items4 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items4 PRIVATE "$<LINK_LIBRARY:feat5,base1,other>")
+
+add_library(base3 SHARED base.c)
+target_link_libraries(base3 PRIVATE "$<LINK_LIBRARY:feat6,base1>")
+add_library(LinkLibrary_mix_features1 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features1 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>")
+
+target_link_libraries(base3 INTERFACE "$<LINK_LIBRARY:feat2,base1>")
+add_library(LinkLibrary_mix_features2 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>")
+
+target_link_libraries(base3 INTERFACE other1)
+add_library(LinkLibrary_mix_features3 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features3 PRIVATE base2 "$<LINK_LIBRARY:feat2,base1,base3>" other2)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
new file mode 100644
index 0000000..febada0
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
@@ -0,0 +1,73 @@
+
+include(RunCMake)
+
+cmake_policy(SET CMP0054 NEW)
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} --config Release --verbose ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+# Some environments are excluded because they are not able to honor verbose mode
+if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
+ OR (RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_VERSION GREATER_EQUAL "1600"))
+ AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows"
+ OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN"
+ OR CMAKE_SYSTEM_NAME STREQUAL "MSYS")
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ else()
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif()
+ if (MINGW OR MSYS OR CYGWIN)
+ set(LINK_EXTERN_LIBRARY_SUFFIX "")
+ else()
+ set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
+ endif()
+
+ run_cmake(LINK_LIBRARY)
+
+ run_cmake_target(LINK_LIBRARY simple1 LinkLibrary_simple1)
+ run_cmake_target(LINK_LIBRARY simple2 LinkLibrary_simple2)
+ run_cmake_target(LINK_LIBRARY group1 LinkLibrary_group1)
+ run_cmake_target(LINK_LIBRARY group2 LinkLibrary_group2)
+ run_cmake_target(LINK_LIBRARY nested-feature1 LinkLibrary_nested_feature1)
+ run_cmake_target(LINK_LIBRARY nested-feature2 LinkLibrary_nested_feature2)
+ run_cmake_target(LINK_LIBRARY link-items1 LinkLibrary_link_items1)
+ run_cmake_target(LINK_LIBRARY link-items2 LinkLibrary_link_items2)
+ run_cmake_target(LINK_LIBRARY link-items3 LinkLibrary_link_items3)
+ run_cmake_target(LINK_LIBRARY link-items4 LinkLibrary_link_items4)
+ run_cmake_target(LINK_LIBRARY mix-features1 LinkLibrary_mix_features1)
+ run_cmake_target(LINK_LIBRARY mix-features2 LinkLibrary_mix_features2)
+ run_cmake_target(LINK_LIBRARY mix-features3 LinkLibrary_mix_features3)
+
+ run_cmake(imported-target)
+
+ # tests using features as described in the documentation
+ if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+ OR (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER "1900")
+ OR (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
+ run_cmake(whole_archive)
+ run_cmake_target(whole_archive link-exe main)
+ endif()
+ if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ run_cmake(weak_library)
+ run_cmake_target(weak_library link-exe main)
+ endif()
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c
new file mode 100644
index 0000000..a5075d4
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c
@@ -0,0 +1,9 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllexport)
+# endif
+#endif
+ void base()
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt
new file mode 100644
index 0000000..b3a86cc
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt
@@ -0,0 +1,18 @@
+CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\):
+ The 'IMPORTED' target 'NS::lib2' uses the generator-expression
+ '\$<LINK_LIBRARY>' with the feature 'whole_archive', which is undefined or
+ unsupported.
+
+ Did you miss to define it by setting variables
+ "CMAKE_C_LINK_USING_whole_archive" and
+ "CMAKE_C_LINK_USING_whole_archive_SUPPORTED"\?
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at imported-target.cmake:[0-9]+ \(add_library\):
+ Feature 'whole_archive', specified through generator-expression
+ '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link
+ language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake
new file mode 100644
index 0000000..9283054
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake
@@ -0,0 +1,18 @@
+
+enable_language(C)
+
+# Create imported target NS::lib
+add_library(NS::lib STATIC IMPORTED)
+
+# Create imported target NS::lib2
+add_library(NS::lib2 SHARED IMPORTED)
+
+set_target_properties(NS::lib2 PROPERTIES
+ IMPORTED_LOCATION "/path/to/lib"
+ IMPORTED_IMPLIB "/path/to/import.lib"
+ INTERFACE_LINK_LIBRARIES "$<LINK_LIBRARY:whole_archive,NS::lib>"
+)
+
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE NS::lib2)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c
new file mode 100644
index 0000000..35ab367
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c
@@ -0,0 +1,15 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllimport)
+# endif
+#endif
+ void base();
+
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ void lib()
+{
+ base();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c
new file mode 100644
index 0000000..601bd96
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c
@@ -0,0 +1,18 @@
+
+#if defined(_WIN32)
+__declspec(dllimport)
+#endif
+ void lib();
+
+#if defined(_WIN32)
+__declspec(dllimport)
+#endif
+ void unref();
+
+int main()
+{
+ lib();
+ unref();
+
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c
new file mode 100644
index 0000000..37c3206
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c
@@ -0,0 +1,8 @@
+
+
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ void unref()
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake
new file mode 100644
index 0000000..135326e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake
@@ -0,0 +1,20 @@
+
+enable_language(C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_LINK_USING_weak_library "PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
+ set(CMAKE_LINK_USING_weak_library_SUPPORTED TRUE)
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_LINK_USING_whole_library_SUPPORTED FALSE)
+endif()
+
+add_library(lib SHARED base.c lib.c unref.c)
+set_property(TARGET lib PROPERTY OUTPUT_NAME base)
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE "$<LINK_LIBRARY:weak_library,lib>")
+
+add_executable(main2 main.c)
+target_link_directories(main2 PRIVATE "$<TARGET_FILE_DIR:lib>")
+target_link_libraries(main2 PRIVATE "$<LINK_LIBRARY:weak_library,base>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake
new file mode 100644
index 0000000..5214565
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake
@@ -0,0 +1,34 @@
+
+enable_language(C)
+
+set(CMAKE_C_LINK_USING_whole_archive_SUPPORTED TRUE)
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_C_LINK_USING_whole_archive "-force_load <LIB_ITEM>")
+elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE linker_help
+ ERROR_VARIABLE linker_help)
+ if(linker_help MATCHES "--push-state" AND linker_help MATCHES "--pop-state")
+ set(CMAKE_C_LINK_USING_whole_archive "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+ else()
+ set(CMAKE_C_LINK_USING_whole_archive "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_C_LINK_USING_whole_archive "/WHOLEARCHIVE:<LIBRARY>")
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_USING_whole_archive_SUPPORTED FALSE)
+endif()
+
+add_library(base STATIC base.c unref.c)
+target_compile_definitions(base PUBLIC STATIC_BASE)
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:whole_archive,base>")
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)