@@ -90,50 +90,60 @@ if (LLVM_ENABLE_DOXYGEN)
90
90
endif ()
91
91
endif ()
92
92
93
- function (gen_rst_file_from_td output_file td_option source docs_target )
93
+ function (gen_rst_file_from_td output_file td_option source docs_targets )
94
94
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${source} " )
95
95
message (FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR} " )
96
96
endif ()
97
97
get_filename_component (TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${source} " DIRECTORY )
98
98
list (APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR} " )
99
99
clang_tablegen (${output_file} ${td_option} SOURCE ${source} TARGET "gen-${output_file} " )
100
- add_dependencies (${docs_target} "gen-${output_file} " )
100
+ foreach (target ${docs_targets} )
101
+ add_dependencies (${target} gen-${output_file} )
102
+ endforeach ()
101
103
endfunction ()
102
104
103
105
if (LLVM_ENABLE_SPHINX )
104
106
include (AddSphinxTarget )
105
- if (SPHINX_FOUND )
107
+ if (SPHINX_FOUND AND (${SPHINX_OUTPUT_HTML} OR ${SPHINX_OUTPUT_MAN} ))
108
+ # Copy rst files to build directory before generating the html
109
+ # documentation. Some of the rst files are generated, so they
110
+ # only exist in the build directory. Sphinx needs all files in
111
+ # the same directory in order to generate the html, so we need to
112
+ # copy all the non-gnerated rst files from the source to the build
113
+ # directory before we run sphinx.
114
+ add_custom_target (copy-clang-rst-docs
115
+ COMMAND "${CMAKE_COMMAND} " -E copy_directory
116
+ "${CMAKE_CURRENT_SOURCE_DIR} " "${CMAKE_CURRENT_BINARY_DIR} "
117
+
118
+ COMMAND "${CMAKE_COMMAND} " -E copy_if_different
119
+ "${CMAKE_CURRENT_SOURCE_DIR} /../CodeOwners.rst"
120
+ "${CMAKE_CURRENT_BINARY_DIR} "
121
+ )
122
+
123
+ set (docs_targets "" )
124
+
106
125
if (${SPHINX_OUTPUT_HTML} )
107
126
add_sphinx_target (html clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
108
127
109
- # Copy rst files to build directory before generating the html
110
- # documentation. Some of the rst files are generated, so they
111
- # only exist in the build directory. Sphinx needs all files in
112
- # the same directory in order to generate the html, so we need to
113
- # copy all the non-gnerated rst files from the source to the build
114
- # directory before we run sphinx.
115
- add_custom_target (copy-clang-rst-docs
116
- COMMAND "${CMAKE_COMMAND} " -E copy_directory
117
- "${CMAKE_CURRENT_SOURCE_DIR} " "${CMAKE_CURRENT_BINARY_DIR} "
118
-
119
- COMMAND "${CMAKE_COMMAND} " -E copy_if_different
120
- "${CMAKE_CURRENT_SOURCE_DIR} /../CodeOwners.rst"
121
- "${CMAKE_CURRENT_BINARY_DIR} "
122
- )
123
- add_dependencies (docs-clang-html copy-clang-rst-docs )
124
-
125
128
add_custom_command (TARGET docs-clang-html POST_BUILD
126
129
COMMAND "${CMAKE_COMMAND} " -E copy
127
130
"${CMAKE_CURRENT_SOURCE_DIR} /LibASTMatchersReference.html"
128
131
"${CMAKE_CURRENT_BINARY_DIR} /html/LibASTMatchersReference.html" )
129
132
130
- # Generated files
131
- gen_rst_file_from_td (AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td docs-clang-html )
132
- gen_rst_file_from_td (DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td docs-clang-html )
133
- gen_rst_file_from_td (ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td docs-clang-html )
133
+ list (APPEND docs_targets "docs-clang-html" )
134
134
endif ()
135
135
if (${SPHINX_OUTPUT_MAN} )
136
- add_sphinx_target (man clang )
136
+ add_sphinx_target (man clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
137
+ list (APPEND docs_targets "docs-clang-man" )
137
138
endif ()
139
+
140
+ # Generated files
141
+ gen_rst_file_from_td (AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td "${docs_targets} " )
142
+ gen_rst_file_from_td (DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td "${docs_targets} " )
143
+ gen_rst_file_from_td (ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td "${docs_targets} " )
144
+
145
+ foreach (target ${docs_targets} )
146
+ add_dependencies (${target} copy-clang-rst-docs )
147
+ endforeach ()
138
148
endif ()
139
149
endif ()
0 commit comments