From 5c7b6b29f9e1b1937c2c5267e8c795015c586937 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Wed, 29 Jun 2022 07:54:06 +1000 Subject: 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. --- Modules/FetchContent.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Modules/FetchContent.cmake') diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index c4c3a930c8..df40c859d4 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() -- cgit v1.2.1