include(FindPackageHandleStandardArgs)
include(SelectLibraryConfigurations)

find_path(
	ATIDAQ_INCLUDE_DIR
	NAMES atidaq/ftconfig.h
)
find_library(
	ATIDAQ_LIBRARY_DEBUG
	NAMES atidaqd
)
find_library(
	ATIDAQ_LIBRARY_RELEASE
	NAMES atidaq
)
select_library_configurations(ATIDAQ)

set(ATIDAQ_INCLUDE_DIRS ${ATIDAQ_INCLUDE_DIR})
set(ATIDAQ_LIBRARIES ${ATIDAQ_LIBRARY})

find_package_handle_standard_args(
	ATIDAQ
	FOUND_VAR ATIDAQ_FOUND
	REQUIRED_VARS ATIDAQ_INCLUDE_DIR ATIDAQ_LIBRARY
)

if(ATIDAQ_FOUND AND NOT TARGET ATIDAQ::ATIDAQ)
	add_library(ATIDAQ::ATIDAQ UNKNOWN IMPORTED)
	if(ATIDAQ_LIBRARY_RELEASE)
		set_property(TARGET ATIDAQ::ATIDAQ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
		set_target_properties(ATIDAQ::ATIDAQ PROPERTIES IMPORTED_LOCATION_RELEASE "${ATIDAQ_LIBRARY_RELEASE}")
	endif()
	if(ATIDAQ_LIBRARY_DEBUG)
		set_property(TARGET ATIDAQ::ATIDAQ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
		set_target_properties(ATIDAQ::ATIDAQ PROPERTIES IMPORTED_LOCATION_DEBUG "${ATIDAQ_LIBRARY_DEBUG}")
	endif()
	set_target_properties(ATIDAQ::ATIDAQ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ATIDAQ_INCLUDE_DIRS}")
endif()

mark_as_advanced(ATIDAQ_INCLUDE_DIR)
