#
# Define how to use third party, i.e. 
# - include directory
# - library
# - preprocessor definitions needed by package
#
cmake_policy(SET CMP0074 NEW)
if(NOT HDF5_ROOT)
	set(HDF5_ROOT "not defined" CACHE PATH "path to HDF5 root folder")	
	message(WARNING "Please define HDF5 root folder")
endif(NOT HDF5_ROOT)
if (HDF5_ROOT STREQUAL "not defined")
	message(WARNING "Please define HDF5 root folder")
	set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE ON)
endif(HDF5_ROOT STREQUAL "not defined")

FIND_PACKAGE(HDF5 COMPONENTS C REQUIRED)
SET(HDF5_DEFINITIONS "-DH5_USE_16_API")
 
MACRO(USE_HDF5)
	INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
	ADD_DEFINITIONS(${HDF5_DEFINITIONS})
	
	LIST( APPEND MY_EXTERNAL_LINK_LIBRARIES ${HDF5_LIBRARIES} )
	REMEMBER_TO_CALL_THIS_INSTALL_MACRO( INSTALL_RUNTIME_LIBRARIES_HDF5 )
ENDMACRO()

MACRO(INSTALL_RUNTIME_LIBRARIES_HDF5)
	MESSAGE( STATUS "--> ThirdPartyHdf5: installing HDF5 library ..." )
	IF(MSVC)
		SET(MSVC_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES})
		FOREACH(BUILD_TYPE ${MSVC_CONFIGURATION_TYPES})
			FILE(COPY ${HDF5_INCLUDE_DIRS}/../bin/
				DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${BUILD_TYPE}
				FILES_MATCHING PATTERN "*.dll" PATTERN "*.exe" EXCLUDE )			
		ENDFOREACH()
	ENDIF()
ENDMACRO()