2024-07-18 09:38:18 +10:00
|
|
|
cmake_minimum_required (VERSION 3.20.0)
|
2017-01-31 20:31:19 +11:00
|
|
|
|
2018-08-28 14:02:34 +10:00
|
|
|
find_program(ASCIIDOC NAMES asciidoc asciidoctor DOC "path to the asciidoc binary")
|
2017-01-31 20:31:19 +11:00
|
|
|
mark_as_advanced (ASCIIDOC)
|
|
|
|
|
|
|
|
if (ASCIIDOC)
|
|
|
|
execute_process (
|
|
|
|
COMMAND ${ASCIIDOC} --version
|
|
|
|
OUTPUT_VARIABLE ASCIIDOC_version_output
|
|
|
|
ERROR_VARIABLE ASCIIDOC_version_error
|
|
|
|
RESULT_VARIABLE ASCIIDOC_version_result
|
|
|
|
)
|
|
|
|
|
|
|
|
if (${ASCIIDOC_version_output})
|
|
|
|
string (
|
|
|
|
REGEX REPLACE
|
|
|
|
"^asciidoc (\\d+\\.\\d+\\.\\d+)$"
|
|
|
|
"\\1"
|
|
|
|
ASCIIDOC_VERSION
|
|
|
|
"${ASCIIDOC_version_output}"
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (ASCIIDOC_target_usage "ASCIIDOC_target(<name> SOURCE <source> OUTPUT <output> [DEPENDS ...])")
|
|
|
|
|
|
|
|
macro (ASCIIDOC_target name)
|
|
|
|
set (_ASCIIDOC_${name}_onoff_args HTML5)
|
|
|
|
set (_ASCIIDOC_${name}_value_args SOURCE OUTPUT)
|
|
|
|
set (_ASCIIDOC_${name}_multi_args DEPENDS)
|
|
|
|
|
|
|
|
cmake_parse_arguments (_ASCIIDOC_${name}
|
|
|
|
"${_ASCIIDOC_${name}_onoff_args}"
|
|
|
|
"${_ASCIIDOC_${name}_value_args}"
|
|
|
|
"${_ASCIIDOC_${name}_multi_args}"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT _ASCIIDOC_${name}_SOURCE)
|
|
|
|
message (FATAL_ERROR "${ASCIIDOC_target_usage}")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (NOT _ASCIIDOC_${name}_OUTPUT)
|
|
|
|
message (FATAL_ERROR "${ASCIIDOC_target_usage}")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
get_filename_component (dir "${_ASCIIDOC_${name}_OUTPUT}" DIRECTORY)
|
|
|
|
file (MAKE_DIRECTORY "${dir}")
|
|
|
|
|
|
|
|
add_custom_command (
|
|
|
|
OUTPUT
|
|
|
|
"${_ASCIIDOC_${name}_OUTPUT}"
|
|
|
|
COMMAND
|
|
|
|
"${ASCIIDOC}"
|
|
|
|
-b html5
|
|
|
|
-o "${_ASCIIDOC_${name}_OUTPUT}"
|
2018-08-28 14:02:54 +10:00
|
|
|
#--theme=volnitsky
|
2017-01-31 20:31:19 +11:00
|
|
|
-a icons
|
|
|
|
"${_ASCIIDOC_${name}_SOURCE}"
|
|
|
|
DEPENDS
|
|
|
|
"${_ASCIIDOC_${name}_SOURCE};${_ASCIIDOC_${name}_DEPENDS}"
|
|
|
|
MAIN_DEPENDENCY
|
|
|
|
"${_ASCIIDOC_${name}_SOURCE}"
|
|
|
|
COMMENT
|
|
|
|
"[asciidoc] ${_ASCIIDOC_${name}_SOURCE}"
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target (${name} "${_ASCIIDOC_${name}_OUTPUT}")
|
|
|
|
endmacro ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args (ASCIIDOC
|
|
|
|
REQUIRED_VARS ASCIIDOC
|
|
|
|
VERSION_VAR ASCIIDOC_VERSION
|
|
|
|
)
|