#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set(THRIFT_VERSION @thrift_VERSION@)

@PACKAGE_INIT@

set_and_check(THRIFT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(THRIFT_CMAKE_DIR "@PACKAGE_CMAKE_INSTALL_DIR@")
set_and_check(THRIFT_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@")
if(NOT DEFINED THRIFT_COMPILER)
    set(THRIFT_COMPILER "${THRIFT_BIN_DIR}/thrift@CMAKE_EXECUTABLE_SUFFIX@")
endif()

if (NOT TARGET thrift::thrift)
    include("${THRIFT_CMAKE_DIR}/thriftTargets.cmake")
endif()
set(THRIFT_LIBRARIES thrift::thrift)

if(@ZLIB_FOUND@ AND @WITH_ZLIB@)
    if (NOT TARGET thriftz::thriftz)
        include("${THRIFT_CMAKE_DIR}/thriftzTargets.cmake")
    endif()
    set(THRIFT_LIBRARIES thriftz::thriftz)
endif()

if ("${THRIFT_LIBRARIES}" STREQUAL "")
    message(FATAL_ERROR "thrift libraries were not found")
endif()
if (NOT Thrift_FIND_QUIETLY)
    message(STATUS "Found thrift: ${PACKAGE_PREFIX_DIR}")
endif()


include(CMakeFindDependencyMacro)

if(@ZLIB_FOUND@ AND @WITH_ZLIB@)
    find_dependency(ZLIB)
endif()

if(@OPENSSL_FOUND@ AND @WITH_OPENSSL@)
    find_dependency(OpenSSL)
endif()

if(@Libevent_FOUND@ AND @WITH_LIBEVENT@)
    if(DEFINED CMAKE_MODULE_PATH)
        set(THRIFT_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH})
    else()
        unset(THRIFT_CMAKE_MODULE_PATH_OLD)
    endif()
    set(CMAKE_MODULE_PATH "${THRIFT_CMAKE_DIR}")
    find_dependency(Libevent)
    if(DEFINED THRIFT_CMAKE_MODULE_PATH_OLD)
        set(CMAKE_MODULE_PATH ${THRIFT_CMAKE_MODULE_PATH_OLD})
        unset(THRIFT_CMAKE_MODULE_PATH_OLD)
    else()
        unset(CMAKE_MODULE_PATH)
    endif()
endif()

check_required_components(Thrift)
