cmake_minimum_required(VERSION 3.20)
project(HYPREDRVJuliaConsumer C)

find_package(HYPREDRV REQUIRED)

if(NOT TARGET HYPREDRV::Julia)
    message(FATAL_ERROR "Expected exported target HYPREDRV::Julia")
endif()

set(_julia_locations)
get_target_property(_julia_configs HYPREDRV::Julia IMPORTED_CONFIGURATIONS)
foreach(_config IN LISTS _julia_configs)
    get_target_property(_julia_location HYPREDRV::Julia IMPORTED_LOCATION_${_config})
    if(_julia_location)
        list(APPEND _julia_locations "${_julia_location}")
    endif()
endforeach()
get_target_property(_julia_location HYPREDRV::Julia IMPORTED_LOCATION)
if(_julia_location)
    list(APPEND _julia_locations "${_julia_location}")
endif()
if(NOT _julia_locations)
    message(FATAL_ERROR "HYPREDRV::Julia has no imported library location")
endif()
list(GET _julia_locations 0 _julia_lib)
message(STATUS "HYPREDRV::Julia imported location: ${_julia_lib}")

add_executable(hypredrv_julia_consumer consumer.c)
target_link_libraries(hypredrv_julia_consumer PRIVATE HYPREDRV::Julia)
