summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-06-03 14:59:40 +0200
committerSlávek Banko <slavek.banko@axis.cz>2021-06-03 14:59:40 +0200
commit4a3c96b1f355902a706a663e984193d7211d2c79 (patch)
tree5b61cd0017aa03b31100a30f742a4e2a1895fd20
parent870ade6418da040cf9db963adab5034c5bd169a7 (diff)
downloadtde-cmake-4a3c96b1.tar.gz
tde-cmake-4a3c96b1.zip
tde_add_project_docs: Add common rules for generating and installing project documentation.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEMacros.cmake87
1 files changed, 87 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 0318890..faf4170 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -2074,6 +2074,93 @@ 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
macro( tde_create_handbook )