无法在 C++ 项目中使用 Meson 的 Doxygen 运行

Cannot run Doxygen from Meson on a C++ project

我无法通过 Meson 的配置 运行 Doxygen。

这是meson.build中的相关代码:

doxygen = find_program('doxygen')
...
run_target('docs', command : 'doxygen ' + meson.source_root() + '/Doxyfile')

成功找到 doxygen 可执行文件:

Program doxygen found: YES (/usr/bin/doxygen)

但是,启动时,我收到此错误消息:

[0/1] Running external command docs.
Could not execute command "doxygen /home/project/Doxyfile". File not found.
FAILED: meson-docs

运行 从命令行手动运行它:

/usr/bin/doxygen /home/project/Doxyfile
doxygen /home/project/Doxyfile

我的 meson.build 配置有什么问题?

根据参考 manual,

command is a list containing the command to run and the arguments to pass to it. Each list item may be a string or a target

因此,在您的情况下,介子将整个字符串视为命令,即工具名称,而不是命令 + 参数。所以,试试这个:

run_target('docs', command : ['doxygen', meson.source_root() + '/Doxyfile'])

或者直接使用find_program():

的结果会更好
doxygen = find_program('doxygen', required : false)
if doxygen.found()
  message('Doxygen found')
  run_target('docs', command : [doxygen, meson.source_root() + '/Doxyfile'])    
else
  warning('Documentation disabled without doxygen')
endif

请注意,如果您想通过 Doxyfile.in 的支持改进文档生成,请查看 custom_target() instead and example like this