find_package(PkgConfig)
pkg_check_modules(TWCLIENT QUIET twclient>=twclient_FIND_VERSION)
pkg_check_modules(TWCLIENT_ICONS QUIET twclient-icons>=twclient_FIND_VERSION)

find_library(TWCLIENT_LOCATION NAMES twclient HINTS
  ${TWCLIENT_LIBRARY_DIRS})
find_library(TWCLIENT_ICONS_LOCATION NAMES twclient-icons HINTS
  ${TWCLIENT_ICONS_LIBRARY_DIRS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(twclient DEFAULT_MSG
  TWCLIENT_LIBRARIES TWCLIENT_ICONS_LIBRARIES
  TWCLIENT_INCLUDE_DIRS TWCLIENT_ICONS_INCLUDE_DIRS)
mark_as_advanced(TWCLIENT_LIBRARIES TWCLIENT_ICONS_LIBRARIES
  TWCLIENT_INCLUDE_DIRS TWCLIENT_ICONS_INCLUDE_DIRS)

if (TWCLIENT_FOUND AND TWCLIENT_ICONS_FOUND AND
    NOT TARGET twclient::twclient AND
    NOT TARGET twclient::icons)

  add_library(twclient::twclient UNKNOWN IMPORTED)
  set_target_properties(twclient::twclient PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "${TWCLIENT_LOCATION}"
    INTERFACE_LINK_DIRECTORIES "${TWCLIENT_LIBRARY_DIRS}"
    INTERFACE_LINK_LIBRARIES "${TWCLIENT_LIBRARIES}"
    INTERFACE_INCLUDE_DIRECTORIES "${TWCLIENT_INCLUDE_DIRS}"
    )

  add_library(twclient::icons UNKNOWN IMPORTED)
  set_target_properties(twclient::icons PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "${TWCLIENT_ICONS_LOCATION}"
    INTERFACE_LINK_DIRECTORIES "${TWCLIENT_ICONS_LIBRARY_DIRS}"
    INTERFACE_LINK_LIBRARIES "${TWCLIENT_ICONS_LIBRARIES}"
    INTERFACE_INCLUDE_DIRECTORIES "${TWCLIENT_ICONS_INCLUDE_DIRS}"
    )

endif()
