From 4a3c96b1f355902a706a663e984193d7211d2c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 3 Jun 2021 14:59:40 +0200 Subject: tde_add_project_docs: Add common rules for generating and installing project documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- modules/TDEMacros.cmake | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 0318890..faf4170 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -2072,6 +2072,93 @@ macro( tde_create_translated_desktop ) endmacro( ) +################################################# +##### +##### tde_add_project_docs +##### +##### Macro for standard processing and installation of documentation and man pages. +##### This is designed for ordinary modules - as an applications, not for core modules. + +function( tde_add_project_docs ) + + file( GLOB_RECURSE _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} * ) + foreach( _doc_file IN LISTS _doc_files ) + get_filename_component( _dir ${_doc_file} PATH ) + list( APPEND _dirs ${_dir} ) + endforeach() + if( _dirs ) + list( SORT _dirs ) + list( REMOVE_DUPLICATES _dirs ) + endif() + + string( REGEX REPLACE "[ \r\n\t]+" ";" _linguas "$ENV{LINGUAS}" ) + + unset( _skip_subdir ) + foreach( _dir IN LISTS _dirs ) + string( REGEX REPLACE "/.*" "" _lang ${_dir} ) + if( NOT ${_lang} MATCHES "^(html|man|misc)$" + AND ( NOT DEFINED _skip_subdir OR + NOT ${_dir} MATCHES "^${_skip_subdir}/" ) + AND ( ${_lang} STREQUAL "en" OR + "${_linguas}" MATCHES "^;*$" OR + ";${_linguas};" MATCHES ";${_lang};" )) + if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt ) + set( _skip_subdir ${_dir} ) + add_subdirectory( ${_dir} ) + else() + unset( _skip_subdir ) + if( ${_dir} MATCHES "/[^/]*/" ) + string( REGEX REPLACE "^[^/]*/(.*)" "\\1" _doc_dest "${_dir}" ) + else() + string( REGEX REPLACE "^[^/]*/(.*)" "\\1" _doc_dest "${_dir}/${PROJECT_NAME}" ) + endif() + file( GLOB _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_dir} ${_dir}/*.docbook ) + if( _doc_files ) + list( FIND _doc_files "index.docbook" _find_index ) + if( -1 EQUAL _find_index ) + set( _noindex "NOINDEX" ) + else() + unset( _noindex ) + endif() + tde_create_handbook( + SOURCE_BASEDIR ${_dir} + ${_noindex} + LANG ${_lang} + DESTINATION ${_doc_dest} + ) + endif() + endif() + endif() + endforeach() + + if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/man AND + NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/man/CMakeLists.txt ) + file( GLOB_RECURSE _man_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} man/* ) + foreach( _man_file IN LISTS _man_files ) + if( ${_man_file} MATCHES "\\.[0-9]$" ) + string( REGEX REPLACE ".*\\.([0-9])$" "\\1" _man_section "${_man_file}" ) + list( APPEND _man_files_${_man_section} "${_man_file}" ) + list( APPEND _man_sections "${_man_section}" ) + endif() + endforeach() + foreach( _man_section IN LISTS _man_sections ) + INSTALL( + FILES ${_man_files_${_man_section}} + DESTINATION ${MAN_INSTALL_DIR}/man${_man_section} + COMPONENT doc + ) + endforeach() + endif() + + foreach( _dir html man misc ) + if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt ) + add_subdirectory( ${_dir} ) + endif() + endforeach() + +endfunction( ) + + ################################################# ##### ##### tde_create_handbook -- cgit v1.2.1