if(NOT OPENEXR_HALF_LIBRARY)
  find_path(OPENEXR_HALF_INCLUDE_DIR "OpenEXR/half.h")
  find_library(OPENEXR_HALF_LIBRARY_DEBUG
    NAMES
      Half  # Arch Linux
      Half-2_3_s_d  # Windows
    PATH_SUFFIXES
      lib
  )
  find_library(OPENEXR_HALF_LIBRARY_RELEASE
    NAMES
      Half  # Arch Linux
      Half-2_3_s  # Windows
    PATH_SUFFIXES
      lib
  )
  set(OPENEXR_HALF_LIBRARY
    debug ${OPENEXR_HALF_LIBRARY_DEBUG}
    optimized ${OPENEXR_HALF_LIBRARY_RELEASE}
  )
endif()

FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENEXR_HALF REQUIRED_VARS
  OPENEXR_HALF_LIBRARY OPENEXR_HALF_INCLUDE_DIR)

mark_as_advanced(OPENEXR_HALF_INCLUDE_DIRS)
mark_as_advanced(OPENEXR_HALF_LIBRARIES)

if(OPENEXR_HALF_FOUND)
  set(OPENEXR_HALF_INCLUDE_DIRS ${OPENEXR_HALF_INCLUDE_DIR})
  set(OPENEXR_HALF_LIBRARIES ${OPENEXR_HALF_LIBRARY})

  if(NOT TARGET OpenEXR::half)
    add_library(OpenEXR::half UNKNOWN IMPORTED)
    set_target_properties(OpenEXR::half PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OPENEXR_HALF_INCLUDE_DIRS}")

    set_property(TARGET OpenEXR::half APPEND PROPERTY
      IMPORTED_CONFIGURATIONS RELEASE)
    set_property(TARGET OpenEXR::half APPEND PROPERTY
      IMPORTED_CONFIGURATIONS DEBUG)

    if(OPENEXR_HALF_LIBRARY_DEBUG AND OPENEXR_HALF_LIBRARY_RELEASE)
      set_target_properties(OpenEXR::half PROPERTIES
        IMPORTED_LOCATION_DEBUG "${OPENEXR_HALF_LIBRARY_DEBUG}"
        IMPORTED_LOCATION_RELEASE "${OPENEXR_HALF_LIBRARY_RELEASE}"
      )
    else()
      set_target_properties(OpenEXR::half PROPERTIES
        IMPORTED_LOCATION "${OPENEXR_HALF_LIBRARY_RELEASE}"
      )
    endif()
  endif()
endif()
