--- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,13 +405,14 @@ else (MINIGLOG) unset(MINIGLOG_MAX_LOG_LEVEL CACHE) # Don't search with REQUIRED so that configuration continues if not found and # we can output an error messages explaining MINIGLOG option. - find_package(Glog) - if (NOT GLOG_FOUND) + find_package(glog REQUIRED CONFIG) + if (0) message(FATAL_ERROR "Can't find Google Log (glog). Please set either: " "glog_DIR (newer CMake built versions of glog) or GLOG_INCLUDE_DIR & " "GLOG_LIBRARY or enable MINIGLOG option to use minimal glog " "implementation.") - endif(NOT GLOG_FOUND) + endif() + if(0) # By default, assume gflags was found, updating the message if it was not. set(GLOG_GFLAGS_DEPENDENCY_MESSAGE " Assuming glog was built with gflags support as gflags was found. " @@ -424,7 +425,8 @@ else (MINIGLOG) "Otherwise, Ceres may fail to link due to missing gflags symbols.") endif(NOT gflags_FOUND) message("-- Found Google Log (glog)." ${GLOG_GFLAGS_DEPENDENCY_MESSAGE}) -endif (MINIGLOG) + endif() +endif () if (NOT SCHUR_SPECIALIZATIONS) list(APPEND CERES_COMPILE_OPTIONS CERES_RESTRICT_SCHUR_SPECIALIZATION) --- a/internal/ceres/CMakeLists.txt +++ b/internal/ceres/CMakeLists.txt @@ -101,9 +101,9 @@ endif() find_package(Threads QUIET) list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES Threads::Threads) -if (NOT MINIGLOG AND GLOG_FOUND) - list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GLOG_LIBRARIES}) - if (gflags_FOUND) +if (NOT MINIGLOG) + list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES glog::glog) + if (0) # If glog & gflags are both found, we assume that glog was built with # gflags, as it is awkward to perform a try_compile() to verify this # when gflags is an imported target (as it is in newer versions). @@ -111,7 +111,7 @@ if (NOT MINIGLOG AND GLOG_FOUND) # gflags, it is thus a public dependency for Ceres in this case. list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES gflags) endif() -endif (NOT MINIGLOG AND GLOG_FOUND) +endif () if (SUITESPARSE AND SuiteSparse_FOUND) # Define version information for use in Solver::FullReport.