5 # Find ldoc executable.
10 # This module defines the following variables:
21 # .. command:: create_ldoc
25 # create_ldoc(target [QUIET] [VERBOSE]
26 # [WORKING_DIRECTORY dir] [COMMENT comment] [CONFIG cfg]
27 # [OPTIONS opt ...] [SOURCES src ...] [src ...]
30 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
32 find_program(LDOC_EXECUTABLE NAMES ldoc ldoc.bat)
34 find_program(LDOC_EXECUTABLE NAMES ldoc)
36 mark_as_advanced(LDOC_EXECUTABLE)
38 if(EXISTS "${LDOC_EXECUTABLE}")
39 execute_process(COMMAND ${LDOC_EXECUTABLE} OUTPUT_VARIABLE LDOC_VERSION ERROR_VARIABLE LDOC_VERSION)
40 string(REGEX REPLACE "[^0-9]+([^\n ]+).*" "\\1" LDOC_VERSION "${LDOC_VERSION}")
43 find_package_handle_standard_args(LDoc
53 function(create_ldoc target)
54 cmake_parse_arguments(LDOC "QUIET;VERBOSE" "WORKING_DIRECTORY;COMMENT;CONFIG" "OPTIONS;SOURCES" ${ARGN})
55 list(APPEND LDOC_SOURCES ${LDOC_UNPARSED_ARGUMENTS})
57 list(INSERT LDOC_OPTIONS 0 --quiet)
60 list(INSERT LDOC_OPTIONS 0 --verbose)
62 if(EXISTS "${LDOC_CONFIG}")
63 list(APPEND LDOC_OPTIONS -c ${LDOC_CONFIG})
65 if(NOT LDOC_WORKING_DIRECTORY)
66 set(LDOC_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
69 set(LDOC_COMMENT "Generate API documentation for ${target}")
71 add_custom_target(${target} # https://stevedonovan.github.io/ldoc/manual/doc.md.html
72 COMMAND ${LDOC_EXECUTABLE} ${LDOC_OPTIONS} ${LDOC_SOURCES}
73 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
74 COMMENT "${LDOC_COMMENT}"