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
This commit is contained in:
Alex Stewart
2016-12-01 18:20:11 +00:00
parent d1e954d246
commit 8a2da98ac2
5 changed files with 30 additions and 0 deletions
+6
View File
@@ -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)
+6
View File
@@ -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.
#
+6
View File
@@ -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
+6
View File
@@ -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
+6
View File
@@ -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)