首页 > 解决方案 > 从 CMake 生成 qt 帮助文件

问题描述

我想使用qt 帮助框架为我的程序创建在线帮助。我的 doc 文件是由 doxygen 生成的,我想从中生成 qt 帮助生成器的文件。

我的程序是用 CMake 构建的,并且我添加了一个用于生成文档的目标:

cmake_minimum_required (VERSION 3.21.0)

find_package(Doxygen REQUIRED dot)

set (DOXYGEN_HIDDEN_SYMBOLS "")

if (DOXYGEN_FOUND)
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  doxygen_add_docs(
    myprograme-manual
    ${CMAKE_CURRENT_SOURCE_DIR}/en
  )
endif(DOXYGEN_FOUND)

之所以configure_file需要,是因为在配置中我使用了 CMake 变量,例如我的程序版本等。

这是我创建 qhp 文件的 doxyfile 的一部分。

GENERATE_QHP           = YES

# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
# the file name of the resulting .qch file. The path specified is relative to
# the HTML output folder.
# This tag requires that the tag GENERATE_QHP is set to YES.

QCH_FILE               = @DOC_OUTPUT_DIRECTORY@/manual.qch

# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
# (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_NAMESPACE          = my.program

# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_VIRTUAL_FOLDER     = doc

# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_CUST_FILTER_NAME   =

# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_CUST_FILTER_ATTRS  =

# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_SECT_FILTER_ATTRS  =

# The QHG_LOCATION tag can be used to specify the location (absolute path
# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to
# run qhelpgenerator on the generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES.

QHG_LOCATION           = 

问题是没有生成文件。从评论中我可以看到我需要定义QHG_LOCATION参数,这是qhelpgenerator. 由于我使用CMake,计算机上的qt路径不固定,我使用find_package它是为了使用Qt。如何从find_package(Qt)允许我定义 qhelpgenerator 位置的变量中定义一个变量?

标签: qtcmakedoxygen

解决方案


推荐阅读