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