我目前正在尝试设置 CMake 以自动生成我的 Doxygen 文档。我目前使用以下代码。
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file("docs/Doxyfile.in" "${PROJECT_BINARY_DIR}/Doxyfile")
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE}
"${PROJECT_BINARY_DIR}/Doxyfile"
SOURCES "${PROJECT_BINARY_DIR}/Doxyfile")
install(DIRECTORY "${PROJECT_BINARY_DIR}/docs/"
DESTINATION "docs")
endif()
当您输入make docs
它时,它可以正常工作,它会在PROJECT_BINARY_DIR/docs
. 当您输入make install
时,它将 docs 子目录复制到CMAKE_INSTALL_PREFIX
. 但是,当用户不希望生成文档而只是键入make install
时,会发生以下错误:
CMake Error at cmake_install.cmake:36 (FILE):
file INSTALL cannot find "/home/lukas/workspace/TheGame/build/docs".
如何指示install
仅在docs
构建自定义目标 ( ) 时执行命令(或者如果子目录docs
存在于 中PROJECT_BINARY_DIR
)?