# Copyright 2011,2012,2016,2018,2019 Free Software Foundation, Inc.
#
# This file was generated by gr_modtool, a tool from the GNU Radio framework
# This file is a part of gr-satnogs
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

# ##############################################################################
# Setup library
# ##############################################################################
include(GrPlatform) # define LIB_SUFFIX

add_subdirectory(code)
add_subdirectory(libfec)

list(
  APPEND
  satnogs_sources
  # cmake-format: sortable
  amsat_duv_decoder.cc
  argos_ldr_decoder.cc
  ax100_decoder.cc
  ax100_encoder.cc
  ax100_mode5.cc
  ax100_mode5_encoder.cc
  ax100_mode6.cc
  ax100_mode6_encoder.cc
  ax25_decoder.cc
  ax25_encoder.cc
  ber_calculator_impl.cc
  conv_decoder.cc
  conv_encoder.cc
  crc.cc
  crc_async_impl.cc
  cw_decoder.cc
  cw_decoder_priv.cc
  cw_encoder_impl.cc
  decoder.cc
  doppler_correction_cc_impl.cc
  dummy_doppler_correction.cc
  encoder.cc
  frame_decoder_impl.cc
  frame_encoder_impl.cc
  golay24.cc
  ieee802_15_4_encoder.cc
  ieee802_15_4_variant_decoder.cc
  json_converter_impl.cc
  metadata.cc
  metadata_sink_impl.cc
  morse_tree.cc
  noaa_apt_sink_impl.cc
  ogg_encoder_impl.cc
  ogg_source_impl.cc
  reed_muller.cc
  rigctl_doppler_correction.cc
  shift_reg.cc
  sigmf_metadata.cc
  sstv_pd120_sink_impl.cc
  usp_encoder.cc
  utils.cc
  waterfall_sink_impl.cc
  whitening.cc)

set(satnogs_sources
    "${satnogs_sources}"
    PARENT_SCOPE)
if(NOT satnogs_sources)
  message(STATUS "No C++ sources... skipping lib/")
  return()
endif(NOT satnogs_sources)

add_library(gnuradio-satnogs SHARED ${satnogs_sources})
add_dependencies(gnuradio-satnogs gnuradio-satnogs-fec)

target_link_libraries(
  gnuradio-satnogs
  gnuradio-satnogs-fec
  gnuradio::gnuradio-runtime
  gnuradio::gnuradio-analog
  gnuradio::gnuradio-blocks
  gnuradio::gnuradio-fft
  gnuradio::gnuradio-digital
  gnuradio::gnuradio-pmt
  gnuradio-satnogs-code
  ${ITPP_LIBRARIES}
  ${OGGVORBIS_LIBRARIES}
  ${PNG_LIBRARIES}
  ${png++_LIBRARIES}
  ${hamlib++_LIBRARIES}
  nlohmann_json::nlohmann_json
  Volk::volk)
target_include_directories(
  gnuradio-satnogs
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../CRCpp/inc>
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../lib/>
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../lib/libsigmf/external>
  PUBLIC $<INSTALL_INTERFACE:include>)
set_target_properties(gnuradio-satnogs PROPERTIES DEFINE_SYMBOL
                                                  "gnuradio_satnogs_EXPORTS")

if(APPLE)
  set_target_properties(
    gnuradio-satnogs PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(APPLE)

# ##############################################################################
# Install built library files
# ##############################################################################
include(GrMiscUtils)
gr_library_foo(gnuradio-satnogs)

# ##############################################################################
# Print summary
# ##############################################################################
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for version: ${VERSION} / ${LIBVER}")

# ##############################################################################
# Build and register unit test
# ##############################################################################
include(GrTest)

# If your unit tests require special include paths, add them here
# include_directories()
set(test_satnogs_sources # cmake-format: sortable
                         qa_ccsds_rs.cc qa_crc.cc qa_egolay.cc)

# List all files that contain Boost.UTF unit tests here
list(APPEND test_satnogs_sources)
# Anything we need to link to for the unit tests go here
list(APPEND GR_TEST_TARGET_DEPS gnuradio-satnogs)

if(NOT test_satnogs_sources)
  message(STATUS "No C++ unit tests... skipping")
  return()
endif(NOT test_satnogs_sources)

foreach(qa_file ${test_satnogs_sources})
  gr_add_cpp_test("satnogs_${qa_file}" ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file})
endforeach(qa_file)
