forked from standardese/standardese
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstandardese-config.cmake
75 lines (64 loc) · 2.96 KB
/
standardese-config.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright (C) 2016 Jonathan Müller <[email protected]>
# This file is subject to the license terms in the LICENSE file
# found in the top-level directory of this distribution.
# EXTERNAL
# makes imported targets available
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/${CMAKE_BUILD_TYPE}/standardese.cmake)
find_package(Threads REQUIRED)
# EXTERNAL
# saves the location of the standardese executable in STANDARDESE_TOOL
find_program(STANDARDESE_TOOL standardese)
# EXTERNAL
# generates documentation for a given target
# will create a custom target standardese_${target} that will run standardese with given options
# usage:
# standardese_generate(<target> [ALL] [CONFIG <config>]
# [INCLUDE_DIRECTORY <include_dir_a> [include_dir_b ...]]
# [MACRO_DEFINITION <def_a> [def_b ...]]
# [MACRO_UNDEFINITION <def_a> [def_b ...]]
# INPUT <input_a> [input_b ...])
# ALL - whether or not the custom target will run when building all
# CONFIG - same as --config for standardese
# INCLUDE_DIRECTORY - same as -I <arg> for standardese for each argument
# MACRO_DEFINITION - same as -D <arg> for standardese for each argument
# MACRO_UNDEFINITION - same as -U <arg> for standardese for each argument
# INPUT - the input files given to standardese
# all paths must be absolute (e.g. through CMAKE_CURRENT_SOURCE_DIR or similar)
# or relative to the working directory of standardese which is ${CMAKE_CURRENT_BINARY_DIR}/standardese_${target}
function(standardese_generate target)
cmake_parse_arguments(STANDARDESE "ALL" # no arg
"CONFIG" # single arg
"INPUT;INCLUDE_DIRECTORY;MACRO_DEFINITION;MACRO_UNDEFINITION" # multiple arg
${ARGN})
if(STANDARDESE_CONFIG)
list(APPEND options --config ${STANDARDESE_CONFIG})
endif()
if(STANDARDESE_INCLUDE_DIRECTORY)
foreach(dir ${STANDARDESE_INCLUDE_DIRECTORY})
list(APPEND options -I ${dir})
endforeach()
endif()
if(STANDARDESE_MACRO_DEFINITION)
foreach(def ${STANDARDESE_MACRO_DEFINITION})
list(APPEND options -D ${def})
endforeach()
endif()
if(STANDARDESE_MACRO_UNDEFINITION)
foreach(def ${STANDARDESE_MACRO_UNDEFINITION})
list(APPEND options -U ${def})
endforeach()
endif()
foreach(input ${STANDARDESE_INPUT})
list(APPEND options ${input})
endforeach()
if(STANDARDESE_ALL)
set(all ALL)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/standardese_${target})
add_custom_target(standardese_${target} ${all}
${STANDARDESE_TOOL} ${options}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/standardese_${target}
COMMENT "Generating documentation for target ${target}..."
VERBATIM)
endfunction()