gpt4 book ai didi

Doxygen 的 CMake

转载 作者:行者123 更新时间:2023-12-04 01:31:22 24 4
gpt4 key购买 nike

我正在尝试将 CMake 用于 Doxygen 生成的文档。这是我的 CMakeList.txt 的样子:

if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/config-file)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}doc)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)

运行时 make ,我收到这些错误:
Doxygen build started
-- Configuring done
-- Generating done
-- Build files have been written to: /home/newproject/build
[ 5%] Generating API documentation with Doxygen
warning: tag INPUT: input source `doc/mainpage.txt' does not exist
warning: tag INPUT: input source `src/player.cpp' does not exist
warning: tag INPUT: input source `src/player.h' does not exist
warning: tag INPUT: input source `test/tests-mainfunctionality-v2.cpp' does not exist
error: tag OUTPUT_DIRECTORY: Output directory `doc' does not exist and cannot be created
Exiting...
CMakeFiles/doc_doxygen.dir/build.make:57: recipe for target 'CMakeFiles/doc_doxygen' failed
make[2]: *** [CMakeFiles/doc_doxygen] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/doc_doxygen.dir/all' failed
make[1]: *** [CMakeFiles/doc_doxygen.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

即使这些文件确实存在。我使用的路径有问题吗?

最佳答案

如果要从 CMake 二进制目录 ( build ) 运行 Doxygen,则必须修改 Doxygen 配置文件以包含正确的相对路径:

INPUT = ../doc/mainpage.txt \
../src/player.cpp \
../src/player.h \
../test/tests-mainfunctionality-v2.cpp

另外,您对 DOXYGEN_OUT 的使用看起来有点奇怪,因为它当前设置为二进制目录之外的内容。这个变量应该指定一个文件名,以便您的 configure_file()和自定义目标命令才能正常工作。也许,尝试将其重命名为这样的:
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/config-file)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/config-file.doxygen)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)

关于Doxygen 的 CMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60955881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com