# Copyright 2011 Free Software Foundation, Inc.
# Copyright 2020 Daniel Estevez <daniel@destevez.net>
#
# 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 dependencies
########################################################################
find_package(Doxygen)

########################################################################
# Begin conditional configuration
########################################################################
if(ENABLE_DOXYGEN)

########################################################################
# Add subdirectories
########################################################################
add_subdirectory(doxygen)

endif(ENABLE_DOXYGEN)

########################################################################
# Man pages
########################################################################
if(ENABLE_MANPAGES)

FIND_PROGRAM(BZIP
             NAMES bzip2
             PATHS /bin
                   /usr/bin
                   /usr/local/bin)

if(NOT BZIP)
        MESSAGE(FATAL_ERROR "Could not find bzip2 for man page compression.")
endif(NOT BZIP)

set(MAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MAN_BUILD_DIR ${PROJECT_BINARY_DIR}/docs)

list(APPEND manpages
     gr_satellites.1
     gr_satellites_ssdv.1
     smog_p_spectrum.1
)

# If user has not set the base dir for man pages, use a default location
set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)

foreach(manpage ${manpages})
    add_custom_target(generate_manpage_${manpage} ALL
        COMMAND ${BZIP} -c ${MAN_SRC_DIR}/${manpage} > ${MAN_BUILD_DIR}/${manpage}.bz2
    )
    install(FILES
       ${MAN_BUILD_DIR}/${manpage}.bz2
       DESTINATION ${MAN_INSTALL_DIR}/man1
    )
endforeach(manpage)

endif(ENABLE_MANPAGES)
