cmake_minimum_required(VERSION 3.12)
project(hackrf_sdr_support)


find_library(HACKRF_LIBRARY hackrf)

if(HACKRF_LIBRARY OR MSVC OR ANDROID)
    message("Building with HackRF support")
    file(GLOB_RECURSE hackrf_sdr_support_CPPS *.cpp)
    add_library(hackrf_sdr_support SHARED ${hackrf_sdr_support_CPPS})
    target_include_directories(hackrf_sdr_support PUBLIC src)

    if(MSVC)
        target_link_libraries(hackrf_sdr_support PUBLIC satdump_core hackrf.dll)
        install(TARGETS hackrf_sdr_support DESTINATION ${CMAKE_INSTALL_LIBDIR}/satdump/plugins RUNTIME_DEPENDENCY_SET satdump_deps)
    elseif(ANDROID)
        target_link_libraries(hackrf_sdr_support PUBLIC satdump_core hackrf usb)
        target_include_directories(hackrf_sdr_support PUBLIC ../../../android/deps/libhackrf)
        install(TARGETS hackrf_sdr_support DESTINATION ${CMAKE_INSTALL_LIBDIR}/satdump/plugins)
    else()
        target_link_libraries(hackrf_sdr_support PUBLIC satdump_core ${HACKRF_LIBRARY})
        install(TARGETS hackrf_sdr_support DESTINATION ${CMAKE_INSTALL_LIBDIR}/satdump/plugins)
    endif()
else()
    message("HackRF Library could not be found! Not building.")
endif()