@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(Threads)
find_dependency(Protobuf)

if(@USE_CRYPTO@ STREQUAL "OpenSSL")
    find_dependency(OpenSSL)
endif()

if(@USE_CRYPTO@ STREQUAL "libsodium")
    find_dependency(sodium)
endif()

if(@STEAMWEBRTC_ABSL_SOURCE@ STREQUAL "package")
    find_dependency(absl REQUIRED)
endif()

if(@USE_STEAMWEBRTC@)
    include(${CMAKE_CURRENT_LIST_DIR}/steamwebrtc.cmake)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/GameNetworkingSockets.cmake)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0")
    # Need to set IMPORTED_GLOBAL in order to create the aliases
    # However, IMPORTED_GLOBAL only exists in 3.11 and up
    # Also, setting IMPORTED_GLOBAL from another directory from where it was first set blows up
    # so we can only set it once.

    if(@BUILD_SHARED_LIB@)
        get_target_property(GNS_IMPORTED_GLOBAL_SET GameNetworkingSockets::GameNetworkingSockets IMPORTED_GLOBAL)

        if(NOT ${GNS_IMPORTED_GLOBAL_SET})
            set_target_properties(
                GameNetworkingSockets::GameNetworkingSockets
                PROPERTIES IMPORTED_GLOBAL True
            )
        endif()

        unset(GNS_IMPORTED_GLOBAL_SET)

        add_library(GameNetworkingSockets::shared ALIAS GameNetworkingSockets::GameNetworkingSockets)
    endif()

    if(@BUILD_STATIC_LIB@)
        get_target_property(GNS_IMPORTED_GLOBAL_SET GameNetworkingSockets::GameNetworkingSockets_s IMPORTED_GLOBAL)

        if(NOT ${GNS_IMPORTED_GLOBAL_SET})
            set_target_properties(
                GameNetworkingSockets::GameNetworkingSockets_s
                PROPERTIES IMPORTED_GLOBAL True
            )
        endif()

        unset(GNS_IMPORTED_GLOBAL_SET)

        add_library(GameNetworkingSockets::static ALIAS GameNetworkingSockets::GameNetworkingSockets_s)
    endif()
endif()

check_required_components(GameNetworkingSockets)
set(GameNetworkingSockets_FOUND 1)
