cmake_minimum_required(VERSION 3.10)
project(ewsdr_dmr C)

find_path(MBELIB_INCLUDE_DIR mbelib.h REQUIRED)
find_library(MBELIB_LIBRARY NAMES mbe REQUIRED)

add_library(ewsdr_dmr SHARED ewsdr_dmr.c)
target_compile_definitions(ewsdr_dmr PRIVATE EWSDR_DMR_BUILD)
target_include_directories(ewsdr_dmr
  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  PRIVATE ${MBELIB_INCLUDE_DIR})
target_link_libraries(ewsdr_dmr PRIVATE ${MBELIB_LIBRARY})
set_target_properties(ewsdr_dmr PROPERTIES
  C_VISIBILITY_PRESET hidden
  VISIBILITY_INLINES_HIDDEN YES)

include(GNUInstallDirs)
install(TARGETS ewsdr_dmr
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ewsdr_dmr.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
