cmake_minimum_required(VERSION 3.13)

# Define the static library target for the Lost + Found INMP441 driver
add_library(lf-inmp441 STATIC)

# Expose the source files from src/
target_sources(lf-inmp441 PRIVATE
    ${CMAKE_CURRENT_LIST_DIR}/src/lf_inmp441.c
)

# Expose the public header file search path from include/
target_include_directories(lf-inmp441 PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

# Expose the binary directory privately so lf_inmp441.c can include the generated PIO header
target_include_directories(lf-inmp441 PRIVATE
    ${CMAKE_CURRENT_BINARY_DIR}
)

# Compile PIO file using Pico SDK generator
pico_generate_pio_header(lf-inmp441 ${CMAKE_CURRENT_LIST_DIR}/src/lf_inmp441.pio)

# Link hardware dependencies from the Pico C SDK and the math library
target_link_libraries(lf-inmp441 PUBLIC
    pico_stdlib
    hardware_pio
    hardware_dma
    hardware_clocks
    hardware_gpio
    m
)
