浏览代码

Merge topic 'variable-link-feature-supported'

1777883f8b genex-LINK_(LIBRARY|GROUP) features: update variables behavior

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !7113
Brad King 3 年之前
父节点
当前提交
e3f2601a9d

+ 3 - 2
Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst

@@ -19,8 +19,9 @@ of features dependent from the link language.
 
 This variable will be used by :genex:`LINK_GROUP` generator expression if,
 for the linker language, the variable
-:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is false or not
-set.
+:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is not defined
+and the variable :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is
+``TRUE``..
 
 .. include:: CMAKE_LINK_GROUP_USING_FEATURE.txt
 

+ 1 - 2
Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst

@@ -10,5 +10,4 @@ linker language.
 .. note::
 
   This variable is evaluated if, and only if, the variable
-  :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` evaluates to
-  ``FALSE``.
+  :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is not defined.

+ 3 - 2
Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst

@@ -19,8 +19,9 @@ definition of features dependent from the link language.
 
 This variable will be used by :genex:`LINK_LIBRARY` generator expression if,
 for the linker language, the variable
-:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is false or not
-set.
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is not defined
+and the variable :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is
+``TRUE``.
 
 .. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt
 

+ 2 - 2
Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst

@@ -10,5 +10,5 @@ linker language.
 .. note::
 
   This variable is evaluated if, and only if, the variable
-  :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` evaluates to
-  ``FALSE``.
+  :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is not
+  defined.

+ 6 - 2
Source/cmComputeLinkInformation.cxx

@@ -803,7 +803,9 @@ bool cmComputeLinkInformation::AddLibraryFeature(std::string const& feature)
     cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_LIBRARY_USING_", feature);
   cmValue featureSupported =
     this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
-  if (!featureSupported.IsOn()) {
+  if (!featureSupported) {
+    // language specific variable is not defined, fallback to the more generic
+    // one
     featureName = cmStrCat("CMAKE_LINK_LIBRARY_USING_", feature);
     featureSupported =
       this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
@@ -965,7 +967,9 @@ cmComputeLinkInformation::GetGroupFeature(std::string const& feature)
     cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_GROUP_USING_", feature);
   cmValue featureSupported =
     this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
-  if (!featureSupported.IsOn()) {
+  if (!featureSupported) {
+    // language specific variable is not defined, fallback to the more generic
+    // one
     featureName = cmStrCat("CMAKE_LINK_GROUP_USING_", feature);
     featureSupported =
       this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));

+ 1 - 0
Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake

@@ -11,6 +11,7 @@ run_cmake(empty-arguments)
 run_cmake(forbidden-arguments)
 run_cmake(nested-incompatible-genex)
 run_cmake(invalid-feature)
+run_cmake(multiple-definitions)
 run_cmake(bad-feature1)
 run_cmake(bad-feature2)
 run_cmake(bad-feature3)

+ 1 - 0
Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt

@@ -0,0 +1 @@
+1

+ 5 - 0
Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt

@@ -0,0 +1,5 @@
+CMake Error at multiple-definitions.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\)

+ 12 - 0
Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake

@@ -0,0 +1,12 @@
+enable_language(C)
+
+# Language specific definition takes precedence over more generic one
+set(CMAKE_C_LINK_GROUP_USING_feat "-BEFORE" "-AFTER")
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE)
+set(CMAKE_LINK_GROUP_USING_feat "-BEFORE" "-AFTER")
+set(CMAKE_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>")

+ 1 - 0
Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake

@@ -10,6 +10,7 @@ run_cmake(no-arguments)
 run_cmake(empty-arguments)
 run_cmake(forbidden-arguments)
 run_cmake(invalid-feature)
+run_cmake(multiple-definitions)
 run_cmake(bad-feature1)
 run_cmake(bad-feature2)
 run_cmake(bad-feature3)

+ 1 - 0
Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt

@@ -0,0 +1 @@
+1

+ 5 - 0
Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt

@@ -0,0 +1,5 @@
+CMake Error at multiple-definitions.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\)

+ 12 - 0
Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake

@@ -0,0 +1,12 @@
+enable_language(C)
+
+# Language specific definition takes precedence over more generic one
+set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>")
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED FALSE)
+set(CMAKE_LINK_LIBRARY_USING_feat "<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_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>")

+ 1 - 0
Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt

@@ -0,0 +1 @@
+.*

+ 4 - 0
Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-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()

+ 7 - 0
Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake

@@ -20,6 +20,9 @@ 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)
 
+set(CMAKE_C_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP")
+set(CMAKE_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP")
+set(CMAKE_LINK_GROUP_USING_feat2_SUPPORTED TRUE)
 
 add_library(LinkGroup_simple1 SHARED lib.c)
 target_link_libraries(LinkGroup_simple1 PRIVATE "$<LINK_GROUP:feat1,base1,base2>")
@@ -31,6 +34,10 @@ add_library(LinkGroup_simple2 SHARED lib.c)
 target_link_libraries(LinkGroup_simple2 PRIVATE "$<LINK_GROUP:feat1,base2,base3>")
 
 
+add_library(LinkGroup_multiple-definitions SHARED lib.c)
+target_link_libraries(LinkGroup_multiple-definitions PRIVATE "$<LINK_GROUP:feat2,base1,base2>")
+
+
 add_library(base4 SHARED base.c)
 target_link_libraries(base4 INTERFACE "$<LINK_GROUP:feat1,base1,base2>")
 add_library(LinkGroup_multiple-groups SHARED lib.c)

+ 1 - 0
Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake

@@ -42,6 +42,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
 
   run_cmake_target(LINK_GROUP simple1 LinkGroup_simple1)
   run_cmake_target(LINK_GROUP simple2 LinkGroup_simple2)
+  run_cmake_target(LINK_GROUP multiple-definitions LinkGroup_multiple-definitions)
   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)

+ 0 - 1
Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake

@@ -16,7 +16,6 @@ set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>")
 set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
 
 set(CMAKE_C_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG_C<LIBRARY>")
-set(CMAKE_C_LINK_LIBRARY_USING_feat1_1_SUPPORTED FALSE)
 set(CMAKE_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG<LIBRARY>")
 set(CMAKE_LINK_LIBRARY_USING_feat1_1_SUPPORTED TRUE)