tde_add_project_docs: Add common rules for generating and installing project documentation.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 4a3c96b1f3)
r14.0.x
Slávek Banko 3 years ago
parent 03cdb8caf6
commit 0d83e597f2
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -2072,6 +2072,93 @@ macro( tde_create_translated_desktop )
endmacro( ) 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 ##### tde_create_handbook

Loading…
Cancel
Save