Commit a92e1d95 authored by Sergiu Deitsch's avatar Sergiu Deitsch

cmake: use gflags package config instead of a find module

This allows to avoid conflicts between third party gflags find modules floating
around. If a package provide a local version of gflags find module, clients
which locate glog will incorrectly use it. Another problem is a CMake error message
"cmake_policy PUSH without matching POP" in nested find_package calls. In summary,
we need to ensure to use the original gflags package config.
parent b2c3afec
......@@ -599,8 +599,19 @@ install (TARGETS glog
LIBRARY DESTINATION ${_glog_CMake_LIBDIR}
ARCHIVE DESTINATION ${_glog_CMake_LIBDIR})
set (glog_POLICY_VERSION 3.0)
if (gflags_FOUND)
set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})")
# Ensure clients locate only the package config and not third party find
# modules having the same name. This avoid cmake_policy PUSH/POP errors.
if (CMAKE_VERSION VERSION_LESS 3.9)
set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})")
else (CMAKE_VERSION VERSION_LESS 3.9)
# Passing additional find_package arguments to find_dependency is possible
# starting with CMake 3.9.
set (glog_POLICY_VERSION 3.9)
set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION} NO_MODULE)")
endif (CMAKE_VERSION VERSION_LESS 3.9)
endif (gflags_FOUND)
configure_package_config_file (glog-config.cmake.in
......
cmake_policy (PUSH)
cmake_policy (VERSION 3.0)
cmake_policy (VERSION @glog_POLICY_VERSION@)
@PACKAGE_INIT@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment