Warning, /sdk/pology/cmake/EpydocTools.cmake is written in an unsupported language. File is not indexed.

0001 # TODO: Add doc comments for all this stuff.
0002 
0003 if(NOT EPYDOC_EXECUTABLE)
0004     find_package(Epydoc 3.0)
0005 endif()
0006 
0007 if(NOT epyt_target_count)
0008     set(epyt_target_count 1)
0009 endif()
0010 
0011 
0012 function(GET_ABSOLUTE_PATHS abspathsvar absroot)
0013     set(paths ${ARGN})
0014 
0015     set(abspaths)
0016     foreach(path ${paths})
0017         if(NOT IS_ABSOLUTE ${path})
0018             set(path ${absroot}/${path})
0019         endif()
0020         set(abspaths ${abspaths} ${path})
0021     endforeach()
0022 
0023     set(${abspathsvar} ${abspaths} PARENT_SCOPE)
0024 
0025 endfunction()
0026 
0027 
0028 macro(EPYDOC_TO_HTML)
0029 
0030     set(optargs)
0031     set(svalargs PYPKGDIR OUTDIR DESTINATION TARGET)
0032     set(mvalargs EPYOPTS)
0033     cmake_parse_arguments(EPYT_H
0034                           "${optargs}" "${svalargs}" "${mvalargs}" ${ARGN})
0035     if(EPYT_H_UNPARSED_ARGUMENTS)
0036         string(REPLACE ";" " " badargs "${EPYT_H_UNPARSED_ARGUMENTS}")
0037         message(FATAL_ERROR "Unknown arguments: ${badargs}")
0038     endif()
0039     if(NOT EPYT_H_OUTDIR)
0040         message(FATAL_ERROR "Output directory for HTML pages not set (OUTDIR).")
0041     endif()
0042     if(NOT EPYT_H_DESTINATION)
0043         message(FATAL_ERROR "Install directory not set (DESTINATION).")
0044     endif()
0045 
0046     get_absolute_paths(pypkgdir ${CMAKE_CURRENT_SOURCE_DIR} ${EPYT_H_PYPKGDIR})
0047     get_absolute_paths(outdir ${CMAKE_CURRENT_BINARY_DIR} ${EPYT_H_OUTDIR})
0048 
0049     if(NOT EPYT_H_TARGET)
0050         string(REPLACE ${CMAKE_SOURCE_DIR}/ "" srcsubdir
0051                        ${CMAKE_CURRENT_SOURCE_DIR})
0052         string(REPLACE "/" "-" targbase ${srcsubdir})
0053         set(target "${targbase}-epyt${epyt_target_count}-epydoc-to-html")
0054         math(EXPR epyt_target_count "${epyt_target_count} + 1")
0055     else()
0056         set(target ${EPYT_H_TARGET})
0057     endif()
0058 
0059     file(GLOB_RECURSE pyfiles "${pypkgdir}/*.py") # evil
0060     set(targfilebase ${target}-buildstamp)
0061     set(targfile ${outdir}/${targfilebase})
0062     add_custom_command(
0063         OUTPUT ${targfile}
0064         COMMAND find ${pypkgdir} -iname *.pyc -print0 | xargs -0r rm -rf
0065         COMMAND rm -rf ${outdir} && mkdir -p ${outdir}
0066         COMMAND PYTHONDONTWRITEBYTECODE=1 # do not pollute srcdir with *.pyc files
0067                 ${EPYDOC_EXECUTABLE} ${pypkgdir}/ -o ${outdir}
0068                 ${EPYT_H_EPYOPTS}
0069         COMMAND touch ${targfile}
0070         DEPENDS ${pyfiles}
0071     )
0072     add_custom_target(${target} ALL DEPENDS ${targfile})
0073     install(DIRECTORY ${outdir} DESTINATION ${EPYT_H_DESTINATION}
0074             PATTERN ${targfilebase} EXCLUDE)
0075 
0076 endmacro()
0077 
0078