@PACKAGE_INIT@

set(export_config_name "@export_config_name@")

set_and_check(${export_config_name}Targets "${CMAKE_CURRENT_LIST_DIR}/${export_config_name}Targets.cmake")

include(${${export_config_name}Targets})

@CONFIG_CODE@

set(iMSTK_ROOT ${PACKAGE_PREFIX_DIR})
set(iMSTK_DATA_DIR ${PACKAGE_PREFIX_DIR}/data)

# iMSTK settings
set(iMSTK_AUDIO_ENABLED @iMSTK_AUDIO_ENABLED@)
set(iMSTK_USE_OpenHaptics @iMSTK_USE_OpenHaptics@)
set(iMSTK_USE_VTK_OSMESA @iMSTK_USE_VTK_OSMESA@)
set(iMSTK_USE_RENDERING_VTK @iMSTK_USE_RENDERING_VTK@)
set(iMSTK_BUILD_BENCHMARK @iMSTK_BUILD_BENCHMARK@)
set(iMSTK_BUILD_TESTING @iMSTK_BUILD_TESTING@)
set(iMSTK_BUILD_TESTING @iMSTK_BUILD_TESTING@)
set(iMSTK_BUILD_VISUAL_TESTING @iMSTK_BUILD_VISUAL_TESTING@)
set(iMSTK_USE_VRPN @iMSTK_USE_VRPN@)
set(iMSTK_VTK_DEPENDENCIES "@iMSTK_VTK_DEPENDENCIES@")

# Save
set(_iMSTK_ORIG_CMAKE_DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
set(_iMSTK_ORIG_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})

set(CMAKE_DEBUG_POSTFIX @CMAKE_DEBUG_POSTFIX@)

# Use the iMSTK modules to find all required packages
list(APPEND CMAKE_MODULE_PATH
  "${CMAKE_CURRENT_LIST_DIR}/modules"
  "@iMSTK_SOURCE_DIR@/CMake"
  "@iMSTK_SOURCE_DIR@/CMake/Utilities"
  )

include(CMakeFindDependencyMacro)

# Assimp
find_dependency( Assimp )

# Eigen3
find_dependency( Eigen3 )

# g3log
find_dependency( g3log )

# GTest
if(iMSTK_BUILD_TESTING OR iMSTK_BUILD_VISUAL_TESTING)
  find_dependency( GTest CONFIG )
endif()

# Google Benchmark
if (iMSTK_BUILD_BENCHMARK)
  find_package( benchmark REQUIRED )
endif()

# Libusb
if (iMSTK_USE_VRPN)
 
  find_dependency( Libusb )
endif()

# OpenVR
if (iMSTK_USE_RENDERING_VTK)
  find_dependency( OpenVR )
endif()

# SFML
if(iMSTK_AUDIO_ENABLED)
  find_dependency( SFML REQUIRED )
  add_definitions( -DiMSTK_AUDIO_ENABLED )
endif()

# TBB
find_dependency(TBB)

# VegaFEM
find_dependency( VegaFEM )

# VRPN
if (iMSTK_USE_VRPN)
  find_dependency( VRPN )
endif()

# OpenHaptics
if(iMSTK_USE_OpenHaptics)
  find_dependency( OpenHapticsSDK )
  add_definitions( -DiMSTK_USE_OPENHAPTICS )
endif()

# VTK
find_dependency(VTK CONFIG)
if (iMSTK_USE_RENDERING_VTK)
  find_package(vtkRenderingOpenVR QUIET)
  find_package(vtkRenderingExternal QUIET)
endif()
find_dependency(VTK COMPONENTS ${iMSTK_VTK_DEPENDENCIES})

if(iMSTK_USE_VTK_OSMESA)
  add_definitions(-DiMSTK_USE_VTK_OSMESA)
endif()

# Restore
set(CMAKE_DEBUG_POSTFIX ${_iMSTK_ORIG_CMAKE_DEBUG_POSTFIX})
set(CMAKE_MODULE_PATH ${_iMSTK_ORIG_CMAKE_MODULE_PATH})
