123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- include(CMakeFindDependencyMacro)
- macro(CERES_REPORT_NOT_FOUND REASON_MSG)
-
-
- set(Ceres_FOUND FALSE)
- set(CERES_FOUND FALSE)
- unset(CERES_INCLUDE_DIR)
- unset(CERES_INCLUDE_DIRS)
- unset(CERES_LIBRARIES)
-
- set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})
-
-
- if (Ceres_FIND_QUIETLY)
- message(STATUS "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
- elseif (Ceres_FIND_REQUIRED)
- message(FATAL_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
- else()
-
-
- message(SEND_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
- endif ()
- return()
- endmacro(CERES_REPORT_NOT_FOUND)
- function(ceres_message)
- if (NOT Ceres_FIND_QUIETLY)
- message(${ARGN})
- endif()
- endfunction()
- function(ceres_pretty_print_cmake_list OUTPUT_VAR)
- string(REPLACE ";" ", " PRETTY_LIST_STRING "[${ARGN}]")
- set(${OUTPUT_VAR} "${PRETTY_LIST_STRING}" PARENT_SCOPE)
- endfunction()
- set(CERES_COMPILED_COMPONENTS "@CERES_COMPILED_COMPONENTS@")
- set(CERES_WAS_INSTALLED @SETUP_CERES_CONFIG_FOR_INSTALLATION@)
- set(CALLERS_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
- get_filename_component(CERES_CURRENT_CONFIG_DIR
- "${CMAKE_CURRENT_LIST_FILE}" PATH)
- if (CERES_WAS_INSTALLED)
-
-
-
-
- set(CMAKE_MODULE_PATH ${CERES_CURRENT_CONFIG_DIR})
-
-
-
-
- get_filename_component(CURRENT_ROOT_INSTALL_DIR
- "${CERES_CURRENT_CONFIG_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@"
- ABSOLUTE)
- if (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR})
- ceres_report_not_found(
- "Ceres install root: ${CURRENT_ROOT_INSTALL_DIR}, "
- "determined from relative path from CeresConfig.cmake install location: "
- "${CERES_CURRENT_CONFIG_DIR}, does not exist. Either the install "
- "directory was deleted, or the install tree was only partially relocated "
- "outside of CMake after Ceres was built.")
- endif (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR})
- else(CERES_WAS_INSTALLED)
-
- set(CERES_EXPORTED_BUILD_DIR ${CERES_CURRENT_CONFIG_DIR})
- get_filename_component(CERES_EXPORTED_SOURCE_DIR
- "${CERES_EXPORTED_BUILD_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@"
- ABSOLUTE)
- if (NOT EXISTS ${CERES_EXPORTED_SOURCE_DIR})
- ceres_report_not_found(
- "Ceres exported source directory: ${CERES_EXPORTED_SOURCE_DIR}, "
- "determined from relative path from CeresConfig.cmake exported build "
- "directory: ${CERES_EXPORTED_BUILD_DIR} does not exist.")
- endif()
-
-
-
-
- set(CMAKE_MODULE_PATH ${CERES_EXPORTED_SOURCE_DIR}/cmake)
- endif(CERES_WAS_INSTALLED)
- set(CERES_VERSION @CERES_VERSION@)
- include(CMakeFindDependencyMacro)
- @METIS_DEPENDENCY@
- @SuiteSparse_DEPENDENCY@
- @CUDAToolkit_DEPENDENCY@
- @Threads_DEPENDENCY@
- set(CERES_EIGEN_VERSION @Eigen3_VERSION@)
- find_package(Eigen3 ${CERES_EIGEN_VERSION} QUIET)
- if (Eigen3_FOUND)
- if (NOT Eigen3_VERSION VERSION_EQUAL CERES_EIGEN_VERSION)
-
-
-
- ceres_report_not_found("Found Eigen dependency, but the version of Eigen "
- "found (${Eigen3_VERSION}) does not exactly match the version of Eigen "
- "Ceres was compiled with (${CERES_EIGEN_VERSION}). This can cause subtle "
- "bugs by triggering violations of the One Definition Rule. See the "
- "Wikipedia article http://en.wikipedia.org/wiki/One_Definition_Rule "
- "for more details")
- endif ()
- ceres_message(STATUS "Found required Ceres dependency: "
- "Eigen version ${CERES_EIGEN_VERSION} in ${Eigen3_DIR}")
- else (Eigen3_FOUND)
- ceres_report_not_found("Missing required Ceres "
- "dependency: Eigen version ${CERES_EIGEN_VERSION}, please set "
- "Eigen3_DIR.")
- endif (Eigen3_FOUND)
- set(CERES_USES_MINIGLOG @MINIGLOG@)
- set(CERES_GLOG_VERSION @glog_VERSION@)
- set(CERES_GLOG_WAS_BUILT_WITH_CMAKE @FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION@)
- set(CERES_USES_GFLAGS @GFLAGS@)
- set(CERES_GFLAGS_VERSION @gflags_VERSION@)
- if (CERES_USES_MINIGLOG)
-
-
- ceres_message("-- Found Ceres compiled with miniglog substitute "
- "for glog, beware this will likely cause problems if glog is later linked.")
- else(CERES_USES_MINIGLOG)
- if (CERES_GLOG_WAS_BUILT_WITH_CMAKE)
- find_package(glog ${CERES_GLOG_VERSION} CONFIG QUIET)
- set(GLOG_FOUND ${glog_FOUND})
- else()
-
-
-
- list(APPEND GLOG_INCLUDE_DIR_HINTS "@GLOG_INCLUDE_DIR@")
- get_filename_component(CERES_BUILD_GLOG_LIBRARY_DIR "@GLOG_LIBRARY@" PATH)
- list(APPEND GLOG_LIBRARY_DIR_HINTS ${CERES_BUILD_GLOG_LIBRARY_DIR})
-
- find_package(Glog QUIET)
- endif()
- if (GLOG_FOUND)
- ceres_message(STATUS "Found required Ceres dependency: glog")
- else()
- ceres_report_not_found("Missing required Ceres dependency: glog.")
- endif()
-
-
- if (CERES_USES_GFLAGS)
-
- find_package(gflags ${CERES_GFLAGS_VERSION} QUIET)
- if (gflags_FOUND AND TARGET gflags)
- ceres_message(STATUS "Found required Ceres dependency: gflags")
- else()
- ceres_report_not_found("Missing required Ceres "
- "dependency: gflags (not found, or not found as exported CMake target).")
- endif()
- endif()
- endif(CERES_USES_MINIGLOG)
- if (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
- include(${CERES_CURRENT_CONFIG_DIR}/CeresTargets.cmake)
- endif (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
- set(CERES_LIBRARIES Ceres::ceres)
- set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})
- ceres_pretty_print_cmake_list(CERES_COMPILED_COMPONENTS_STRING
- ${CERES_COMPILED_COMPONENTS})
- if (CERES_WAS_INSTALLED)
- set(CERES_DETECTED_VERSION_STRING "Ceres version: ${CERES_VERSION} "
- "installed in: ${CURRENT_ROOT_INSTALL_DIR} with components: "
- "${CERES_COMPILED_COMPONENTS_STRING}")
- else (CERES_WAS_INSTALLED)
- set(CERES_DETECTED_VERSION_STRING "Ceres version: ${CERES_VERSION} "
- "exported from build directory: ${CERES_EXPORTED_BUILD_DIR} with "
- "components: ${CERES_COMPILED_COMPONENTS_STRING}")
- endif()
- if (Ceres_FIND_COMPONENTS)
- foreach (REQUESTED_COMPONENT ${Ceres_FIND_COMPONENTS})
- list(FIND CERES_COMPILED_COMPONENTS ${REQUESTED_COMPONENT} HAVE_REQUESTED_COMPONENT)
-
-
-
- if (HAVE_REQUESTED_COMPONENT EQUAL -1)
-
-
-
- list(APPEND MISSING_CERES_COMPONENTS ${REQUESTED_COMPONENT})
- endif()
- endforeach()
- if (MISSING_CERES_COMPONENTS)
- ceres_pretty_print_cmake_list(REQUESTED_CERES_COMPONENTS_STRING
- ${Ceres_FIND_COMPONENTS})
- ceres_pretty_print_cmake_list(MISSING_CERES_COMPONENTS_STRING
- ${MISSING_CERES_COMPONENTS})
- ceres_report_not_found("Missing requested Ceres components: "
- "${MISSING_CERES_COMPONENTS_STRING} (components requested: "
- "${REQUESTED_CERES_COMPONENTS_STRING}). Detected "
- "${CERES_DETECTED_VERSION_STRING}.")
- endif()
- endif()
- ceres_message(STATUS "Found " ${CERES_DETECTED_VERSION_STRING})
- set(CERES_FOUND TRUE)
- if (NOT TARGET ceres)
-
-
-
- add_library(ceres INTERFACE IMPORTED)
- set_target_properties(ceres PROPERTIES INTERFACE_LINK_LIBRARIES Ceres::ceres)
- endif()
|