# - Try to find LEVMAR
# Once done this will define
#
#  LEVMAR_FOUND			- system has LEVMAR
#  LEVMAR_INCLUDE_DIR		- the LEVMAR include directory
#  LEVMAR_LIBRARY		- link library to use LEVMAR

IF (LEVMAR_INCLUDE_DIR)
  #already in cache
  SET(LEVMAR_FIND_QUIETLY TRUE)
ENDIF(LEVMAR_INCLUDE_DIR)

FIND_PATH(LEVMAR_INCLUDE_DIR levmar.h
          PATHS /usr/include)
FIND_LIBRARY(LEVMAR_LIBRARY
             NAMES levmar
             PATHS /usr/lib64 /usr/lib)

# handle the QUIETLY and REQUIRED arguments and set LEVMAR_FOUND to TRUE if 
# all listed variables are TRUE

IF(LEVMAR_INCLUDE_DIR AND LEVMAR_LIBRARY)
  SET(LEVMAR_FOUND TRUE)
ELSE(LEVMAR_INCLUDE_DIR AND LEVMAR_LIBRARY)
  SET(LEVMAR_FOUND FALSE)
ENDIF(LEVMAR_INCLUDE_DIR AND LEVMAR_LIBRARY)

INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LEVMAR DEFAULT_MSG LEVMAR_LIBRARY LEVMAR_INCLUDE_DIR)

MARK_AS_ADVANCED(
  LEVMAR_LIBRARY
  LEVMAR_INCLUDE_DIR)
