summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMike Gelfand <mikedld@mikedld.com>2020-07-27 22:05:13 (GMT)
committerBrad King <brad.king@kitware.com>2020-07-28 13:09:43 (GMT)
commit0faedae33531372fb01b158a449d03ecf9e78ee0 (patch)
tree858d3199e2af149197b86b1ba91042cf55197b5b /Modules
parentdde97681e9eabcb6aada1d5d2d90a9b34beddc0f (diff)
downloadCMake-0faedae33531372fb01b158a449d03ecf9e78ee0.zip
CMake-0faedae33531372fb01b158a449d03ecf9e78ee0.tar.gz
CMake-0faedae33531372fb01b158a449d03ecf9e78ee0.tar.bz2
FindCURL: Fix list index check after search
Fix logic added by commit fc5afbe970 (FindCURL: support COMPONENTS to check features, 2018-11-28, v3.14.0-rc1~287^2~2). When searching for particular components and `curl-config` reports one of the components being searched for first in the list, `find_package` fails. This is due to the check that treats non-zero index in the list as success and zero index as failure, while documentation on `list(FIND)` states that failure to find an element results in return value of -1 (not 0). I'm hitting this when building cURL with support for HTTP and HTTPS protocols only, and then trying to `find_package(CURL COMPONENTS HTTP HTTPS)`. I'm using `if(NOT x EQUAL -1)` check form as it appears to be the most used throughout the modules. While fixing this issue I've looked through all the uses of `list(FIND)` in other modules but wasn't able to find improper use except here.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindCURL.cmake6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
index 919babc..be7e16e 100644
--- a/Modules/FindCURL.cmake
+++ b/Modules/FindCURL.cmake
@@ -148,16 +148,16 @@ if(CURL_FIND_COMPONENTS)
endif()
foreach(component IN LISTS CURL_FIND_COMPONENTS)
list(FIND CURL_KNOWN_PROTOCOLS ${component} _found)
- if(_found)
+ if(NOT _found EQUAL -1)
list(FIND CURL_SUPPORTED_PROTOCOLS ${component} _found)
- if(_found)
+ if(NOT _found EQUAL -1)
set(CURL_${component}_FOUND TRUE)
elseif(CURL_FIND_REQUIRED)
message(FATAL_ERROR "CURL: Required protocol ${component} is not found")
endif()
else()
list(FIND CURL_SUPPORTED_FEATURES ${component} _found)
- if(_found)
+ if(NOT _found EQUAL -1)
set(CURL_${component}_FOUND TRUE)
elseif(CURL_FIND_REQUIRED)
message(FATAL_ERROR "CURL: Required feature ${component} is not found")