From 8a2da98ac28ccba8d77d5bd9265e93eb6ac6876c Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Thu, 1 Dec 2016 18:20:11 +0000 Subject: [PATCH] Clear XXX_FOUND in Find.cmake prior to searching. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- cmake/FindCXSparse.cmake | 6 ++++++ cmake/FindEigen.cmake | 6 ++++++ cmake/FindGflags.cmake | 6 ++++++ cmake/FindGlog.cmake | 6 ++++++ cmake/FindSuiteSparse.cmake | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/cmake/FindCXSparse.cmake b/cmake/FindCXSparse.cmake index e6c21d242..ce01199a7 100644 --- a/cmake/FindCXSparse.cmake +++ b/cmake/FindCXSparse.cmake @@ -103,6 +103,12 @@ macro(CXSPARSE_REPORT_NOT_FOUND REASON_MSG) 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 5d8ecdac6..d45fad7c9 100644 --- a/cmake/FindEigen.cmake +++ b/cmake/FindEigen.cmake @@ -83,6 +83,12 @@ macro(EIGEN_REPORT_NOT_FOUND REASON_MSG) 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 751771d75..0bd5c566d 100644 --- a/cmake/FindGflags.cmake +++ b/cmake/FindGflags.cmake @@ -271,6 +271,12 @@ function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) 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 17b8bc531..341168566 100644 --- a/cmake/FindGlog.cmake +++ b/cmake/FindGlog.cmake @@ -109,6 +109,12 @@ macro(GLOG_REPORT_NOT_FOUND REASON_MSG) 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 6815c03ba..af1fb1db7 100644 --- a/cmake/FindSuiteSparse.cmake +++ b/cmake/FindSuiteSparse.cmake @@ -152,6 +152,12 @@ macro(SUITESPARSE_REPORT_NOT_FOUND REASON_MSG) # 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)