################
# UseZed.cmake #
################

INCLUDE(${PROJECT_SOURCE_DIR}/cmake/UseCUDA.cmake)

OPTION(WITH_ZED "Build with Zed SDK support?" OFF)

IF(WITH_ZED)
  IF(NOT WITH_CUDA)
    MESSAGE(FATAL_ERROR "The Zed SDK requires CUDA to work. Please enable the WITH_CUDA flag in CMake.")
  ENDIF()

  FIND_PACKAGE(ZED 2 REQUIRED)

  IF(MSVC_IDE)
    FIND_PATH(ZED_INCLUDE_DIRS sl/Camera.hpp HINTS "${ZED_DIR}/include")
    FIND_PATH(ZED_LIBRARY_DIR sl_zed64.lib HINTS "${ZED_DIR}/lib")

    FIND_LIBRARY(ZED_LIBRARY_CORE sl_core64 HINTS "${ZED_LIBRARY_DIR}")
    FIND_LIBRARY(ZED_LIBRARY_SCANNING sl_scanning64 HINTS "${ZED_LIBRARY_DIR}")
    FIND_LIBRARY(ZED_LIBRARY_ZED sl_zed64 HINTS "${ZED_LIBRARY_DIR}")

    SET(ZED_LIBRARIES ${ZED_LIBRARY_CORE} ${ZED_LIBRARY_SCANNING} ${ZED_LIBRARY_ZED})
  ENDIF()

  INCLUDE_DIRECTORIES(SYSTEM ${ZED_INCLUDE_DIRS})
  ADD_DEFINITIONS(-DWITH_ZED)
ENDIF()
