summaryrefslogtreecommitdiffstats
path: root/Modules/FetchContent.cmake
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-06-28 21:54:06 (GMT)
committerCraig Scott <craig.scott@crascit.com>2022-06-28 21:54:06 (GMT)
commit5c7b6b29f9e1b1937c2c5267e8c795015c586937 (patch)
tree889b3bb513fbe6c85fe4507e354cb87b0c74ad20 /Modules/FetchContent.cmake
parente9213013e605b963d016b132e1488eca5847b29a (diff)
downloadCMake-5c7b6b29f9e1b1937c2c5267e8c795015c586937.zip
CMake-5c7b6b29f9e1b1937c2c5267e8c795015c586937.tar.gz
CMake-5c7b6b29f9e1b1937c2c5267e8c795015c586937.tar.bz2
FetchContent: Don't use if(... IN_LIST ...)
This avoids the need for changing policy settings, which would then propagate through to projects brought into the build via FetchContent.
Diffstat (limited to 'Modules/FetchContent.cmake')
-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()