Browse Source

tde_create_handbook: Add an optional SOURCE_BASEDIR argument.

Using the optional SOURCE_BASEDIR argument, it is possible to use
tde_create_handbook in CMakeLists.txt from a folder other than the
folder containing the documentation itself.

This will allow the creation of common rules for generating documentation
for all languages that are currently available, without the need to
create CMakeLists.txt in the directory of each individual language.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/47/head
Slávek Banko 3 months ago
parent
commit
f7a3d5c3e2
No known key found for this signature in database GPG Key ID: 608F5293A04BE668
1 changed files with 42 additions and 7 deletions
  1. +42
    -7
      modules/TDEMacros.cmake

+ 42
- 7
modules/TDEMacros.cmake View File

@@ -1957,12 +1957,20 @@ macro( tde_create_handbook )
unset( _extra )
unset( _srcdir )

get_filename_component( _source_basedir "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE )
set( _lang en )
set( _first_arg 1 )
set( _var _target )

foreach( _arg ${ARGN} )

# found directive "SOURCE_BASEDIR"
if( "+${_arg}" STREQUAL "+SOURCE_BASEDIR" )
unset( _source_basedir )
set( _var _source_basedir )
set( _directive 1 )
endif()

# found directive "NOINDEX"
if( "+${_arg}" STREQUAL "+NOINDEX" )
set( _noindex 1 )
@@ -2019,6 +2027,16 @@ macro( tde_create_handbook )

endforeach()

# if source_basedir is relative, complete the path to absolute
if( NOT IS_ABSOLUTE ${_source_basedir} )
get_filename_component( _source_basedir "${_source_basedir}" ABSOLUTE )
endif()

# prepare the binary directory according to source_basedir
file( RELATIVE_PATH _binary_basedir "${CMAKE_CURRENT_SOURCE_DIR}" "${_source_basedir}" )
set( _binary_basedir "${CMAKE_CURRENT_BINARY_DIR}/${_binary_basedir}" )
file( MAKE_DIRECTORY "${_binary_basedir}" )

# if no target specified, try to guess it from DESTINATION
if( NOT _target )
if( NOT _dest )
@@ -2029,9 +2047,24 @@ macro( tde_create_handbook )

set( _target "${_target}-${_lang}-handbook" )

# if sources are listed, complete the path to absolute
if( _srcs )
foreach( _src ${_srcs} )
if( NOT IS_ABSOLUTE ${_src} )
list( REMOVE_ITEM _srcs ${_src} )
get_filename_component( _src "${_source_basedir}/${_src}" ABSOLUTE )
list( APPEND _srcs ${_src} )
endif()
endforeach()
endif()

# if no file specified, include all docbooks, stylesheets and images
if( NOT _srcs )
file( GLOB _srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.docbook *.css *.png )
file( GLOB _srcs
${_source_basedir}/*.docbook
${_source_basedir}/*.css
${_source_basedir}/*.png
)
endif()

# if no destination specified, defaulting to HTML_INSTALL_DIR
@@ -2050,7 +2083,7 @@ macro( tde_create_handbook )
if( NOT _noindex )

# check for index.docbook
list( FIND _srcs "index.docbook" _find_index )
list( FIND _srcs "${_source_basedir}/index.docbook" _find_index )
if( -1 EQUAL _find_index )
tde_message_fatal( "missing index.docbook file" )
endif()
@@ -2061,14 +2094,16 @@ macro( tde_create_handbook )
endif()

add_custom_command(
OUTPUT index.cache.bz2
COMMAND ${KDE3_MEINPROC_EXECUTABLE} ${_srcdir} --check --cache index.cache.bz2 ${CMAKE_CURRENT_SOURCE_DIR}/index.docbook
OUTPUT ${_binary_basedir}/index.cache.bz2
COMMAND ${KDE3_MEINPROC_EXECUTABLE} ${_srcdir} --check --cache index.cache.bz2 ${_source_basedir}/index.docbook
COMMENT "Generating ${_target}"
DEPENDS ${_srcs} )
DEPENDS ${_srcs}
WORKING_DIRECTORY "${_binary_basedir}"
)

add_custom_target( ${_target} ALL DEPENDS index.cache.bz2 )
add_custom_target( ${_target} ALL DEPENDS ${_binary_basedir}/index.cache.bz2 )

list( APPEND _srcs ${CMAKE_CURRENT_BINARY_DIR}/index.cache.bz2 )
list( APPEND _srcs ${_binary_basedir}/index.cache.bz2 )

if( NOT TDE_HTML_DIR )
set( TDE_HTML_DIR ${HTML_INSTALL_DIR} )


Loading…
Cancel
Save