# 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-satellites
#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.

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

if(MSVC)
    # compile the golay24.c as C++ due to the lack of complex.h under MSVC
    # this is required by Volk, so we do the same trick as in Volk
    set_source_files_properties(golay24.c PROPERTIES LANGUAGE CXX)
endif()

# This workaround is taken from GNU Radio
# gr-fec/lib/reed-solomon/CMakeLists.txt
#MSVC workaround: we can't have dynamically sized arrays.
#So ifdef a max array bounds that is larger than NN and NROOTS
#Its a bit of a hack, but if you look at the code, its so full of ifdefs,
#and lacks optimization where it should be pre-allocating these arrays.
if(MSVC)
    set_source_files_properties(
        ${CMAKE_CURRENT_SOURCE_DIR}/libfec/decode_rs_char.c
        PROPERTIES COMPILE_DEFINITIONS "MAX_ARRAY=256;"
    )
endif(MSVC)

list(APPEND satellites_sources
    decode_rs_impl.cc
    encode_rs_impl.cc
    ao40_rs_decoder_impl.cc
    ax100_decode_impl.cc
    u482c_decode_impl.cc
    randomizer.c
    golay24.c
    lilacsat1_demux_impl.cc
    varlen_packet_tagger_impl.cc
    varlen_packet_framer_impl.cc
    viterbi.c
    nusat_decoder_impl.cc
    descrambler308_impl.cc
    decode_rs_general_impl.cc
    decode_rs_interleaved_impl.cc
    distributed_syncframe_soft_impl.cc
    matrix_deinterleaver_soft_impl.cc
    radecoder/ra_config.c
    radecoder/ra_decoder_gen.c
    radecoder/ra_lfsr.c
    radecoder/ra_encoder.c
    decode_ra_code_impl.cc
    nrzi_encode_impl.cc
    nrzi_decode_impl.cc
    libfec/decode_rs_8.c
    libfec/decode_rs_ccsds.c
    libfec/decode_rs_char.c
    libfec/encode_rs_8.c
    libfec/encode_rs_ccsds.c
    libfec/encode_rs_char.c
    libfec/taltab.c
    libfec/ccsds.c
    libfec/init_rs_char.c
)

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

add_library(gnuradio-satellites SHARED ${satellites_sources})
target_link_libraries(gnuradio-satellites gnuradio::gnuradio-runtime)
target_include_directories(gnuradio-satellites
    PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
    PUBLIC $<INSTALL_INTERFACE:include>
  )
set_target_properties(gnuradio-satellites PROPERTIES DEFINE_SYMBOL "gnuradio_satellites_EXPORTS")

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

########################################################################
# Install built library files
########################################################################
include(GrMiscUtils)
GR_LIBRARY_FOO(gnuradio-satellites)

########################################################################
# 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()
# List all files that contain Boost.UTF unit tests here
list(APPEND test_satellites_sources
)
# Anything we need to link to for the unit tests go here
list(APPEND GR_TEST_TARGET_DEPS gnuradio-satellites)

if(NOT test_satellites_sources)
    MESSAGE(STATUS "No C++ unit tests... skipping")
    return()
endif(NOT test_satellites_sources)

foreach(qa_file ${test_satellites_sources})
    GR_ADD_CPP_TEST("satellites_${qa_file}"
        ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file}
    )
endforeach(qa_file)
