Update tde_add_project_* macros:

+ Added macros in the tde_conditional_add_project_* variant.
+ Macros can now be used from the project's top directory.
+ Added default processing for simple HTML documentation.
+ Added the 'other' directory to separate processing.
+ Added default processing for 'misc' directory.

Signed-off-by: Ray-V <ray-v@inbox.lv>
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 23d7973b29)
r14.0.x
Ray-V 3 years ago committed by Slávek Banko
parent 8b192e30cb
commit 0643c956f5
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1656,14 +1656,29 @@ endmacro( tde_add_tdeinit_executable )
################################################# #################################################
##### #####
##### tde_conditional_add_project_translations
##### tde_add_project_translations ##### tde_add_project_translations
##### #####
##### Macro for standard processing and installation of translations. ##### Macro for standard processing and installation of translations.
##### This is designed for ordinary modules - as an applications, not for core modules. ##### This is designed for ordinary modules - as an applications, not for core modules.
function( tde_conditional_add_project_translations _cond )
if( ${_cond} )
tde_add_project_translations()
endif()
endfunction()
function( tde_add_project_translations ) function( tde_add_project_translations )
file( GLOB_RECURSE po_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.po ) if( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} )
set( TRANSLATIONS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/translations/messages )
else()
set( TRANSLATIONS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
endif()
file( GLOB_RECURSE po_files RELATIVE ${TRANSLATIONS_SOURCE_DIR} ${TRANSLATIONS_SOURCE_DIR}/*.po )
string( REGEX REPLACE "[ \r\n\t]+" ";" _linguas "$ENV{LINGUAS}" ) string( REGEX REPLACE "[ \r\n\t]+" ";" _linguas "$ENV{LINGUAS}" )
foreach( _po ${po_files} ) foreach( _po ${po_files} )
@ -1674,7 +1689,7 @@ function( tde_add_project_translations )
else( ) else( )
set( _component "${PROJECT_NAME}" ) set( _component "${PROJECT_NAME}" )
endif( ) endif( )
tde_create_translation( FILES ${_po} LANG ${_lang} OUTPUT_NAME ${_component} ) tde_create_translation( FILES ${TRANSLATIONS_SOURCE_DIR}/${_po} LANG ${_lang} OUTPUT_NAME ${_component} )
endif( ) endif( )
endforeach( ) endforeach( )
@ -2101,14 +2116,29 @@ endmacro( )
################################################# #################################################
##### #####
##### tde_conditional_add_project_docs
##### tde_add_project_docs ##### tde_add_project_docs
##### #####
##### Macro for standard processing and installation of documentation and man pages. ##### Macro for standard processing and installation of documentation and man pages.
##### This is designed for ordinary modules - as an applications, not for core modules. ##### This is designed for ordinary modules - as an applications, not for core modules.
function( tde_conditional_add_project_docs _cond )
if( ${_cond} )
tde_add_project_docs()
endif()
endfunction()
function( tde_add_project_docs ) function( tde_add_project_docs )
file( GLOB_RECURSE _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} * ) if( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} )
set( DOCS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/doc )
else()
set( DOCS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
endif()
file( GLOB_RECURSE _doc_files RELATIVE ${DOCS_SOURCE_DIR} ${DOCS_SOURCE_DIR}/* )
foreach( _doc_file IN LISTS _doc_files ) foreach( _doc_file IN LISTS _doc_files )
get_filename_component( _dir ${_doc_file} PATH ) get_filename_component( _dir ${_doc_file} PATH )
list( APPEND _dirs ${_dir} ) list( APPEND _dirs ${_dir} )
@ -2123,15 +2153,15 @@ function( tde_add_project_docs )
unset( _skip_subdir ) unset( _skip_subdir )
foreach( _dir IN LISTS _dirs ) foreach( _dir IN LISTS _dirs )
string( REGEX REPLACE "/.*" "" _lang ${_dir} ) string( REGEX REPLACE "/.*" "" _lang ${_dir} )
if( NOT ${_lang} MATCHES "^(html|man|misc)$" if( NOT ${_lang} MATCHES "^(html|man|misc|other)$"
AND ( NOT DEFINED _skip_subdir OR AND ( NOT DEFINED _skip_subdir OR
NOT ${_dir} MATCHES "^${_skip_subdir}/" ) NOT ${_dir} MATCHES "^${_skip_subdir}/" )
AND ( ${_lang} STREQUAL "en" OR AND ( ${_lang} STREQUAL "en" OR
"${_linguas}" MATCHES "^;*$" OR "${_linguas}" MATCHES "^;*$" OR
";${_linguas};" MATCHES ";${_lang};" )) ";${_linguas};" MATCHES ";${_lang};" ))
if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt ) if( EXISTS ${DOCS_SOURCE_DIR}/${_dir}/CMakeLists.txt )
set( _skip_subdir ${_dir} ) set( _skip_subdir ${_dir} )
add_subdirectory( ${_dir} ) add_subdirectory( ${DOCS_SOURCE_DIR}/${_dir} )
else() else()
unset( _skip_subdir ) unset( _skip_subdir )
if( ${_dir} MATCHES "/[^/]*/" ) if( ${_dir} MATCHES "/[^/]*/" )
@ -2139,7 +2169,7 @@ function( tde_add_project_docs )
else() else()
string( REGEX REPLACE "^[^/]*/(.*)" "\\1" _doc_dest "${_dir}/${PROJECT_NAME}" ) string( REGEX REPLACE "^[^/]*/(.*)" "\\1" _doc_dest "${_dir}/${PROJECT_NAME}" )
endif() endif()
file( GLOB _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_dir} ${_dir}/*.docbook ) file( GLOB _doc_files RELATIVE ${DOCS_SOURCE_DIR}/${_dir} ${DOCS_SOURCE_DIR}/${_dir}/*.docbook )
if( _doc_files ) if( _doc_files )
list( FIND _doc_files "index.docbook" _find_index ) list( FIND _doc_files "index.docbook" _find_index )
if( -1 EQUAL _find_index ) if( -1 EQUAL _find_index )
@ -2148,19 +2178,32 @@ function( tde_add_project_docs )
unset( _noindex ) unset( _noindex )
endif() endif()
tde_create_handbook( tde_create_handbook(
SOURCE_BASEDIR ${_dir} SOURCE_BASEDIR ${DOCS_SOURCE_DIR}/${_dir}
${_noindex} ${_noindex}
LANG ${_lang} LANG ${_lang}
DESTINATION ${_doc_dest} DESTINATION ${_doc_dest}
) )
else()
file( GLOB _html_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${DOCS_SOURCE_DIR}/${_dir}/*.html )
if( _html_files )
file( GLOB _htmldoc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DOCS_SOURCE_DIR}/${_dir}/*.css
${DOCS_SOURCE_DIR}/${_dir}/*.jpg
${DOCS_SOURCE_DIR}/${_dir}/*.png
)
install(
FILES ${_html_files} ${_htmldoc_files}
DESTINATION ${HTML_INSTALL_DIR}/${_lang}/${_doc_dest}
)
endif()
endif() endif()
endif() endif()
endif() endif()
endforeach() endforeach()
if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/man AND if( EXISTS ${DOCS_SOURCE_DIR}/man AND
NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/man/CMakeLists.txt ) NOT EXISTS ${DOCS_SOURCE_DIR}/man/CMakeLists.txt )
file( GLOB_RECURSE _man_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} man/* ) file( GLOB_RECURSE _man_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${DOCS_SOURCE_DIR}/man/* )
foreach( _man_file IN LISTS _man_files ) foreach( _man_file IN LISTS _man_files )
if( ${_man_file} MATCHES "\\.[0-9]$" ) if( ${_man_file} MATCHES "\\.[0-9]$" )
string( REGEX REPLACE ".*\\.([0-9])$" "\\1" _man_section "${_man_file}" ) string( REGEX REPLACE ".*\\.([0-9])$" "\\1" _man_section "${_man_file}" )
@ -2177,9 +2220,19 @@ function( tde_add_project_docs )
endforeach() endforeach()
endif() endif()
foreach( _dir html man misc ) if( EXISTS ${DOCS_SOURCE_DIR}/misc AND
if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt ) NOT EXISTS ${DOCS_SOURCE_DIR}/misc/CMakeLists.txt )
add_subdirectory( ${_dir} ) install(
DIRECTORY ${DOCS_SOURCE_DIR}/misc/
DESTINATION ${SHARE_INSTALL_PREFIX}/doc/${PROJECT_NAME}
COMPONENT doc
PATTERN Makefile.am EXCLUDE
)
endif()
foreach( _dir html man misc other )
if( EXISTS ${DOCS_SOURCE_DIR}/${_dir}/CMakeLists.txt )
add_subdirectory( ${DOCS_SOURCE_DIR}/${_dir} )
endif() endif()
endforeach() endforeach()

Loading…
Cancel
Save