include(LibFindMacros)

libfind_pkg_check_modules(DISCORDRPC_PKGCONF DISCORDRPC)

find_path(DISCORDRPC_INCLUDE_DIR
	NAMES discord_rpc.h
	PATHS
		${DISCORDRPC_PKGCONF_INCLUDE_DIRS}
		"/usr/include"
		"/usr/local/include"
)

find_library(DISCORDRPC_LIBRARY
	NAMES discord-rpc
	PATHS
		${DISCORDRPC_PKGCONF_LIBRARY_DIRS}
		"/usr/lib"
		"/usr/local/lib"
)

set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
libfind_process(DISCORDRPC)

if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC)
	add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED)
	set_target_properties(
		DiscordRPC::DiscordRPC
		PROPERTIES
		IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}"
		INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}"
	)
endif()
