#-----------------------------------------------------------------------------
# HDFJAVA Config file for compiling against hdfjava build/install directory
#-----------------------------------------------------------------------------
@PACKAGE_INIT@

string(TOUPPER @HDFJAVA_PACKAGE@ HDFJAVA_PACKAGE_NAME)

set (${HDFJAVA_PACKAGE_NAME}_VALID_COMPONENTS
    JNI
    JHI4
    JHI5
)

#-----------------------------------------------------------------------------
# User Options
#-----------------------------------------------------------------------------
set (${HDFJAVA_PACKAGE_NAME}_BUILD_TOOLS     @HDFJAVA_BUILD_TOOLS@)
set (${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS      @HDFJAVA_PACKAGE_EXTLIBS@)
set (${HDFJAVA_PACKAGE_NAME}_EXPORT_LIBRARIES @HDFJAVA_LIBRARIES_TO_EXPORT@)
set (${HDFJAVA_PACKAGE_NAME}_BUILD_SHARED_LIBS       @BUILD_SHARED_LIBS@)
set (${HDFJAVA_PACKAGE_NAME}_ENABLE_JPEG_LIB_SUPPORT @HDF_ENABLE_JPEG_LIB_SUPPORT@)
set (${HDFJAVA_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT @HDF_ENABLE_Z_LIB_SUPPORT@)
set (${HDFJAVA_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT  @HDF_ENABLE_SZIP_SUPPORT@)
set (${HDFJAVA_PACKAGE_NAME}_ENABLE_SZIP_ENCODING @HDF_ENABLE_SZIP_ENCODING@)

#-----------------------------------------------------------------------------
# Directories
#-----------------------------------------------------------------------------
set (${HDFJAVA_PACKAGE_NAME}_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")

set (${HDFJAVA_PACKAGE_NAME}_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@")
set_and_check (${HDFJAVA_PACKAGE_NAME}_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@")

if (${HDFJAVA_PACKAGE_NAME}_BUILD_TOOLS)
  set (${HDFJAVA_PACKAGE_NAME}_INCLUDE_DIR_TOOLS "@PACKAGE_INCLUDE_INSTALL_DIR@")
  set_and_check (${HDFJAVA_PACKAGE_NAME}_TOOLS_DIR "@PACKAGE_CURRENT_BUILD_DIR@/bin")
endif ()

if (HDFJAVA_BUILD_SHARED_LIBS)
  set (HJAVA_BUILT_AS_DYNAMIC_LIB 1)
else ()
  set (HJAVA_BUILT_AS_STATIC_LIB 1)
endif ()
set (HDFJAVA_LIBRARY "@PACKAGE_CURRENT_BUILD_DIR@/lib")
set (HDFJAVA_LIBRARIES "${HDFJAVA_LIBRARY}")


#-----------------------------------------------------------------------------
# Version Strings
#-----------------------------------------------------------------------------
set (HDFJAVA_VERSION_STRING @HDFJAVA_VERSION_STRING@)
set (HDFJAVA_VERSION_MAJOR  @HDFJAVA_VERSION_MAJOR@)
set (HDFJAVA_VERSION_MINOR  @HDFJAVA_VERSION_MINOR@)

#-----------------------------------------------------------------------------
# Include Directories
#-----------------------------------------------------------------------------
set (HDFJAVA_INCLUDE_DIRS
    ${HDFJAVA_LIBRARY}/jarhdf-@HDFJAVA_PACKAGE_VERSION@.jar
    ${HDFJAVA_LIBRARY}/jarhdf5-@HDFJAVA_PACKAGE_VERSION@.jar
    ${HDFJAVA_LIBRARY}/slf4j-api-1.7.5.jar
    ${HDFJAVA_LIBRARY}/slf4j-nop-1.7.5.jar
)

#-----------------------------------------------------------------------------
# Don't include targets if this file is being picked up by another
# project which has already built hdfjava as a subproject
#-----------------------------------------------------------------------------
if (NOT TARGET "@HDFJAVA_PACKAGE@")
  if (${HDFJAVA_PACKAGE_NAME}_ENABLE_JPEG_LIB_SUPPORT AND ${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS AND NOT TARGET "jpeg")
    include (@PACKAGE_SHARE_INSTALL_DIR@/@JPEG_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
  endif ()
  if (${HDFJAVA_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT AND ${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS AND NOT TARGET "zlib")
    include (@PACKAGE_SHARE_INSTALL_DIR@/@ZLIB_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
  endif ()
  if (${HDFJAVA_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT AND ${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS AND NOT TARGET "szip")
    include (@PACKAGE_SHARE_INSTALL_DIR@/@SZIP_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
  endif ()
  if (${HDFJAVA_PACKAGE_NAME}_ENABLE_HDF4_LIB_SUPPORT AND ${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS AND NOT TARGET "hdf4")
    include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF4_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
  endif ()
  if (${HDFJAVA_PACKAGE_NAME}_ENABLE_HDF5_LIB_SUPPORT AND ${HDFJAVA_PACKAGE_NAME}_PACKAGE_EXTLIBS AND NOT TARGET "hdf5")
    include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
  endif ()
  include (@PACKAGE_SHARE_INSTALL_DIR@/@HDFJAVA_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
  set (HDFJAVA_LIBRARIES "@HDFJAVA_LIBRARIES_TO_EXPORT@")
endif ()

# Handle default component :
if (NOT ${HDFJAVA_PACKAGE_NAME}_FIND_COMPONENTS)
    set (${HDFJAVA_PACKAGE_NAME}_FIND_COMPONENTS JNI)
    set (${HDFJAVA_PACKAGE_NAME}_FIND_REQUIRED_JNI true)
endif ()

## Handle requested components:
list (REMOVE_DUPLICATES ${HDFJAVA_PACKAGE_NAME}_FIND_COMPONENTS)
  foreach (comp IN LISTS ${HDFJAVA_PACKAGE_NAME}_FIND_COMPONENTS)
    set (hdfjava_comp2)
    if (${comp} STREQUAL "JNI")
      set (hdfjava_comp "jhdf5")
      set (hdfjava_comp2 "jhdf")
    elseif (${comp} STREQUAL "JHI4")
      set (hdfjava_comp "jhdf")
    elseif (${comp} STREQUAL "JHI5")
      set (hdfjava_comp "jhdf5")
    endif ()
    list (FIND ${HDFJAVA_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdfjava_comp}" HAVE_COMP)
    if (${HAVE_COMP} LESS 0)
      set (${HDFJAVA_PACKAGE_NAME}_${comp}_FOUND 0)
    else ()
      if (hdfjava_comp2)
        list (FIND ${HDFJAVA_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdfjava_comp2}" HAVE_COMP2)
        if (${HAVE_COMP2} LESS 0)
          set (${HDFJAVA_PACKAGE_NAME}_${comp}_FOUND 0)
        else ()
          set (${HDFJAVA_PACKAGE_NAME}_${comp}_FOUND 1)
          string(TOUPPER ${HDFJAVA_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY)
          set (${HDFJAVA_PACKAGE_NAME}_LIBRARIES ${${HDFJAVA_PACKAGE_NAME}_LIBRARIES} ${hdfjava_comp2} ${hdfjava_comp})
        endif ()
      else ()
        set (${HDFJAVA_PACKAGE_NAME}_${comp}_FOUND 1)
        string(TOUPPER ${HDFJAVA_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY)
        set (${HDFJAVA_PACKAGE_NAME}_LIBRARIES ${${HDFJAVA_PACKAGE_NAME}_LIBRARIES} ${hdfjava_comp})
      endif ()
    endif ()
  endforeach ()

check_required_components(${HDFJAVA_PACKAGE_NAME}_FIND_COMPONENTS)

#set (${HDFJAVA_PACKAGE_NAME}_LIBRARIES ${${COMP_LIBRARY}})
