@PACKAGE_INIT@

INCLUDE(GNUInstallDirs)

SET(LIB_RING_QT_INCLUDE_DIR @INCLUDE_INSTALL_DIR@/libringqt)

# First, always set the dynamic path
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so;.dll")
SET(LIB_RING_QT_LIBRARY_NAME "ringqt")

FIND_LIBRARY(LIB_RING_QT_LIBRARY NAMES ringqt
            PATHS ${RING_BUILD_DIR}/.libs
            PATHS @LIB_INSTALL_DIR@
            PATHS ${CMAKE_INSTALL_PREFIX}/libexec )

#if ENABLE_STATIC is set, default to the static version
IF(NOT LIB_RING_QT_LIBRARY OR DEFINED ${ENABLE_STATIC} OR ${ENABLE_STATIC} MATCHES true)
   SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.la;.lib")
   SET(LIB_RING_QT_LIBRARY_NAME "ringqt")

   FIND_LIBRARY(LIB_RING_QT_LIBRARY NAMES ringqt
             PATHS ${RING_BUILD_DIR}/.libs
             PATHS @LIB_INSTALL_DIR@
             PATHS ${CMAKE_INSTALL_PREFIX}/libexec )
ENDIF()

FIND_LIBRARY(LIB_RING_QT_LIBRARY NAMES ${LIB_RING_QT_LIBRARY_NAME}
             PATHS ${RING_BUILD_DIR}/.libs
             PATHS @LIB_INSTALL_DIR@
             PATHS ${CMAKE_INSTALL_PREFIX}/libexec )


# Set the usual CMake library variables. This is required for some other official
# cmake macros to work
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIB_RING_QT
    FOUND_VAR
        LIB_RING_QT_FOUND
    REQUIRED_VARS
        LIB_RING_QT_LIBRARY
        LIB_RING_QT_INCLUDE_DIR
    VERSION_VAR
        @GENERIC_LIB_VERSION@
)

# This isn't pretty, and the blame is on me. I was clueless when I first
# wrote this file and got something wrong. `LIB_RING_QT` doesn't match the
# project name in `ring-lrc/CMakeLists.txt`. This causes problems when the
# ring-lrc Git repository is used in CMake external projects. Given
# changing it above would break the API, it instead add a second target
# with the proper name.

SET(ringqt_LIBRARY ${LIB_RING_QT_LIBRARY})
SET(ringqt_INCLUDE_DIR ${LIB_RING_QT_INCLUDE_DIR})
SET(ringqt_INCLUDES ${LIB_RING_QT_INCLUDE_DIR}) #compat

FIND_PACKAGE_HANDLE_STANDARD_ARGS(ringqt
    FOUND_VAR
        ringqt_FOUND
    REQUIRED_VARS
        ringqt_LIBRARY
        ringqt_INCLUDE_DIR
    VERSION_VAR
        1.0.0
)

if(NOT TARGET ringqt AND NOT ringqt_BINARY_DIR)
  include("@CMAKE_INSTALL_FULL_LIBDIR@/cmake/LibRingQt/LibRingQtTargets.cmake")
endif()
