#
# To be used by projects that make use of CMakeified hdf-@HDF4_PACKAGE_VERSION@
#

#
# Find the HDF4 includes and get all installed hdf4 library settings from
# HDF4-config.cmake file : Requires a CMake compatible hdf-@HDF4_PACKAGE_VERSION@ or later 
# for this feature to work. The following vars are set if hdf4 is found.
#
# HDF4_FOUND               - True if found, otherwise all other vars are undefined
# HDF4_INCLUDE_DIR         - The include dir for main *.h files
# HDF4_FORTRAN_INCLUDE_DIR - The include dir for fortran modules and headers
# HDF4_VERSION_STRING      - full version (e.g. @HDF4_PACKAGE_VERSION@)
# HDF4_VERSION_MAJOR       - major part of version (e.g. @HDF4_PACKAGE_VERSION_MAJOR@)
# HDF4_VERSION_MINOR       - minor part (e.g. @HDF4_PACKAGE_VERSION_MINOR@)
# 
# The following boolean vars will be defined
# HDF4_ENABLE_PARALLEL - 1 if HDF4 parallel supported
# HDF4_BUILD_FORTRAN   - 1 if HDF4 was compiled with fortran on
# HDF4_BUILD_CPP_LIB   - 1 if HDF4 was compiled with cpp on
# HDF4_BUILD_TOOLS     - 1 if HDF4 was compiled with tools on
# 
# Target names that are valid (depending on enabled options)
# will be the following
#
# hdf              : HDF4 C library
# hdf_f90cstub     : used by Fortran to C interface
# hdf_fortran      : Fortran HDF4 library
# mfhdf            : HDF4 multi-file C interface library
# xdr              : RPC library
# mfhdf_f90cstub   : used by Fortran to C interface to multi-file library
# mfhdf_fortran    : Fortran multi-file library
# 
# To aid in finding HDF4 as part of a subproject set
# HDF4_ROOT_DIR_HINT to the location where @HDF4_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake lies

include (SelectLibraryConfigurations)
include (FindPackageHandleStandardArgs)

# The HINTS option should only be used for values computed from the system.
set (_HDF4_HINTS
    $ENV{HOME}/.local
    $ENV{HDF4_ROOT}
    $ENV{HDF4_ROOT_DIR_HINT}
)
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
set (_HDF4_PATHS
    $ENV{HOME}/.local
    $ENV{HDF4_ROOT}
    $ENV{HDF4_ROOT_DIR_HINT}
    /usr/lib/@HDF4_PACKAGE@
    /usr/share/@HDF4_PACKAGE@
    /usr/local/@HDF4_PACKAGE@
    /usr/local/@HDF4_PACKAGE@/share
)

FIND_PATH (HDF4_ROOT_DIR "@HDF4_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake"
    HINTS ${_HDF4_HINTS}
    PATHS ${_HDF4_PATHS}
    PATH_SUFFIXES
        cmake/@HDF4_PACKAGE@
        lib/cmake/@HDF4_PACKAGE@
        share/cmake/@HDF4_PACKAGE@
)

FIND_PATH (HDF4_INCLUDE_DIRS "hdf.h"
    HINTS ${_HDF4_HINTS}
    PATHS ${_HDF4_PATHS}
    PATH_SUFFIXES
        include
        Include
)

# For backwards compatibility we set HDF4_INCLUDE_DIR to the value of
# HDF4_INCLUDE_DIRS
set ( HDF4_INCLUDE_DIR "${HDF4_INCLUDE_DIRS}" )

if (HDF4_INCLUDE_DIR)
  set (HDF4_FOUND "YES")
  include (${HDF4_ROOT_DIR}/@HDF4_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake)
endif (HDF4_INCLUDE_DIR)
