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} )