diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2020-05-27 18:49:05 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2020-05-28 15:42:22 +0200 |
commit | f7a3d5c3e272cbb059f96b90a2555506c9a6b454 (patch) | |
tree | 9da123e569b88e5de11ef772f9326e67edeca3af | |
parent | 3b6509cacff64191851aa1db18f9b2a421c5d33d (diff) | |
download | tde-cmake-f7a3d5c3e272cbb059f96b90a2555506c9a6b454.tar.gz tde-cmake-f7a3d5c3e272cbb059f96b90a2555506c9a6b454.zip |
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>
-rw-r--r-- | modules/TDEMacros.cmake | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index c1f8ab6..75bdf15 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -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} ) |