# FindMuPdf
# ------------
#
# Locate MuPdf library
#
# This module defines
#
#   MUPDF_LIBRARIES, the libraries to link against
#   MUPDF_FOUND, if false, do not try to link to MuPdf
#   MUPDF_INCLUDE_DIR, where to find headers.

FIND_PATH( MUPDF_INCLUDE_DIR mupdf/pdf.h
    HINTS $ENV{BAWT_DEV_DIR}/include
    PATHS
    /usr/X11R6
    /usr/local/X11R6
    /usr/local/X11
    /usr/freeware
)

FIND_LIBRARY( MUPDF_LIBRARY NAMES libmupdf libmupdf.a
    HINTS $ENV{BAWT_DEV_DIR}/lib
    PATH_SUFFIXES lib lib64
)

IF( MSVC )
FIND_LIBRARY( RESOURCE_LIBRARY NAMES libresources
    HINTS $ENV{BAWT_DEV_DIR}/lib
    PATH_SUFFIXES lib lib64
)
ENDIF()

FIND_LIBRARY( THIRDPARTY_LIBRARY NAMES libthirdparty libmupdf-third.a
    HINTS $ENV{BAWT_DEV_DIR}/lib
    PATH_SUFFIXES lib lib64
)

IF( MSVC )
SET( MUPDF_LIBRARIES
    ${MUPDF_LIBRARY} 
    ${RESOURCE_LIBRARY}
    ${THIRDPARTY_LIBRARY}
    CACHE INTERNAL "The libraries needed to use MuPdf" FORCE )
ELSE()
SET( MUPDF_LIBRARIES
    ${MUPDF_LIBRARY} 
    ${THIRDPARTY_LIBRARY}
    CACHE INTERNAL "The libraries needed to use MuPdf" FORCE )
ENDIF()

# handle the QUIETLY and REQUIRED arguments and set MUPDF_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( mupdf DEFAULT_MSG MUPDF_LIBRARIES MUPDF_INCLUDE_DIR )
