summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-06-29 12:46:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-06-29 12:46:31 (GMT)
commitca8720c6afaec979bc7facc0324ddbfad9f99993 (patch)
tree36369d2ed2f400c94bd0befe1ce1ea0694a1184b /Modules
parent55ceba891115e132704fdc2f14911773e54ea051 (diff)
parent5c7b6b29f9e1b1937c2c5267e8c795015c586937 (diff)
downloadCMake-ca8720c6afaec979bc7facc0324ddbfad9f99993.zip
CMake-ca8720c6afaec979bc7facc0324ddbfad9f99993.tar.gz
CMake-ca8720c6afaec979bc7facc0324ddbfad9f99993.tar.bz2
Merge topic 'FetchContent-avoid-IN_LIST'
5c7b6b29f9 FetchContent: Don't use if(... IN_LIST ...) Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7423
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FetchContent.cmake10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index c4c3a93..df40c85 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1178,7 +1178,11 @@ function(FetchContent_Declare contentName)
# Always check this even if we won't save these details.
# This helps projects catch errors earlier.
- if("OVERRIDE_FIND_PACKAGE" IN_LIST ARGN AND "FIND_PACKAGE_ARGS" IN_LIST ARGN)
+ # Avoid using if(... IN_LIST ...) so we don't have to alter policy settings
+ list(FIND ARGN OVERRIDE_FIND_PACKAGE index_OVERRIDE_FIND_PACKAGE)
+ list(FIND ARGN FIND_PACKAGE_ARGS index_FIND_PACKAGE_ARGS)
+ if(index_OVERRIDE_FIND_PACKAGE GREATER_EQUAL 0 AND
+ index_FIND_PACKAGE_ARGS GREATER_EQUAL 0)
message(FATAL_ERROR
"Cannot specify both OVERRIDE_FIND_PACKAGE and FIND_PACKAGE_ARGS "
"when declaring details for ${contentName}"
@@ -1750,7 +1754,9 @@ function(__FetchContent_setupFindPackageRedirection contentName)
DEFINED
)
- if(NOT wantFindPackage AND NOT OVERRIDE_FIND_PACKAGE IN_LIST contentDetails)
+ # Avoid using if(... IN_LIST ...) so we don't have to alter policy settings
+ list(FIND contentDetails OVERRIDE_FIND_PACKAGE indexResult)
+ if(NOT wantFindPackage AND indexResult EQUAL -1)
# No find_package() redirection allowed
return()
endif()