소스 검색

Help: use package-specific var for supported component list

Always using `_supported_components` causes conflicts when transitive
dependencies also set this variable, e.g., because the developers
followed these code samples.

An even more general approach could be to set
`_${CMAKE_FIND_PACKAGE_NAME}_supported_components` instead, but such a
change should then be applied to other variables for consistency.

Fixes: #23112
Connor Imes 3 년 전
부모
커밋
5317015e68
2개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 2
      Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
  2. 2 2
      Help/manual/cmake-packages.7.rst

+ 2 - 2
Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in

@@ -1,9 +1,9 @@
 @PACKAGE_INIT@
 
-set(_supported_components Addition SquareRoot)
+set(_MathFunctions_supported_components Addition SquareRoot)
 
 foreach(_comp ${MathFunctions_FIND_COMPONENTS})
-  if (NOT _comp IN_LIST _supported_components)
+  if (NOT _comp IN_LIST _MathFunctions_supported_components)
     set(MathFunctions_FOUND False)
     set(MathFunctions_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
   endif()

+ 2 - 2
Help/manual/cmake-packages.7.rst

@@ -446,10 +446,10 @@ be true. This can be tested with logic in the package configuration file:
   include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
   include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
 
-  set(_supported_components Plot Table)
+  set(_ClimbingStats_supported_components Plot Table)
 
   foreach(_comp ${ClimbingStats_FIND_COMPONENTS})
-    if (NOT ";${_supported_components};" MATCHES ";${_comp};")
+    if (NOT ";${_ClimbingStats_supported_components};" MATCHES ";${_comp};")
       set(ClimbingStats_FOUND False)
       set(ClimbingStats_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
     endif()