Fix detection of CMake-built glog on Windows. - glog has a bug in its CMakeLists.txt whereby it uses ‘google-glog’ as its project() name in its CMakeLists.txt, but exports itself as ‘glog’ which results in an install prefix on Windows which contains ‘google-glog’ instead of ‘glog’ which breaks find_package(glog). This has been raised as a glog issue here: https://github.com/google/glog/issues/149. - We now force find_package(glog) to search glog using both ‘google-glog’ (for Windows) & ‘glog’ (for all other OSs). Change-Id: I6c0edccdec405200eaa0fea1476b574e73bd3f14
diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake index d7af064..a11ba2c 100644 --- a/cmake/FindGlog.cmake +++ b/cmake/FindGlog.cmake
@@ -161,8 +161,21 @@ # recently with the CMake GUI to ensure that we always prefer an installed # version if available. # + # NOTE: We use the NAMES option as glog erroneously uses 'google-glog' as its + # project name when built with CMake, but exports itself as just 'glog'. + # On Linux/OS X this does not break detection as the project name is + # not used as part of the install path for the CMake package files, + # e.g. /usr/local/lib/cmake/glog, where the <glog> suffix is hardcoded + # in glog's CMakeLists. However, on Windows the project name *is* + # part of the install prefix: C:/Program Files/google-glog/[include,lib]. + # However, by default CMake checks: + # C:/Program Files/<FIND_PACKAGE_ARGUMENT_NAME='glog'> which does not + # exist and thus detection fails. Thus we use the NAMES to force the + # search to use both google-glog & glog. + # # [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_package find_package(glog QUIET + NAMES google-glog glog NO_MODULE NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_BUILDS_PATH) @@ -176,6 +189,7 @@ # Again pass NO_CMAKE_BUILDS_PATH, as we know that glog is exported and # do not want to treat projects built with the CMake GUI preferentially. find_package(glog QUIET + NAMES google-glog glog NO_MODULE NO_CMAKE_BUILDS_PATH) if (glog_FOUND)