# - Config file for the @PROJECT_NAME@ package
# It defines the following variables. 
# Specific to the pacakge @PROJECT_NAME@ itself:
#  MEDFILE_INCLUDE_DIRS - include directories 
#  MEDFILE_LIBRARIES    - libraries to link against (C and Fortran)
#  MEDFILE_C_LIBRARIES  - C libraries only
#  MEDFILE_EXTRA_LIBRARIES 
#  MEDFILE_ROOT_DIR_EXP - the root path of the installation providing this CMake file
#
# Other stuff specific to this package:
#  1. Dependencies of MEDFILE that might be re-used by dependent modules:
#   HDF5_ROOT_DIR_EXP  - path to the HDF5 installation used by @PROJECT_NAME@
#   MPI_ROOT_DIR_EXP   - path to the MPI installation used by @PROJECT_NAME@
#  2. Some flags
#   MEDFILE_USE_MPI   - boolean indicating if med fichier was compiled with MPI support

### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE:
@PACKAGE_INIT@

### First the generic stuff for a standard module:

SET(MEDFILE_INCLUDE_DIRS "@PACKAGE_CONF_INCLUDE_DIRS@")

# Load the dependencies for the libraries of @PROJECT_NAME@ 
# (contains definitions for IMPORTED targets). This is only 
# imported if we are not built as a subproject (in this case targets are already there)
IF(NOT TARGET medC AND NOT @PROJECT_NAME@_BINARY_DIR)
  # Load the Fortran targets if MED-file was compiled with it
  INCLUDE("@PACKAGE_INSTALL_CMAKE_CONFIG_DIR@/@PROJECT_NAME@Targets.cmake")
ENDIF()   

# Options exported by the package:
SET(MEDFILE_USE_MPI @MEDFILE_USE_MPI@)
SET(MEDFILE_VERSION @MED_STR_VERSION@)
SET(MEDFILE_BUILD_SHARED_LIBS @MEDFILE_BUILD_SHARED_LIBS@)
SET(MEDFILE_BUILD_STATIC_LIBS @MEDFILE_BUILD_STATIC_LIBS@)

# These are IMPORTED targets created by @PROJECT_NAME@Targets.cmake
IF(MEDFILE_BUILD_SHARED_LIBS)
  SET(MEDFILE_C_LIBRARIES medC)
  SET(MEDFILE_EXTRA_LIBRARIES medimportengine)
ENDIF()
IF(MEDFILE_BUILD_STATIC_LIBS)
  SET(MEDFILE_C_LIBRARIES medC_static)
  SET(MEDFILE_EXTRA_LIBRARIES medimportengine_static)
ENDIF()
# For now we don't expose Fortran bindings:
SET(MEDFILE_LIBRARIES ${MEDFILE_C_LIBRARIES})

# If HDF5 was found in CONFIG mode, we need to include its targets so that
# dependent projects can compile
SET(_hdf5_path "@HDF5_DIR@")
IF(_hdf5_path)
  FIND_PACKAGE(HDF5 REQUIRED COMPONENTS C 
         NO_MODULE PATHS "@HDF5_DIR@" NO_DEFAULT_PATH) 
ENDIF()

# Package root dir:
SET_AND_CHECK(MEDFILE_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@")

#### Now the specificities
# Dependencies *directly* used by the package and exported
# for forward reference:
# We set them only if they were used:
SET_AND_CHECK(HDF5_ROOT_DIR_EXP "@PACKAGE_HDF5_ROOT_DIR@")
IF(MEDFILE_USE_MPI)
  SET_AND_CHECK(MPI_ROOT_DIR_EXP  "@PACKAGE_MPI_ROOT_DIR@")
ENDIF()

