SET(ESSL_INCLUDE_SEARCH_PATHS
  /opt/ibmmath/essl/6.1/include
  $ENV{ESSL_HOME}/include
)

SET(ESSL_LIB_SEARCH_PATHS
        /opt/ibmmath/essl/6.1/lib64
	$ENV{ESSL_HOME}/lib64
 )

FIND_PATH(ESSL_INCLUDE_DIR NAMES essl.h PATHS ${ESSL_INCLUDE_SEARCH_PATHS})
FIND_LIBRARY(ESSL_LIBRARIES NAMES essl PATHS ${ESSL_LIB_SEARCH_PATHS})

SET(ESSL_FOUND ON)

#    Check include files
IF(NOT ESSL_INCLUDE_DIR)
    SET(ESSL_FOUND OFF)
    MESSAGE(STATUS "Could not find ESSL include. Turning ESSL_FOUND off")
ENDIF()

#    Check libraries
IF(NOT ESSL_LIBRARIES)
    SET(ESSL_FOUND OFF)
    MESSAGE(STATUS "Could not find ESSL lib. Turning ESSL_FOUND off")
ENDIF()

IF (ESSL_FOUND)
  IF (NOT ESSL_FIND_QUIETLY)
    MESSAGE(STATUS "Found ESSL libraries: ${ESSL_LIBRARIES}")
    MESSAGE(STATUS "Found ESSL include: ${ESSL_INCLUDE_DIR}")
  ENDIF (NOT ESSL_FIND_QUIETLY)
ELSE (ESSL_FOUND)
  IF (ESSL_FIND_REQUIRED)
    MESSAGE(FATAL_ERROR "Could not find ESSL")
  ENDIF (ESSL_FIND_REQUIRED)
ENDIF (ESSL_FOUND)

MARK_AS_ADVANCED(
    ESSL_INCLUDE_DIR
    ESSL_LIBRARIES
    ESSL
)
