Clear XXX_FOUND in Find<XXX>.cmake prior to searching. - This protects against a client project which invokes find_package(Ceres) after having called find_package(Foo) with their own version of FindFoo.cmake which conflicts with Ceres’ exported version and defines FOO_FOUND, but not the other variables Ceres’ FindFoo.cmake is expecting which can break the detection logic. Change-Id: I9fe7bfa8a34bb58b09ffe34446da973912cf5587
diff --git a/cmake/FindCXSparse.cmake b/cmake/FindCXSparse.cmake index e6c21d2..ce01199 100644 --- a/cmake/FindCXSparse.cmake +++ b/cmake/FindCXSparse.cmake
@@ -103,6 +103,12 @@ return() endmacro(CXSPARSE_REPORT_NOT_FOUND) +# Protect against any alternative find_package scripts for this library having +# been called previously (in a client project) which set CXSPARSE_FOUND, but not +# the other variables we require / set here which could cause the search logic +# here to fail. +unset(CXSPARSE_FOUND) + # Handle possible presence of lib prefix for libraries on MSVC, see # also CXSPARSE_RESET_FIND_LIBRARY_PREFIX(). if (MSVC)
diff --git a/cmake/FindEigen.cmake b/cmake/FindEigen.cmake index 5d8ecda..d45fad7 100644 --- a/cmake/FindEigen.cmake +++ b/cmake/FindEigen.cmake
@@ -83,6 +83,12 @@ return() endmacro(EIGEN_REPORT_NOT_FOUND) +# Protect against any alternative find_package scripts for this library having +# been called previously (in a client project) which set EIGEN_FOUND, but not +# the other variables we require / set here which could cause the search logic +# here to fail. +unset(EIGEN_FOUND) + # Search user-installed locations first, so that we prefer user installs # to system installs where both exist. #
diff --git a/cmake/FindGflags.cmake b/cmake/FindGflags.cmake index 751771d..0bd5c56 100644 --- a/cmake/FindGflags.cmake +++ b/cmake/FindGflags.cmake
@@ -271,6 +271,12 @@ endif() endfunction(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) +# Protect against any alternative find_package scripts for this library having +# been called previously (in a client project) which set GFLAGS_FOUND, but not +# the other variables we require / set here which could cause the search logic +# here to fail. +unset(GFLAGS_FOUND) + # ----------------------------------------------------------------- # By default, if the user has expressed no preference for using an exported # gflags CMake configuration over performing a search for the installed
diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake index 17b8bc5..3411685 100644 --- a/cmake/FindGlog.cmake +++ b/cmake/FindGlog.cmake
@@ -109,6 +109,12 @@ return() endmacro(GLOG_REPORT_NOT_FOUND) +# Protect against any alternative find_package scripts for this library having +# been called previously (in a client project) which set GLOG_FOUND, but not +# the other variables we require / set here which could cause the search logic +# here to fail. +unset(GLOG_FOUND) + # ----------------------------------------------------------------- # By default, if the user has expressed no preference for using an exported # glog CMake configuration over performing a search for the installed
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake index 6815c03..af1fb1d 100644 --- a/cmake/FindSuiteSparse.cmake +++ b/cmake/FindSuiteSparse.cmake
@@ -152,6 +152,12 @@ # the first. endmacro(SUITESPARSE_REPORT_NOT_FOUND) +# Protect against any alternative find_package scripts for this library having +# been called previously (in a client project) which set SUITESPARSE_FOUND, but +# not the other variables we require / set here which could cause the search +# logic here to fail. +unset(SUITESPARSE_FOUND) + # Handle possible presence of lib prefix for libraries on MSVC, see # also SUITESPARSE_RESET_FIND_LIBRARY_PREFIX(). if (MSVC)