# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

# add here all the find_dependency() whenever switching to config based dependencies
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
    find_dependency(Imath @Imath_VERSION@)
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
    find_dependency(IlmBase @OpenEXR_VERSION@)
    find_dependency(OpenEXR @OpenEXR_VERSION@)
    find_dependency(ZLIB @ZLIB_VERSION@)  # Because OpenEXR doesn't do it
    find_dependency(Threads)  # Because OpenEXR doesn't do it
endif ()


find_dependency(OpenImageIO @OpenImageIO_VERSION@ REQUIRED)

# Compute the installation prefix relative to this file
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

# There's no guarantee that CMAKE_INSTALL_XXXDIR is a relative path so we extract the final component to handle absolute paths
get_filename_component(_INCLUDE_DIR_NAME "@CMAKE_INSTALL_INCLUDEDIR@" NAME)
get_filename_component(_LIB_DIR_NAME "@CMAKE_INSTALL_LIBDIR@" NAME)

set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_INCLUDES    "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_LIB_DIR     "${_IMPORT_PREFIX}/${_LIB_DIR_NAME}")

#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR  "${installedPrefix}/@CONFIG_INSTALL_DIR@")

include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

check_required_components ("@PROJECT_NAME@")
