diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-01-31 16:43:41 +0100 |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2022-02-28 10:26:26 +0100 |
commit | 0a81ea1f12cbaf60ec60b8e4a27c5ea476a655de (patch) | |
tree | 8491b1ae05b5c252b1165244c6976d81c87397ee /Tests/RunCMake | |
parent | a9928eb4a54431780d589f70460e5715258f1d27 (diff) | |
download | cmake-0a81ea1f12cbaf60ec60b8e4a27c5ea476a655de.tar.gz |
Genex-LINK_GROUP: Add possibility to group libraries at link step
Fixes: #23121
Diffstat (limited to 'Tests/RunCMake')
115 files changed, 872 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index eda857b11a..82bc8c3fde 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -314,6 +314,7 @@ 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-LINK_GROUP) 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) @@ -670,6 +671,18 @@ add_RunCMake_test(target_link_libraries-LINK_LIBRARY -DCMAKE_SYSTEM_NAME=${CMAKE -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(target_link_libraries-LINK_GROUP -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DMINGW=${MINGW} + -DMSYS=${MSYS} + -DCYGWIN=${CYGWIN} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + -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_GROUP/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt new file mode 100644 index 0000000000..612169c3ac --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake new file mode 100644 index 0000000000..98eef35802 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake @@ -0,0 +1,35 @@ +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(nested-incompatible-genex) +run_cmake(invalid-feature) +run_cmake(bad-feature1) +run_cmake(bad-feature2) +run_cmake(bad-feature3) +run_cmake(bad-feature4) +run_cmake(bad-feature5) +run_cmake(feature-not-supported) +run_cmake(library-ignored) +run_cmake(compatible-features1) +run_cmake(compatible-features2) +run_cmake(compatible-features3) +run_cmake(incompatible-features1) +run_cmake(nested-incompatible-features1) +run_cmake(nested-incompatible-features2) +run_cmake(circular-dependencies1) +run_cmake(circular-dependencies2) +run_cmake(only-targets) + +# usage of LINK_LIBRARY with LINK_GROUP +run_cmake(incompatible-library-features1) +run_cmake(incompatible-library-features2) +run_cmake(override-library-features1) +run_cmake(override-library-features2) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt new file mode 100644 index 0000000000..a80a11b1cf --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake new file mode 100644 index 0000000000..1efe2766d4 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt new file mode 100644 index 0000000000..deb246a7b6 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake new file mode 100644 index 0000000000..cbb5ff0717 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake @@ -0,0 +1,3 @@ +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_GROUP:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt new file mode 100644 index 0000000000..17c348c9b8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake new file mode 100644 index 0000000000..2e31b3409e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_link_options("$<LINK_GROUP:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt new file mode 100644 index 0000000000..8c9545209b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\): + Feature 'bad_feat', specified through generator-expression '\$<LINK_GROUP>' + 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_GROUP/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake new file mode 100644 index 0000000000..016122136d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:bad_feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt new file mode 100644 index 0000000000..3f057c4523 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP>' 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_GROUP/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake new file mode 100644 index 0000000000..7e561945bc --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake @@ -0,0 +1,8 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt new file mode 100644 index 0000000000..43e2700229 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP_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_GROUP/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake new file mode 100644 index 0000000000..58b422a25a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt new file mode 100644 index 0000000000..0a2ba60d2f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP_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_GROUP/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake new file mode 100644 index 0000000000..dcb8236047 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "-opt") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt new file mode 100644 index 0000000000..4b1f01d27a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP_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_GROUP/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake new file mode 100644 index 0000000000..cb1099692c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "-start" "<LIBRARY>" "-stop") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt new file mode 100644 index 0000000000..94008e1ea7 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at circular-dependencies1.cmake:[0-9]+ \(add_library\): + The inter-target dependency graph, for the target "lib1", contains the + following strongly connected component \(cycle\): + + group "feat:{dep1.1,dep1.2}" + depends on group "feat:{dep2.1,dep2.2}" + group "feat:{dep2.1,dep2.2}" + depends on group "feat:{dep1.1,dep1.2}" + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake new file mode 100644 index 0000000000..a1d757538e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1.1 SHARED empty.c) +add_library(dep1.2 SHARED empty.c) + +add_library(dep2.1 SHARED empty.c) +add_library(dep2.2 SHARED empty.c) + +target_link_libraries(dep1.1 PUBLIC dep2.1) +target_link_libraries(dep2.2 PUBLIC dep1.2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat,dep1.1,dep1.2>" + "$<LINK_GROUP:feat,dep2.1,dep2.2>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt new file mode 100644 index 0000000000..365e98fd51 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at circular-dependencies2.cmake:[0-9]+ \(add_library\): + The inter-target dependency graph, for the target "lib2", contains the + following strongly connected component \(cycle\): + + group "feat:{base3,base4}" + depends on group "feat:{base1,base2}" + group "feat:{base1,base2}" + depends on group "feat:{base3,base4}" + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake new file mode 100644 index 0000000000..99fda4db66 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(base1 SHARED empty.c) +add_library(base2 SHARED empty.c) +add_library(base3 SHARED empty.c) +add_library(base4 SHARED empty.c) + +target_link_libraries(base1 PUBLIC base3) +target_link_libraries(base4 PUBLIC base2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,base1,base2>") + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,base3,base4>" lib1) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake new file mode 100644 index 0000000000..9d10f95775 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PRIVATE "$<LINK_GROUP:feat1,dep1>") + +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC dep2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE $<LINK_GROUP:feat2,dep1,dep2>) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake new file mode 100644 index 0000000000..1fe2880ffb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>") + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,dep2,lib1>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake new file mode 100644 index 0000000000..ac486cecfd --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC dep1) +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC dep1) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>" dep3) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt new file mode 100644 index 0000000000..27101cb137 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:,> + + \$<LINK_GROUP:...> 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_GROUP/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake new file mode 100644 index 0000000000..6093935842 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:,>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty.c b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt new file mode 100644 index 0000000000..3507f4d83d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP>' 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_GROUP/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake new file mode 100644 index 0000000000..c4739bb114 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt new file mode 100644 index 0000000000..bae65050fa --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat>". The + LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_GROUP:...>" 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_GROUP:feat>". The + LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_GROUP:...>" 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_GROUP/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake new file mode 100644 index 0000000000..dcbf8ddc1b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +link_libraries(<LINK_GROUP:feat> foo </LINK_GROUP:feat>) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE <LINK_GROUP:feat> foo </LINK_GROUP:feat>) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt new file mode 100644 index 0000000000..932245d639 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-features1.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' because the link item 'dep2', specified + with the group 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_GROUP/incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake new file mode 100644 index 0000000000..efac0f8eaa --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC "$<LINK_GROUP:feat1,dep1,dep2>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat2,dep2,dep3>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt new file mode 100644 index 0000000000..e3a4250d9e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-library-features1.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' because the link item 'dep1', specified + with the feature 'feat1', has already occurred without any feature or + 'DEFAULT' feature, which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake new file mode 100644 index 0000000000..203f071d4d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2>,dep1>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt new file mode 100644 index 0000000000..889cba0bc6 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-library-features2.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' 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_GROUP/incompatible-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake new file mode 100644 index 0000000000..64908198a5 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2,dep1>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt new file mode 100644 index 0000000000..793b393acb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat:invalid,dep> + + The feature name 'feat:invalid' contains invalid characters. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake new file mode 100644 index 0000000000..34a319cb8b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.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_GROUP:feat:invalid,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt new file mode 100644 index 0000000000..b29c4ec215 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\): + The feature 'feat', specified as part of a generator-expression + '\$<LINK_GROUP: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_GROUP: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_GROUP/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake new file mode 100644 index 0000000000..b3f19a7b54 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +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_GROUP:feat,front,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt new file mode 100644 index 0000000000..51194a4220 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at link_directories.cmake:[0-9]+ \(link_directories\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake new file mode 100644 index 0000000000..e356e915f3 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +link_directories("$<LINK_GROUP:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt new file mode 100644 index 0000000000..78631ab58d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at nested-incompatible-features1.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat,dep1,\$<LINK_GROUP:feat,dep2>> + + \$<LINK_GROUP:...> cannot be nested. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake new file mode 100644 index 0000000000..50e0c64de8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake @@ -0,0 +1,11 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep1,$<LINK_GROUP:feat,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt new file mode 100644 index 0000000000..1a27c372ea --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at nested-incompatible-features2.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat1,dep1,\$<LINK_GROUP:feat2,dep2>> + + \$<LINK_GROUP:...> cannot be nested. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake new file mode 100644 index 0000000000..c6ea14cadf --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--end") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--end") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat1,dep1,$<LINK_GROUP:feat2,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt new file mode 100644 index 0000000000..87eeb4d43f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt @@ -0,0 +1,18 @@ +CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(add_library\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>> + + \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>> + + \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake new file mode 100644 index 0000000000..e3f2ade1dc --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +link_libraries("$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>") + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt new file mode 100644 index 0000000000..63c2648847 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP> + + \$<LINK_GROUP> expression requires at least one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake new file mode 100644 index 0000000000..ffc13819e7 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt new file mode 100644 index 0000000000..6b770f00be --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake new file mode 100644 index 0000000000..8501f1d154 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +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_GROUP:feat,dep1>") + +add_library(lib2 SHARED empty.c) +# invalid +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,external>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake new file mode 100644 index 0000000000..127e73f1ed --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake @@ -0,0 +1,4 @@ + +include(incompatible-library-features1.cmake) + +set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake new file mode 100644 index 0000000000..9ad0bfe45c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake @@ -0,0 +1,4 @@ + +include(incompatible-library-features2.cmake) + +set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE_dep1 "feat1") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt new file mode 100644 index 0000000000..042dd0b1de --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake new file mode 100644 index 0000000000..47a5f9c1d8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_directories(empty PRIVATE "$<LINK_GROUP:feat>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt new file mode 100644 index 0000000000..7030b9c10c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/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_GROUP:FEAT> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake new file mode 100644 index 0000000000..d7dd87680b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_options(empty PRIVATE $<LINK_GROUP:FEAT>) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake index d5438b847b..9c266fe94a 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake @@ -9,6 +9,7 @@ run_cmake(target_link_directories) run_cmake(no-arguments) run_cmake(empty-arguments) run_cmake(forbidden-arguments) +run_cmake(invalid-feature) run_cmake(bad-feature1) run_cmake(bad-feature2) run_cmake(bad-feature3) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt new file mode 100644 index 0000000000..fb5cdab185 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat:invalid,dep> + + The feature name 'feat:invalid' contains invalid characters. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake new file mode 100644 index 0000000000..c49e4cdcfb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.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:feat:invalid,dep>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt new file mode 100644 index 0000000000..915fc4127b --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/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_GROUP/LINK_GROUP-group-and-single-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake new file mode 100644 index 0000000000..3b8f3ba84c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base5${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base3> --END_GROUP <base5> --START_GROUP <base1> <base3> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake new file mode 100644 index 0000000000..97732a551e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base4${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base4> --END_GROUP --START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake new file mode 100644 index 0000000000..3e53d268eb --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake new file mode 100644 index 0000000000..475a0e2ef0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base3> --END_GROUP <base1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake new file mode 100644 index 0000000000..2b2460e9a0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake new file mode 100644 index 0000000000..5ef830cac6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> --LIBFLAG<base3> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake new file mode 100644 index 0000000000..d08db16b91 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake @@ -0,0 +1,52 @@ +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_GROUP_USING_feat1 "--START_GROUP" "--END_GROUP") +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) + + +add_library(LinkGroup_simple1 SHARED lib.c) +target_link_libraries(LinkGroup_simple1 PRIVATE "$<LINK_GROUP:feat1,base1,base2>") + + +add_library(base3 SHARED base.c) +target_link_libraries(base3 PUBLIC base1) +add_library(LinkGroup_simple2 SHARED lib.c) +target_link_libraries(LinkGroup_simple2 PRIVATE "$<LINK_GROUP:feat1,base2,base3>") + + +add_library(base4 SHARED base.c) +target_link_libraries(base4 INTERFACE "$<LINK_GROUP:feat1,base1,base2>") +add_library(LinkGroup_multiple-groups SHARED lib.c) +target_link_libraries(LinkGroup_multiple-groups PRIVATE "$<LINK_GROUP:feat1,base2,base4>") + + +add_library(base5 SHARED base.c) +target_link_libraries(base5 PUBLIC base1) +add_library(LinkGroup_group-and-single SHARED lib.c) +target_link_libraries(LinkGroup_group-and-single PRIVATE "$<LINK_GROUP:feat1,base1,base3>" base5) + + +add_library(LinkGroup_with-LINK_LIBRARY SHARED lib.c) +target_link_libraries(LinkGroup_with-LINK_LIBRARY PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1>,base2>") + + +add_library(LinkGroup_with-LINK_LIBRARY_OVERRIDE SHARED lib.c) +target_link_libraries(LinkGroup_with-LINK_LIBRARY_OVERRIDE PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1,base3>,base2>") +set_property(TARGET LinkGroup_with-LINK_LIBRARY_OVERRIDE PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat1) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake new file mode 100644 index 0000000000..eedc5b9bde --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake @@ -0,0 +1,63 @@ + +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_GROUP) + + run_cmake_target(LINK_GROUP simple1 LinkGroup_simple1) + run_cmake_target(LINK_GROUP simple2 LinkGroup_simple2) + run_cmake_target(LINK_GROUP multiple-groups LinkGroup_multiple-groups) + run_cmake_target(LINK_GROUP group-and-single LinkGroup_group-and-single) + run_cmake_target(LINK_GROUP with-LINK_LIBRARY LinkGroup_with-LINK_LIBRARY) + run_cmake_target(LINK_GROUP with-LINK_LIBRARY_OVERRIDE LinkGroup_with-LINK_LIBRARY_OVERRIDE) + + run_cmake(imported-target) + + # tests using features as described in the documentation + if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + OR (CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9" + AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")) + run_cmake(cross_refs) + run_cmake_target(cross_refs link main) + endif() + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c new file mode 100644 index 0000000000..a5075d4428 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/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_GROUP/cross_refs.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake new file mode 100644 index 0000000000..4a2a08ce60 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake @@ -0,0 +1,22 @@ + +enable_language(C) + + set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" + AND CMAKE_SYSTEM_NAME STREQUAL "Linux") +set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:--start-group" + "LINKER:--end-group") +elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro" + AND CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:-z,rescan-start" + "LINKER:-z,rescan-end") +else() + # feature not yet supported for the other environments + set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED FALSE) +endif() + +add_library(func1 STATIC func1.c func3.c) +add_library(func2 STATIC func2.c) + +add_executable(main main.c) +target_link_libraries(main PRIVATE "$<LINK_GROUP:cross_refs,func1,func2>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c new file mode 100644 index 0000000000..3399e00e29 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c @@ -0,0 +1,7 @@ + +extern void func2(); + +void func1() +{ + func2(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c new file mode 100644 index 0000000000..0f9aa64cb6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c @@ -0,0 +1,7 @@ + +extern void func3(); + +void func2() +{ + func3(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c new file mode 100644 index 0000000000..0b7df64551 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c @@ -0,0 +1,6 @@ + +extern void func3(); + +void func3() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt new file mode 100644 index 0000000000..16b93d13ab --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt @@ -0,0 +1,16 @@ +CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\): + The 'IMPORTED' target 'NS::lib2' uses the generator-expression + '\$<LINK_GROUP>' with the feature 'feat', which is undefined or unsupported. + + Did you miss to define it by setting variables + "CMAKE_C_LINK_GROUP_USING_feat" and + "CMAKE_C_LINK_GROUP_USING_feat_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 'feat', specified through generator-expression '\$<LINK_GROUP>' 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_GROUP/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake new file mode 100644 index 0000000000..bd83f9788e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake @@ -0,0 +1,22 @@ + +enable_language(C) + +# Create imported target NS::lib +add_library(NS::lib STATIC IMPORTED) +set_target_properties(NS::lib PROPERTIES + IMPORTED_LOCATION "/path/to/lib" + IMPORTED_IMPLIB "/path/to/import.lib" +) + +# 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_GROUP:feat,NS::lib>" +) + + +add_library(lib SHARED lib.c) +target_link_libraries(lib PRIVATE NS::lib2) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c new file mode 100644 index 0000000000..35ab367456 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/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_GROUP/main.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c new file mode 100644 index 0000000000..403583d633 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c @@ -0,0 +1,7 @@ + +extern void func1(); + +int main() +{ + func1(); +} |