【发布时间】:2020-07-12 07:36:41
【问题描述】:
我正在尝试将 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
即使这些文件确实存在。我使用的路径有问题吗?
【问题讨论】:
-
参数
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}表示doxygen可执行文件将从build 目录中调用。所以src/player.cpp不能从那个目录访问。 -
啊,明白了! @Tsyvarev 有什么方法可以直接从 CMakeLists 中的某个命令打开 index.html 文件?
-
@FSJ 要使用 CMake 打开生成的文档(例如
index.html),请参阅回复 here。