# The math library (libm), found as a full path. A bare `m` could be mistaken
# for a target of the same name (a module called `m`). Empty where the math
# functions are part of the C library itself (Windows, macOS).
find_library(JM_MATH_LIBRARY m)
if(NOT JM_MATH_LIBRARY)
  set(JM_MATH_LIBRARY "")
endif()

add_library(snr_core OBJECT snr_core.c snr_data_aided_db.c snr_m2m4_db.c snr_data_aided_db_series.c snr_m2m4_db_series.c)
target_include_directories(snr_core PUBLIC ${CMAKE_SOURCE_DIR}/native/inc)

if(BUILD_PYTHON)
# snr Python module
Python3_add_library(snr MODULE WITH_SOABI snr_ext.c)
target_link_libraries(snr PRIVATE
    snr_core
    Python3::NumPy)
target_include_directories(snr PRIVATE ${CMAKE_SOURCE_DIR}/native/inc)
set_target_properties(snr PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY "${PYTHON_PACKAGE_DIR}/snr"
    RUNTIME_OUTPUT_DIRECTORY "${PYTHON_PACKAGE_DIR}/snr")
add_custom_command(TARGET snr POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "$<TARGET_FILE:snr>"
        "${PYTHON_PACKAGE_DIR}/snr/$<TARGET_FILE_NAME:snr>"
    VERBATIM
    COMMENT "Copy snr extension module")
endif()

# Your own CMake for this directory goes in snr_extra.cmake beside this
# file: it is included here and never overwritten. This file is
# regenerated by just-makeit.
include(${CMAKE_CURRENT_LIST_DIR}/snr_extra.cmake OPTIONAL)
