# - Try to find SP_SLAM
# Set alternative paths to search for using SP_SLAM_DIR
# Once done this will define
#  SP_SLAM_FOUND - System has SP_SLAM
#  SP_SLAM_INCLUDE_DIRS - The SP_SLAM include directories
#  SP_SLAM_LIBRARIES - The libraries needed to use SP_SLAM
#  SP_SLAM_DEFINITIONS - Compiler switches required for using SP_SLAM

# TODO: This need to find dependencies properly, I can't find an example of how to do that
#find_package(OpenCV REQUIRED)
#find_package(Eigen3 REQUIRED)
#find_package(Pangolin REQUIRED)

set(_SP_SLAM_SEARCHES /usr/local)
if (SP_SLAM_DIR)
    set(_SP_SLAM_SEARCHES ${SP_SLAM_DIR} ${_SP_SLAM_SEARCHES})
endif()
find_path(SP_SLAM_INCLUDE_DIR SP_SLAM/System.h
          PATHS ${_SP_SLAM_SEARCHES} PATH_SUFFIXES include)

find_library(SP_SLAM_LIBRARY NAMES SP_SLAM libSP_SLAM
             PATHS ${_SP_SLAM_SEARCHES} PATH_SUFFIXES lib)

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SP_SLAM_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(SP_SLAM  DEFAULT_MSG
                                  SP_SLAM_LIBRARY SP_SLAM_INCLUDE_DIR)

mark_as_advanced(SP_SLAM_INCLUDE_DIR SP_SLAM_LIBRARY )

set(SP_SLAM_LIBRARIES ${SP_SLAM_LIBRARY})
set(SP_SLAM_INCLUDE_DIRS ${SP_SLAM_INCLUDE_DIR})

