Fix FindPackage scripts to emit warnings, not errors if not found.
- Previously we used message priority: SEND_ERROR when a package was
not found and find_package() was called without QUIET or REQUIRED,
which emits an error message, and prevents generation, but continues
configuration.
- The fact SEND_ERROR induces an error message was confusing for users
as it implies that something bad has happened and they cannot
continue, when in fact we were disabling the option in question
and were thus able to continue, all they had to do was re-configure.
- This commit also reorders the search lists for includes/libraries
so that we always search user installed locations (e.g. /usr/local)
before system installed locations. Thus we will now always prefer
a user install to a system install if both are available, which is
likely to be the users desired intention.
Change-Id: Ide84919f27d3373f31282f70c685720cd77a6723
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54f0664..0f178b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,7 +226,7 @@
# built with SuiteSparse support.
# Check for SuiteSparse and dependencies.
- FIND_PACKAGE(SuiteSparse QUIET)
+ FIND_PACKAGE(SuiteSparse)
IF (SUITESPARSE_FOUND)
# On Ubuntu the system install of SuiteSparse (v3.4.0) up to at least
# Ubuntu 13.10 cannot be used to link shared libraries.
diff --git a/cmake/FindCXSparse.cmake b/cmake/FindCXSparse.cmake
index 45b2f02..e291cda 100644
--- a/cmake/FindCXSparse.cmake
+++ b/cmake/FindCXSparse.cmake
@@ -85,24 +85,27 @@
ELSEIF (CXSparse_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
ELSE()
- # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
- # that prevents generation, but continues configuration.
- MESSAGE(SEND_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
+ # Neither QUIETLY nor REQUIRED, use WARNING which emits a message
+ # but continues configuration and allows generation.
+ MESSAGE(WARNING "Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
ENDIF ()
ENDMACRO(CXSPARSE_REPORT_NOT_FOUND)
+# Search user-installed locations first, so that we prefer user installs
+# to system installs where both exist.
+#
# TODO: Add standard Windows search locations for CXSparse.
LIST(APPEND CXSPARSE_CHECK_INCLUDE_DIRS
- /usr/include
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
- /opt/local/include)
+ /opt/local/include
+ /usr/include)
LIST(APPEND CXSPARSE_CHECK_LIBRARY_DIRS
- /usr/lib
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
- /opt/local/lib)
+ /opt/local/lib
+ /usr/lib)
# Search supplied hint directories first if supplied.
FIND_PATH(CXSPARSE_INCLUDE_DIR
diff --git a/cmake/FindEigen.cmake b/cmake/FindEigen.cmake
index 26a2a06..654e41d 100644
--- a/cmake/FindEigen.cmake
+++ b/cmake/FindEigen.cmake
@@ -76,19 +76,22 @@
ELSEIF (Eigen_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN})
ELSE()
- # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
- # that prevents generation, but continues configuration.
- MESSAGE(SEND_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN})
+ # Neither QUIETLY nor REQUIRED, use WARNING which emits a message
+ # but continues configuration and allows generation.
+ MESSAGE(WARNING "Failed to find Eigen - " ${REASON_MSG} ${ARGN})
ENDIF ()
ENDMACRO(EIGEN_REPORT_NOT_FOUND)
+# Search user-installed locations first, so that we prefer user installs
+# to system installs where both exist.
+#
# TODO: Add standard Windows search locations for Eigen.
LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS
- /usr/include/eigen3
/usr/local/include/eigen3
/usr/local/homebrew/include/eigen3 # Mac OS X
/opt/local/var/macports/software/eigen3 # Mac OS X.
- /opt/local/include/eigen3)
+ /opt/local/include/eigen3
+ /usr/include/eigen3)
# Search supplied hint directories first if supplied.
FIND_PATH(EIGEN_INCLUDE_DIR
diff --git a/cmake/FindGflags.cmake b/cmake/FindGflags.cmake
index 1091862..7023982 100644
--- a/cmake/FindGflags.cmake
+++ b/cmake/FindGflags.cmake
@@ -78,24 +78,27 @@
ELSEIF (Gflags_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN})
ELSE()
- # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
- # that prevents generation, but continues configuration.
- MESSAGE(SEND_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN})
+ # Neither QUIETLY nor REQUIRED, use WARNING which emits a message
+ # but continues configuration and allows generation.
+ MESSAGE(WARNING "Failed to find gflags - " ${REASON_MSG} ${ARGN})
ENDIF ()
ENDMACRO(GFLAGS_REPORT_NOT_FOUND)
+# Search user-installed locations first, so that we prefer user installs
+# to system installs where both exist.
+#
# TODO: Add standard Windows search locations for gflags.
LIST(APPEND GFLAGS_CHECK_INCLUDE_DIRS
- /usr/include
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
- /opt/local/include)
+ /opt/local/include
+ /usr/include)
LIST(APPEND GFLAGS_CHECK_LIBRARY_DIRS
- /usr/lib
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
- /opt/local/lib)
+ /opt/local/lib
+ /usr/lib)
# Search supplied hint directories first if supplied.
FIND_PATH(GFLAGS_INCLUDE_DIR
diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake
index b94cff3..a3f35f6 100644
--- a/cmake/FindGlog.cmake
+++ b/cmake/FindGlog.cmake
@@ -78,24 +78,27 @@
ELSEIF (Glog_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN})
ELSE()
- # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
- # that prevents generation, but continues configuration.
- MESSAGE(SEND_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN})
+ # Neither QUIETLY nor REQUIRED, use WARNING which emits a message
+ # but continues configuration and allows generation.
+ MESSAGE(WARNING "Failed to find glog - " ${REASON_MSG} ${ARGN})
ENDIF ()
ENDMACRO(GLOG_REPORT_NOT_FOUND)
+# Search user-installed locations first, so that we prefer user installs
+# to system installs where both exist.
+#
# TODO: Add standard Windows search locations for glog.
LIST(APPEND GLOG_CHECK_INCLUDE_DIRS
- /usr/include
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
- /opt/local/include)
+ /opt/local/include
+ /usr/include)
LIST(APPEND GLOG_CHECK_LIBRARY_DIRS
- /usr/lib
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
- /opt/local/lib)
+ /opt/local/lib
+ /usr/lib)
# Search supplied hint directories first if supplied.
FIND_PATH(GLOG_INCLUDE_DIR
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake
index 4dc6c7e..a64d837 100644
--- a/cmake/FindSuiteSparse.cmake
+++ b/cmake/FindSuiteSparse.cmake
@@ -125,32 +125,37 @@
# use the camelcase library name, not uppercase.
IF (SuiteSparse_FIND_QUIETLY)
MESSAGE(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
- ELSE (SuiteSparse_FIND_QUIETLY)
+ ELSEIF (SuiteSparse_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
+ ELSE()
+ # Neither QUIETLY nor REQUIRED, use WARNING which emits a message
+ # but continues configuration and allows generation.
+ MESSAGE(WARNING "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
ENDIF (SuiteSparse_FIND_QUIETLY)
ENDMACRO(SUITESPARSE_REPORT_NOT_FOUND)
# Specify search directories for include files and libraries (this is the union
# of the search directories for all OSs). Search user-specified hint
-# directories first if supplied.
+# directories first if supplied, and search user-installed locations first
+# so that we prefer user installs to system installs where both exist.
LIST(APPEND SUITESPARSE_CHECK_INCLUDE_DIRS
${SUITESPARSE_INCLUDE_DIR_HINTS}
/opt/local/include
/opt/local/include/ufsparse # Mac OS X
- /usr/include
- /usr/include/suitesparse # Ubuntu
/usr/local/homebrew/include # Mac OS X
/usr/local/include
- /usr/local/include/suitesparse)
+ /usr/local/include/suitesparse
+ /usr/include/suitesparse # Ubuntu
+ /usr/include)
LIST(APPEND SUITESPARSE_CHECK_LIBRARY_DIRS
${SUITESPARSE_LIBRARY_DIR_HINTS}
/opt/local/lib
/opt/local/lib/ufsparse # Mac OS X
- /usr/lib
- /usr/lib/suitesparse # Ubuntu
/usr/local/homebrew/lib # Mac OS X
/usr/local/lib
- /usr/local/lib/suitesparse)
+ /usr/local/lib/suitesparse
+ /usr/lib/suitesparse # Ubuntu
+ /usr/lib)
# BLAS.
FIND_PACKAGE(BLAS QUIET)