cmake_minimum_required(VERSION 3.7)

function(dkp_set_target_file target file)
	set_target_properties(${target} PROPERTIES DKP_FILE "${file}")
endfunction()

function(dkp_resolve_file outvar inname)
	if (TARGET "${inname}")
		get_target_property(_filename "${inname}" DKP_FILE)
		if (NOT _filename)
			message(FATAL_ERROR "dkp_resolve_file: target ${inname} does not have a registered file")
		endif()
		set(${outvar} "${_filename}" PARENT_SCOPE)
	elseif(EXISTS "${inname}")
		set(${outvar} "${inname}" PARENT_SCOPE)
	else()
		message(FATAL_ERROR "dkp_resolve_file: unable to resolve file: ${inname}")
	endif()
endfunction()
