###################
# UseALGLIB.cmake #
###################

OPTION(WITH_ALGLIB "Build with ALGLIB support?" OFF)

IF(WITH_ALGLIB)
  FIND_PATH(ALGLIB_ROOT gpl3.txt HINTS "${PROJECT_SOURCE_DIR}/libraries/alglib")

  FIND_PATH(ALGLIB_INCLUDE_DIR alglib/alglibmisc.h HINTS "${ALGLIB_ROOT}/install/include")
  INCLUDE_DIRECTORIES(SYSTEM ${ALGLIB_INCLUDE_DIR})

  IF(MSVC_IDE)
    FIND_LIBRARY(ALGLIB_LIBRARY_DEBUG alglib_d HINTS "${ALGLIB_ROOT}/install/lib")
    FIND_LIBRARY(ALGLIB_LIBRARY_RELEASE alglib HINTS "${ALGLIB_ROOT}/install/lib")
    SET(ALGLIB_LIBRARY debug ${ALGLIB_LIBRARY_DEBUG} optimized ${ALGLIB_LIBRARY_RELEASE})
  ELSE()
    FIND_LIBRARY(ALGLIB_LIBRARY alglib HINTS "${ALGLIB_ROOT}/install/lib" NO_DEFAULT_PATH)
  ENDIF()

  ADD_DEFINITIONS(-DWITH_ALGLIB)
ENDIF()
