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/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)