Set CMP0057 policy for IN_LIST operator in FindSuiteSparse.cmake
A recent change introduced some uses of `IN_LIST` in
FindSuiteSparse.cmake, but this is only introduced in cmake 3.3 and
breaks downstream projects that set cmake_minimum_required() to anything
lower.
This commit locally sets CMP0057, which enables the `IN_LIST` operator
and fixes the build for these projects.
Primarily motivated by colmap, which sets cmake_minimum_required(3.0)
and is currently broken: https://github.com/colmap/colmap/issues/1451
Change-Id: I9580c86f56248611326a932b8650b9048fb0ff14
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake
index b54cea4..08b3f17 100644
--- a/cmake/FindSuiteSparse.cmake
+++ b/cmake/FindSuiteSparse.cmake
@@ -98,6 +98,11 @@
return ()
endif (SuiteSparse_FOUND)
+# Push CMP0057 to enable support for IN_LIST, when cmake_minimum_required is
+# set to <3.3.
+cmake_policy (PUSH)
+cmake_policy (SET CMP0057 NEW)
+
if (NOT SuiteSparse_FIND_COMPONENTS)
set (SuiteSparse_FIND_COMPONENTS
AMD
@@ -111,17 +116,17 @@
include (CheckLibraryExists)
-# CHOLMOD depends on AMD, CAMD, CCOLAMD, and COLAMD
+# CHOLMOD depends on AMD, CAMD, CCOLAMD, and COLAMD.
if (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS)
list (APPEND SuiteSparse_FIND_COMPONENTS AMD CAMD CCOLAMD COLAMD)
endif (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS)
-# SPQR depends on CHOLMOD
+# SPQR depends on CHOLMOD.
if (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS)
list (APPEND SuiteSparse_FIND_COMPONENTS CHOLMOD)
endif (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS)
-# Do note list components multiple times
+# Do not list components multiple times.
list (REMOVE_DUPLICATES SuiteSparse_FIND_COMPONENTS)
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
@@ -458,3 +463,6 @@
FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse."
HANDLE_COMPONENTS)
endif (SuiteSparse_FOUND)
+
+# Pop CMP0057.
+cmake_policy (POP)