# Copyright 2011 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-gsm
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

########################################################################
# Setup dependencies
########################################################################
find_package(Doxygen)

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

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

endif(ENABLE_DOXYGEN)

########################################################################
# Convert manual pages from rst to roff and install them
########################################################################
find_program(RST2MAN_EXECUTABLE NAMES rst2man rst2man.py rst2man2 rst2man2.py)

function(BUILD_MAN_PAGE _sources _src _dst)
    add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_dst}"
                       COMMAND ${RST2MAN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_src} ${CMAKE_CURRENT_BINARY_DIR}/${_dst}
                       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_src})

    list(APPEND ${_sources} "${CMAKE_CURRENT_BINARY_DIR}/${_dst}")
    set(${_sources} ${${_sources}} PARENT_SCOPE)

    add_custom_target(man_${_src} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_dst})
endfunction()


if(NOT RST2MAN_EXECUTABLE)
    message(WARNING "rst2man from python-docutils is required to build man pages")
else()
    build_man_page(MAN1_OUTPUT grgsm_livemon.rst grgsm_livemon.1)
    install(
        FILES
        ${MAN1_OUTPUT}
        DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
    )
endif()
