Commit c16b5c26 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #1043 from alalek:fix_sfm_build

parents 05eb9f35 4dce87d2
......@@ -9,7 +9,7 @@ if(NOT Ceres_FOUND) # Looks like Ceres find glog on the own, so separate search
find_package(Glog QUIET)
endif()
if((gflags_FOUND OR GFLAGS_FOUND) AND (glog_FOUND OR GLOG_FOUND))
if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
set(_fname "${CMAKE_CURRENT_BINARY_DIR}/test_sfm_deps.cpp")
file(WRITE "${_fname}" "#include <glog/logging.h>\n#include <gflags/gflags.h>\nint main() { (void)(0); return 0; }\n")
try_compile(SFM_DEPS_OK "${CMAKE_BINARY_DIR}" "${_fname}"
......
......@@ -129,7 +129,11 @@ endmacro(GFLAGS_REPORT_NOT_FOUND)
macro(GFLAGS_CHECK_VARS_DEFINED)
foreach(CHECK_VAR ${ARGN})
if (NOT DEFINED ${CHECK_VAR})
message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
if(NOT Gflags_FIND_REQUIRED)
gflags_report_not_found("Ceres Bug: ${CHECK_VAR} is not defined.")
else()
message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
endif()
endif()
endforeach()
endmacro(GFLAGS_CHECK_VARS_DEFINED)
......@@ -283,7 +287,8 @@ if (NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION
set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
endif()
if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
# Wrap into function because gflags_report_not_found() uses "return" statement
function(__find_exported_gflags)
# Try to find an exported CMake configuration for gflags, as generated by
# gflags versions >= 2.1.
#
......@@ -384,9 +389,19 @@ if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
if (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Detected gflags version: ${gflags_VERSION}")
#set(GFLAGS_FOUND ${gflags_FOUND})
#set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
#set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
if(NOT DEFINED GFLAGS_FOUND AND DEFINED gflags_FOUND)
set(GFLAGS_FOUND ${gflags_FOUND})
endif()
if(NOT DEFINED GFLAGS_INCLUDE_DIR AND DEFINED gflags_INCLUDE_DIR)
set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
endif()
if(NOT DEFINED GFLAGS_LIBRARY AND DEFINED gflags_LIBRARIES)
set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
endif()
if(NOT DEFINED GFLAGS_INCLUDE_DIR)
gflags_report_not_found("GFLAGS_INCLUDE_DIR is missing")
endif()
# gflags does not export the namespace in their CMake configuration, so
# use our function to determine what it should be, as it can be either
......@@ -406,6 +421,15 @@ if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Failed to find an installed/exported CMake configuration "
"for gflags, will perform search for installed gflags components.")
endif (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
set(GFLAGS_FOUND "${GFLAGS_FOUND}" PARENT_SCOPE)
set(GFLAGS_INCLUDE_DIR "${GFLAGS_INCLUDE_DIR}" PARENT_SCOPE)
set(GFLAGS_LIBRARY "${GFLAGS_LIBRARY}" PARENT_SCOPE)
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
endfunction()
if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
__find_exported_gflags()
endif(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
if (NOT GFLAGS_FOUND)
......
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